The following test in VS 2010:
Where Customer is this:
And Order is this:
Results in a MockAssertionException with the following message:
Exepcted call on the mock should be once.But was 0 times.
As you can see in the GetCustomerAddress implementation of Order, the code does indeed call GetAddress on the ICustomer instance. Additionally, message formatting and spelling is incorrect.
Joe
| ICustomer cust = Mock.Create<ICustomer>(); |
| Order ord = new Order(cust); |
| Mock.Assert(() => cust.GetAddress(), Occurs.Once()); |
| ord.GetCustomerAddress(); |
Where Customer is this:
| namespace MockTest |
| { |
| public class Customer : MockTest.ICustomer |
| { |
| public string GetAddress() |
| { |
| return "some address"; |
| } |
| } |
| } |
And Order is this:
| namespace MockTest |
| { |
| public class Order |
| { |
| ICustomer m_cust; |
| public Order(ICustomer cust) |
| { |
| m_cust = cust; |
| } |
| public string GetCustomerAddress() |
| { |
| return m_cust.GetAddress(); |
| } |
| } |
| } |
Results in a MockAssertionException with the following message:
Exepcted call on the mock should be once.But was 0 times.
As you can see in the GetCustomerAddress implementation of Order, the code does indeed call GetAddress on the ICustomer instance. Additionally, message formatting and spelling is incorrect.
Joe