public void Handle_EmailAddressDoesNotExist_ThrowArgumentNullException( [Frozen] Mock <IRepository <Entities.IndividualCustomer> > customerRepoMock, DeleteIndividualCustomerEmailAddressCommandHandler sut, Entities.Person person, string accountNumber ) { //Arrange var command = new DeleteIndividualCustomerEmailAddressCommand { AccountNumber = accountNumber, EmailAddress = EmailAddress.Create("*****@*****.**").Value }; customerRepoMock.Setup(_ => _.GetBySpecAsync( It.IsAny <GetIndividualCustomerSpecification>(), It.IsAny <CancellationToken>() ) ) .ReturnsAsync(new Entities.IndividualCustomer(person)); //Act Func <Task> func = async() => await sut.Handle(command, CancellationToken.None); //Assert func.Should().Throw <ArgumentNullException>() .WithMessage("Value cannot be null. (Parameter 'emailAddress')"); }
public async Task Handle_ExistingCustomer_DeleteEmailAddress( [Frozen] Mock <IRepository <Entities.IndividualCustomer> > customerRepoMock, Entities.Person person, DeleteIndividualCustomerEmailAddressCommandHandler sut, string accountNumber ) { //Arrange var command = new DeleteIndividualCustomerEmailAddressCommand { AccountNumber = accountNumber, EmailAddress = EmailAddress.Create("*****@*****.**").Value }; person.AddEmailAddress( new Entities.PersonEmailAddress(command.EmailAddress) ); customerRepoMock.Setup(x => x.GetBySpecAsync( It.IsAny <GetIndividualCustomerSpecification>(), It.IsAny <CancellationToken>() )) .ReturnsAsync(new Entities.IndividualCustomer(person)); //Act var result = await sut.Handle(command, CancellationToken.None); //Assert result.Should().NotBeNull(); customerRepoMock.Verify(x => x.GetBySpecAsync( It.IsAny <GetIndividualCustomerSpecification>(), It.IsAny <CancellationToken>() )); customerRepoMock.Verify(x => x.UpdateAsync( It.IsAny <Entities.IndividualCustomer>(), It.IsAny <CancellationToken>() )); }