I am writing a unit test case where I need to rollback the first payment when the first payment is a success and the second payment fails. The unit test code looks like the following:
- Process first payment successfully.
- Process second payment. External system will throw similar transaction fault exception. Parse similar transaction fault exception to get exceptionid and process second transaction again, using the exception id.
- When the second transaction is actually processed, the system returns a "Payment declined fault exception".
- The system should then void the first payment.
I have written the unit test for (1). How SO community have pointers on how to take care of part 2, 3, 4?
[TestMethod]
public void IfTheSecondPaymentFailsThenTheFirstPaymentShouldBeVoided()
{
var iPaymentMock = new Mock<IPaymentMock>();
var paymentSpecificationResponse = new PreregisteredAccountSpec();
iPaymentMock.Setup(
counter => counter.ProcessPayment
(
It.IsAny<Context>(),
It.IsAny<PreregisteredAccountSpec>(),
It.IsAny<Guid>())
).
Returns(paymentSpecificationResponse);
iPaymentMock.Verify((
counter => counter.ProcessPaymentSpecification
(
It.IsAny<Context>(),
It.IsAny<PreregisteredAccountSpec>(),
It.IsAny<Guid>()
)
), Times.Once());
}
Aucun commentaire:
Enregistrer un commentaire