public void the_customer_should_be_saved_if_the_address_was_created() { //Arrange var customerToCreateDto = new CustomerToCreateDto { FirstName = "Bob", LastName = "Builder" }; var mockAddressBuilder = new Mock<ICustomerAddressBuilder>(); var mockCustomerRepository = new Mock<ICustomerRepository>(); var customerService = new CustomerService(mockAddressBuilder.Object, mockCustomerRepository.Object); mockAddressBuilder.Setup(x => x.From(It.IsAny<CustomerToCreateDto>())).Returns(() => new Address()); //Act customerService.Create(customerToCreateDto); //Assert mockCustomerRepository.Verify(y=>y.Save(It.IsAny<Customer>())); }
public void an_exception_should_be_thrown_if_the_address_is_not_created() { //Arrange var customerToCreateDto = new CustomerToCreateDto {FirstName = "Bob", LastName = "Builder"}; var mockAddressBuilder = new Mock<ICustomerAddressBuilder>(); var mockCustomerRepository = new Mock<ICustomerRepository>(); var customerService = new CustomerService( mockAddressBuilder.Object, mockCustomerRepository.Object); //Act customerService.Create(customerToCreateDto); //Assert }