【发布时间】:2016-05-25 17:28:40
【问题描述】:
我有以下单元测试。
[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((Context context, PaymentSpecification spec, Guid guid) =>
{
return paymentSpecificationResponse;
}
);
}
当 Distributions 数组为只读时,如何更改测试以将 paymentSpecificationResponse.Distributions[0].Transaction.GetVendorId() 返回为“1”。
【问题讨论】:
标签: c# .net unit-testing moq