public void Handle_CustomerDoesNotExist_ThrowArgumentNullException( [Frozen] Mock <IRepository <Entities.StoreCustomer> > customerRepoMock, AddStoreCustomerContactCommandHandler sut, string accountNumber, string contactType ) { // Arrange var command = new AddStoreCustomerContactCommand { AccountNumber = accountNumber, CustomerContact = new StoreCustomerContactDto { ContactType = contactType, ContactPerson = new PersonDto { EmailAddresses = new List <EmailAddressDto> { new EmailAddressDto { EmailAddress = EmailAddress.Create("*****@*****.**").Value } } } } }; 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 async Task Handle_CustomerExist_AddStoreCustomerContact( [Frozen] Mock <IRepository <Entities.StoreCustomer> > customerRepoMock, AddStoreCustomerContactCommandHandler sut, string accountNumber, string contactType ) { //Arrange var command = new AddStoreCustomerContactCommand { AccountNumber = accountNumber, CustomerContact = new StoreCustomerContactDto { ContactType = contactType, ContactPerson = new PersonDto { EmailAddresses = new List <EmailAddressDto> { new EmailAddressDto { EmailAddress = EmailAddress.Create("*****@*****.**").Value } } } } }; //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>() )); }