Ответ 1
Вы можете использовать метод WhenCalled
следующим образом:
myStub
.Stub(_ => _.Create(Arg<Invoice>.Is.Anything))
.Return(null) // will be ignored but still the API requires it
.WhenCalled(_ =>
{
var invoice = (Invoice)_.Arguments[0];
invoice.Id = 100;
_.ReturnValue = invoice;
});
а затем вы можете создать свой заглушку как таковой:
Invoice invoice = new Invoice { Id = 5 };
Invoice result = myStub.Create(invoice);
// at this stage result = invoice and invoice.Id = 100