public async Task Handle_ExistingCustomerAndAddress_DeleteCustomerAddress( [Frozen] Entities.Customer customer, [Frozen] Mock <IRepository <Entities.Customer> > customerRepoMock, DeleteCustomerAddressCommandHandler sut, DeleteCustomerAddressCommand command, Entities.Address address ) { //Arrange customer.AddAddress( new Entities.CustomerAddress( command.AddressType, address ) ); customerRepoMock.Setup(x => x.GetBySpecAsync( It.IsAny <GetCustomerSpecification>(), It.IsAny <CancellationToken>() )) .ReturnsAsync(customer); //Act var result = await sut.Handle(command, CancellationToken.None); //Assert result.Should().NotBeNull(); customerRepoMock.Verify(x => x.UpdateAsync( It.IsAny <Entities.Customer>(), It.IsAny <CancellationToken>() )); }
public void Handle_AddressDoesNotExist_ThrowArgumentNullException( DeleteCustomerAddressCommandHandler sut, DeleteCustomerAddressCommand command ) { //Act Func <Task> func = async() => await sut.Handle(command, CancellationToken.None); //Assert func.Should().Throw <ArgumentNullException>() .WithMessage("Value cannot be null. (Parameter 'customerAddress')"); }
public void Handle_CustomerDoesNotExist_ThrowArgumentNullException( [Frozen] Mock <IRepository <Entities.Customer> > customerRepoMock, DeleteCustomerAddressCommandHandler sut, DeleteCustomerAddressCommand command ) { // Arrange customerRepoMock.Setup(x => x.GetBySpecAsync( It.IsAny <GetCustomerSpecification>(), It.IsAny <CancellationToken>() )) .ReturnsAsync((Entities.Customer)null); //Act Func <Task> func = async() => await sut.Handle(command, CancellationToken.None); //Assert func.Should().Throw <ArgumentNullException>() .WithMessage("Value cannot be null. (Parameter 'customer')"); }