I am trying to check a set of properties, but I do not know how to do this in this particular case. I am using .NET 4.5 and the Moq framework.
I have this method:
public Invoice Approve(Invoice invoiceToBeApproved)
{
var approvedInvoiceStatus = InvoiceStatusRepository.First<ApprovedStatus>();
invoiceToBeApproved.Car.RemainingSeats -= 1;
if (invoiceToBeApproved.Car.RemainingSeats < 0)
{
throw new BusinessException("There are no remaining seats");
}
invoiceToBeApproved.InvoiceStatus = approvedInvoiceStatus;
InvoiceRepository.Update(invoiceToBeApproved);
context.SaveChanges();
return invoiceToBeApproved;
}
I am doing a unit test (not an integration test, so I am not going to db).
What I want to check
invoiceToBeApproved.Car.RemainingSeats -= 1;
I tried using VerifyGet, but I just can't reach this property.
Part of my test is
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 I check the kit / get RemainingSeats?
Thanks in advance!
source
share