Skip to content

Commit 9ecbf04

Browse files
Add unit test to ensure changes to SetupContext are correct
1 parent 3fa194c commit 9ecbf04

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using NSubstitute;
2+
using Xunit;
3+
4+
namespace Cake.Core.Tests.Unit
5+
{
6+
public sealed class SetupContextTests
7+
{
8+
public sealed class TheConstructor
9+
{
10+
[Fact]
11+
public void Returns_Empty_Tasks_When_Input_Is_Null()
12+
{
13+
var cakeContextMock = Substitute.For<ICakeContext>();
14+
var cakeTaskInfoMock = Substitute.For<ICakeTaskInfo>();
15+
16+
// Given, When
17+
var result = new SetupContext(cakeContextMock, cakeTaskInfoMock, null);
18+
19+
// Then
20+
Assert.NotNull(result.TasksToExecute);
21+
Assert.Empty(result.TasksToExecute);
22+
}
23+
24+
[Fact]
25+
public void Returns_Injected_Tasks_When_Input_Is_Not_Null()
26+
{
27+
var cakeContextMock = Substitute.For<ICakeContext>();
28+
var cakeTaskInfoMock = Substitute.For<ICakeTaskInfo>();
29+
30+
// Given, When
31+
var result = new SetupContext(cakeContextMock, cakeTaskInfoMock, new[]
32+
{
33+
cakeTaskInfoMock
34+
});
35+
36+
// Then
37+
Assert.NotNull(result.TasksToExecute);
38+
Assert.Single(result.TasksToExecute);
39+
}
40+
}
41+
}
42+
}

0 commit comments

Comments
 (0)