public void OrderShouldBeNullInAllRemoveMethod() { //Arrange var handler = Fixture.GetOrderHandler(); var command = GeneratedObjectsTests.GenerateRemoveAllCommand(); Fixture.OrderAdoRepositoryMock.Setup(r => r.GetLastCreatedOrderById(command.OrderId)) .Returns((Order)null); //Act var result = handler.Handle(command); //Assert Fixture.OrderAdoRepositoryMock.Verify(r => r.GetLastCreatedOrderById(command.OrderId), Times.Once); result.Should().BeNull(); handler.Notifications.Should().HaveCount(1); handler.Notifications.First().Message.Should().Be("Order isn't found."); }
public void OrderItemShouldBeAllRemovedInOrder() { //Arrange var handler = Fixture.GetOrderHandler(); var command = GeneratedObjectsTests.GenerateRemoveAllCommand(); var order = GeneratedObjectsTests.GenerateOrder(); Fixture.OrderAdoRepositoryMock.Setup(r => r.GetLastCreatedOrderById(command.OrderId)) .Returns(order); //Act var result = handler.Handle(command); //Assert Fixture.OrderAdoRepositoryMock.Verify(r => r.GetLastCreatedOrderById(command.OrderId), Times.Once); Fixture.OrderItemAdoRepositoryMock.Verify(r => r.DeleteAllbyOrderId(command.OrderId), Times.Once); result.Should().BeOfType <ReturnedItemCommandResult>(); }