Ejemplo n.º 1
0
        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>()
                                        ));
        }