public async Task Handle_ExistingCustomerAndContact_DeleteContact( [Frozen] Mock <IRepository <Entities.StoreCustomer> > customerRepoMock, Entities.StoreCustomer customer, DeleteStoreCustomerContactCommandHandler sut, DeleteStoreCustomerContactCommand command ) { // Arrange customer.AddContact(new Entities.StoreCustomerContact( command.CustomerContact.ContactType, new Entities.Person( command.CustomerContact.ContactPerson.Title, command.CustomerContact.ContactPerson.Name ) )); 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>() )); }
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>() )); }