-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add scenario tests and cleanup invalid test
- Loading branch information
1 parent
5e5de54
commit fba7e57
Showing
2 changed files
with
38 additions
and
18 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
tests/NServiceBusTutorial.UnitTests/ContributorVerificationSagaTests/SagaScenarioTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using FluentAssertions; | ||
using FluentAssertions.Execution; | ||
using NServiceBus.Testing; | ||
using NServiceBusTutorial.Core.ContributorAggregate.Commands; | ||
using NServiceBusTutorial.Core.ContributorAggregate.Events; | ||
using NServiceBusTutorial.Saga; | ||
using Xunit; | ||
|
||
namespace NServiceBusTutorial.UnitTests.ContributorVerificationSagaTests; | ||
|
||
public class SagaScenarioTests | ||
{ | ||
[Fact] | ||
public async Task ShouldInitializeSagaAndMarkAsCompleted() | ||
{ | ||
int expectedContributorId = 1; | ||
var startMessage = new StartContributorVerificationCommand() | ||
{ | ||
ContributorId = expectedContributorId | ||
}; | ||
var message = new ContributorVerifiedEvent() | ||
{ | ||
ContributorId = expectedContributorId | ||
}; | ||
var saga = new TestableSaga<ContributorVerificationSaga, ContributorVerificationSagaData>(); | ||
var context = new TestableMessageHandlerContext(); | ||
|
||
var result = await saga.Handle(startMessage, context); | ||
|
||
using var assertionScope = new AssertionScope(); | ||
result.SagaDataSnapshot.ContributorId.Should().Be(expectedContributorId); | ||
|
||
result = await saga.Handle(message, context); | ||
result.Completed.Should().BeTrue(); | ||
var timeoutMessage = result.FindTimeoutMessage<ContributorVerificationSagaTimeout>(); | ||
timeoutMessage.Should().NotBeNull(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters