Skip to content

Commit a23872c

Browse files
committed
Add a few chain tests
1 parent dc3cb07 commit a23872c

File tree

4 files changed

+61
-3
lines changed

4 files changed

+61
-3
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using BeekmanLabs.UnitTesting;
2+
using InEngine.Commands;
3+
using InEngine.Core.Commands;
4+
using InEngine.Core.Exceptions;
5+
using Moq;
6+
using NUnit.Framework;
7+
using Quartz;
8+
9+
namespace InEngine.Core.Test.Commands
10+
{
11+
[TestFixture]
12+
public class ChainTest : TestBase<Chain>
13+
{
14+
[SetUp]
15+
public void Setup()
16+
{
17+
}
18+
19+
[Test]
20+
public void ShouldRunChainOfCommands()
21+
{
22+
var mockCommand1 = new Mock<AbstractCommand>();
23+
var mockCommand2 = new Mock<AbstractCommand>();
24+
var commands = new[] {
25+
mockCommand1.Object,
26+
mockCommand2.Object,
27+
};
28+
Subject.Commands = commands;
29+
30+
Subject.Run();
31+
32+
mockCommand1.Verify(x => x.Run(), Times.Once());
33+
mockCommand2.Verify(x => x.Run(), Times.Once());
34+
}
35+
36+
[Test]
37+
public void ShouldRunChainOfCommandsAndFail()
38+
{
39+
var mockCommand1 = new Mock<AlwaysFail>();
40+
var mockCommand2 = new Mock<AlwaysFail>();
41+
var alwaysFail = new AlwaysFail();
42+
var commands = new[] {
43+
mockCommand1.Object,
44+
new AlwaysFail(),
45+
mockCommand2.Object,
46+
};
47+
Subject.Commands = commands;
48+
49+
Assert.That(Subject.Run, Throws.TypeOf<CommandChainFailedException>());
50+
51+
mockCommand1.Verify(x => x.Run(), Times.Once());
52+
mockCommand2.Verify(x => x.Run(), Times.Never());
53+
}
54+
}
55+
}

src/InEngine.Core.Test/InEngine.Core.Test.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
</ItemGroup>
3131
<ItemGroup>
3232
<Folder Include="Scheduling\" />
33+
<Folder Include="Commands\" />
3334
</ItemGroup>
3435
</Project>
3536

src/InEngine.Core.Test/Queuing/QueueTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void Setup()
2727
[Test]
2828
public void ShouldPublishCommand()
2929
{
30-
var command = Fake.It();
30+
var command = new AlwaysSucceed();
3131
MockQueueClient.Setup(x => x.Publish(command));
3232

3333
Subject.Publish(command);

src/InEngine.Core/Exceptions/CommandChainFailedException.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ namespace InEngine.Core.Exceptions
44
{
55
public class CommandChainFailedException : Exception
66
{
7+
public CommandChainFailedException() : base()
8+
{}
9+
710
public CommandChainFailedException(string message, Exception innerException) : base(message, innerException)
8-
{
9-
}
11+
{}
1012
}
1113
}

0 commit comments

Comments
 (0)