c# - Testing a get/set with Moq -
i'm trying test set of property, don't know how can in particular case. i'm using .net 4.5 , moq framework.
i've method:
public invoice approve(invoice invoicetobeapproved) { var approvedinvoicestatus = invoicestatusrepository.first<approvedstatus>(); invoicetobeapproved.car.remainingseats -= 1; if (invoicetobeapproved.car.remainingseats < 0) { throw new businessexception("there no remaining seats"); } invoicetobeapproved.invoicestatus = approvedinvoicestatus; invoicerepository.update(invoicetobeapproved); context.savechanges(); return invoicetobeapproved; }
i'm doing unit test (not integration test, i'm not going db).
what want test
invoicetobeapproved.car.remainingseats -= 1;
i tried using verifyget, can't reach property.
part of test this
var newinvoice = invoiceservice.approveinvoice(invoice); invoicestatusrepository.verify(x => x.first<approvedstatus>()); invoicerepository.verify(x => x.update(it.isany<invoice>())); context.verify(x => x.savechanges(), times.exactly(1));
how can test set/get of remainingseats?
thanks in advance!
i don't think should use moq @ this. assuming invoice
poco, assert value of property.
Comments
Post a Comment