コード例 #1
0
        public async Task Handle_CustomerAndAddressExist_UpdateCustomerAddress(
            [Frozen] Mock <IRepository <Entities.Customer> > customerRepoMock,
            Entities.Customer customer,
            UpdateCustomerAddressCommandHandler sut,
            UpdateCustomerAddressCommand command,
            Entities.Address address
            )
        {
            //Arrange
            customer.AddAddress(
                new Entities.CustomerAddress(
                    command.CustomerAddress.AddressType,
                    address
                    )
                );

            customerRepoMock.Setup(x => x.GetBySpecAsync(
                                       It.IsAny <GetCustomerSpecification>(),
                                       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.Customer>(),
                                        It.IsAny <CancellationToken>()
                                        ));
        }
コード例 #2
0
        public void Handle_CustomerAddressDoesNotExist_ThrowArgumentNullException(
            UpdateCustomerAddressCommandHandler sut,
            UpdateCustomerAddressCommand command
            )
        {
            //Act
            Func <Task> func = async() => await sut.Handle(command, CancellationToken.None);

            //Assert
            func.Should().Throw <ArgumentNullException>()
            .WithMessage("Value cannot be null. (Parameter 'customerAddress')");
        }
コード例 #3
0
        public void Handle_CustomerDoesNotExist_ThrowArgumentNullException(
            [Frozen] Mock <IRepository <Entities.Customer> > customerRepoMock,
            UpdateCustomerAddressCommandHandler sut,
            UpdateCustomerAddressCommand command
            )
        {
            // Arrange
            customerRepoMock.Setup(x => x.GetBySpecAsync(
                                       It.IsAny <GetCustomerSpecification>(),
                                       It.IsAny <CancellationToken>()
                                       ))
            .ReturnsAsync((Entities.Customer)null);

            //Act
            Func <Task> func = async() => await sut.Handle(command, CancellationToken.None);

            //Assert
            func.Should().Throw <ArgumentNullException>()
            .WithMessage("Value cannot be null. (Parameter 'customer')");
        }