Hello,
I have some question about unit testing.
Does anybody know if it is possible to verify that markAsComplete was called in a saga-messagehandler?
Regards Nikias,
Hello,
I have some question about unit testing.
Does anybody know if it is possible to verify that markAsComplete was called in a saga-messagehandler?
Regards Nikias,
Hi Nikias
Assuming you use the AAA-style you can simply do the following
[Test]
public async Task ShouldProcessDiscountOrder()
{
// arrange
var saga = new DiscountPolicy
{
Data = new DiscountPolicyData()
};
var context = new TestableMessageHandlerContext();
var discountOrder = new SubmitOrder
{
CustomerId = Guid.NewGuid(),
OrderId = Guid.NewGuid(),
TotalAmount = 1000
};
// act
await saga.Handle(discountOrder, context)
.ConfigureAwait(false);
// assert
var processMessage = (ProcessOrder)context.SentMessages[0].Message;
Assert.That(processMessage.TotalAmount, Is.EqualTo(900));
Assert.That(saga.Completed, Is.True);
}
I have updated the documentation to include an assert on the completed flag.
Regards
Daniel
Ok great thanks for the info!