public void ShouldNotBeAbleToRemoveOrderInStateOtherThanNew() { // arrange var mock = new MockRepository(); var repository = mock.StrictMock<IOrderRepository>(); const string IdentityToken = "*****@*****.**"; const int OrderId = 2; Expect.Call(repository.RemoveOrder(IdentityToken, OrderId)).Throw(new ArgumentException()); var service = new OrderService(repository, new FakeEmailService(), this.logger); var request = new RemoveOrderRequest { IdentityToken = IdentityToken, Id = OrderId }; // act mock.ReplayAll(); var actual = service.RemoveOrder(request); mock.VerifyAll(); // assert Assert.That(actual, Is.Not.Null); Assert.That(actual.MessageType, Is.EqualTo(MessageType.Error)); }
public void ShouldBeAbleToRemoveOrder() { // arrange var mock = new MockRepository(); var repository = mock.StrictMock<IOrderRepository>(); const string IdentityToken = "*****@*****.**"; const int OrderId = 1; Expect.Call(repository.RemoveOrder(IdentityToken, OrderId)).Return(new Order { Id = 1 }); var service = new OrderService(repository, new FakeEmailService(), this.logger); var request = new RemoveOrderRequest { IdentityToken = IdentityToken, Id = OrderId }; // act mock.ReplayAll(); var actual = service.RemoveOrder(request); mock.VerifyAll(); // assert Assert.That(actual, Is.Not.Null); Assert.That(actual.MessageType, Is.EqualTo(MessageType.Success)); }