public void TestOrderSendsEmailsIfUnfilled() { var order = new V2.Order(ProductType.Whiskey, 51m); var mailServiceStub = new MailServiceStub(); order.Mailer = mailServiceStub; order.Fill(warehouse); Assert.Equal(1, mailServiceStub.NumberOfMessagesSent); }
public void TestOrderSendsEmailsIfUnfilled() { V2.Order order = new V2.Order(ProductType.Whiskey, 51m); IWarehouse warehouse = MockRepository.GenerateStrictMock <IWarehouse>(); IMailService mailer = MockRepository.GenerateStrictMock <IMailService>(); order.Mailer = mailer; mailer.Expect(m => m.Send(Arg <Message> .Is.Anything)).Repeat.Once(); warehouse.Expect(wh => wh.HasInventory(Arg <ProductType> .Is.Anything, Arg <decimal> .Is.Anything)).Return(false).Repeat.Once(); order.Fill(warehouse); warehouse.VerifyAllExpectations(); mailer.VerifyAllExpectations(); }