public async Task Handle_CustomerExist_AddCustomerAddress( [Frozen] Mock <IRepository <Entities.Customer> > customerRepoMock, AddCustomerAddressCommandHandler sut, AddCustomerAddressCommand command ) { // Arrange //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_CustomerDoesNotExist_ThrowArgumentNullException( [Frozen] Mock <IRepository <Entities.Customer> > customerRepoMock, AddCustomerAddressCommandHandler sut, AddCustomerAddressCommand 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')"); }