public void Handle_CustomerDoesNotExist_ThrowArgumentNullException( [Frozen] Mock <IRepository <Entities.StoreCustomer> > customerRepoMock, UpdateStoreCustomerContactCommandHandler sut, string accountNumber, string contactType ) { // Arrange var command = new UpdateStoreCustomerContactCommand { AccountNumber = accountNumber, CustomerContact = new StoreCustomerContactDto { ContactType = contactType, ContactPerson = new PersonDto { EmailAddresses = new List <EmailAddressDto>() } } }; customerRepoMock.Setup(x => x.GetBySpecAsync( It.IsAny <GetStoreCustomerSpecification>(), It.IsAny <CancellationToken>() )) .ReturnsAsync((Entities.StoreCustomer)null); //Act Func <Task> func = async() => await sut.Handle(command, CancellationToken.None); //Assert func.Should().Throw <ArgumentNullException>() .WithMessage("Value cannot be null. (Parameter 'storeCustomer')"); }
public void Handle_ContactDoesNotExist_ThrowArgumentNullException( UpdateStoreCustomerContactCommandHandler sut, string accountNumber, string contactType ) { //Arrange var command = new UpdateStoreCustomerContactCommand { AccountNumber = accountNumber, CustomerContact = new StoreCustomerContactDto { ContactType = contactType, ContactPerson = new PersonDto { EmailAddresses = new List <EmailAddressDto>() } } }; //Act Func <Task> func = async() => await sut.Handle(command, CancellationToken.None); //Assert func.Should().Throw <ArgumentNullException>() .WithMessage("Value cannot be null. (Parameter 'contact')"); }
public async Task Handle_CustomerAndContactExist_UpdateStoreCustomerContact( [Frozen] Mock <IRepository <Entities.StoreCustomer> > customerRepoMock, Entities.StoreCustomer customer, UpdateStoreCustomerContactCommandHandler sut, Entities.Person contactPerson, string accountNumber, string contactType ) { //Arrange var command = new UpdateStoreCustomerContactCommand { AccountNumber = accountNumber, CustomerContact = new StoreCustomerContactDto { ContactType = contactType, ContactPerson = new PersonDto { EmailAddresses = new List <EmailAddressDto> { new EmailAddressDto { EmailAddress = EmailAddress.Create("*****@*****.**").Value } } } } }; customer.AddContact( new Entities.StoreCustomerContact( command.CustomerContact.ContactType, contactPerson ) ); customerRepoMock.Setup(x => x.GetBySpecAsync( It.IsAny <GetStoreCustomerSpecification>(), 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.StoreCustomer>(), It.IsAny <CancellationToken>() )); }