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 void Handle_ContactPersonDoesNotExist_ThrowArgumentNullException( DeleteStoreCustomerContactCommandHandler sut, DeleteStoreCustomerContactCommand command ) { //Act Func <Task> func = async() => await sut.Handle(command, CancellationToken.None); //Assert func.Should().Throw <ArgumentNullException>() .WithMessage("Value cannot be null. (Parameter 'contact')"); }
public void Handle_CustomerDoesNotExist_ThrowArgumentNullException( [Frozen] Mock <IRepository <Entities.StoreCustomer> > customerRepoMock, DeleteStoreCustomerContactCommandHandler sut, DeleteStoreCustomerContactCommand command ) { // Arrange 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')"); }