Skip to content

Commit

Permalink
Merge branch 'release-5.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Bussmann committed Oct 27, 2015
2 parents 993b097 + e27a929 commit ce651b6
Show file tree
Hide file tree
Showing 6 changed files with 225 additions and 71 deletions.
24 changes: 8 additions & 16 deletions src/NServiceBus.Testing.Tests/InvocationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,30 @@ public void PublishValuePositive()
}

[Test]
[ExpectedException]
public void PublishBasicNegativeCheck()
{
var i = new PublishInvocation<MessageA> {Message = new MessageA()};
var exp = new ExpectedPublishInvocation<MessageA> {Check = m => false};

exp.Validate(i);
Assert.Throws<Exception>(() => exp.Validate(i));
}

[Test]
[ExpectedException]
public void PublishValueNegativeCheck()
{
var i = new PublishInvocation<MessageA> {Message = new MessageA {Value = 2}};
var exp = new ExpectedPublishInvocation<MessageA> {Check = m => m.Value == 3};

exp.Validate(i);
Assert.Throws<Exception>(() => exp.Validate(i));
}

[Test]
[ExpectedException]
public void PublishBasicNegativeType()
{
var i = new PublishInvocation<MessageA> {Message = new MessageA()};
var exp = new ExpectedPublishInvocation<MessageB> {Check = m => true};

exp.Validate(i);
Assert.Throws<Exception>(() => exp.Validate(i));
}

[Test]
Expand All @@ -75,33 +72,30 @@ public void PublishValueMultiplePositive()
}

[Test]
[ExpectedException]
public void NotPublishBasicNegative()
{
var i = new PublishInvocation<MessageA> {Message = new MessageA()};
var exp = new ExpectedNotPublishInvocation<MessageA> {Check = m => true};

exp.Validate(i);
Assert.Throws<Exception>(() => exp.Validate(i));
}

[Test]
[ExpectedException]
public void SendPublishMismatchOne()
{
var i = new SendInvocation<MessageA> {Message = new MessageA()};
var exp = new ExpectedPublishInvocation<MessageA> {Check = m => true};

exp.Validate(i);
Assert.Throws<Exception>(() => exp.Validate(i));
}

[Test]
[ExpectedException]
public void SendPublishMismatchTwo()
{
var i = new PublishInvocation<MessageA> {Message = new MessageA()};
var exp = new ExpectedSendInvocation<MessageA> {Check = m => true};

exp.Validate(i);
Assert.Throws<Exception>(() => exp.Validate(i));
}

[Test]
Expand Down Expand Up @@ -133,23 +127,21 @@ public void SendToSitesBasicPositive()
}

[Test]
[ExpectedException]
public void SendToSitesBasicNegativeCheck()
{
var i = new SendToSitesInvocation<MessageA> { Message = new MessageA() , Value = new[] { "SiteA" } };
var exp = new ExpectedSendToSitesInvocation<MessageA> { Check = (m, a) => false };

exp.Validate(i);
Assert.Throws<Exception>(() => exp.Validate(i));
}

[Test]
[ExpectedException]
public void NotSendToSitesBasicNegative()
{
var i = new SendToSitesInvocation<MessageA> { Message = new MessageA(), Value = new[] { "SiteA" } };
var exp = new ExpectedNotSendToSitesInvocation<MessageA> { Check = (m, a) => true };

exp.Validate(i);
Assert.Throws<Exception>(() => exp.Validate(i));
}

[Test]
Expand Down
35 changes: 34 additions & 1 deletion src/NServiceBus.Testing.Tests/SagaTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ public void RemoteOrderWithAssertions()
.When(s => s.Handle(new SubmitOrder { Total = total, IsRemoteOrder = true }));
}


[Test]
public void DiscountTestWithSpecificTimeout()
{
Expand All @@ -131,13 +130,46 @@ public void DiscountTestWithSpecificTimeout()
.ExpectTimeoutToBeSetIn<SubmitOrder>((state, span) => span == TimeSpan.FromDays(7))
.When(s => s.Handle(new SubmitOrder {Total = 200}));
}

[Test]
public void TestNullReferenceException()
{
Test.Initialize();
var saga = new MySaga();
Assert.DoesNotThrow(() => Test.Saga(saga));
}

[Test]
public void ShouldFailExpectForwardCurrentMessageToIfMessageForwardedToUnexpectedDestination()
{
Assert.Throws<Exception>(() => Test.Saga<MySaga>()
.ExpectForwardCurrentMessageTo(dest => dest == "expectedDestination")
.When(s => s.Handle(new StartsSaga())));
}

[Test]
public void ShouldPassExpectForwardCurrentMessageToIfMessageForwardedToExpectedDestination()
{
Test.Saga<MySaga>()
.ExpectForwardCurrentMessageTo(dest => dest == "forwardingDestination")
.When(s => s.Handle(new StartsSaga()));
}

[Test]
public void ShouldFailExpectNotForwardCurrentMessageToIfMessageForwardedToExpectedDestination()
{
Assert.Throws<Exception>(() => Test.Saga<MySaga>()
.ExpectNotForwardCurrentMessageTo(dest => dest == "forwardingDestination")
.When(s => s.Handle(new StartsSaga())));
}

[Test]
public void ShouldPassExpectNotForwardCurrentMessageToIfMessageForwardedToUnexpectedDestination()
{
Test.Saga<MySaga>()
.ExpectNotForwardCurrentMessageTo(dest => dest == "expectedDestination")
.When(s => s.Handle(new StartsSaga()));
}
}


Expand Down Expand Up @@ -198,6 +230,7 @@ public void Handle(StartsSaga message)
ReplyToOriginator(new ResponseToOriginator());
Bus.Publish<Event>();
Bus.Send<Command>(null);
Bus.ForwardCurrentMessageTo("forwardingDestination");
RequestTimeout(TimeSpan.FromDays(7), message);
}

Expand Down
Loading

0 comments on commit ce651b6

Please sign in to comment.