示例#1
0
        public async Task Handle_CustomerExist_AddCustomerAddress(
            [Frozen] Mock <IRepository <Entities.Customer> > customerRepoMock,
            AddCustomerAddressCommandHandler sut,
            AddCustomerAddressCommand command
            )
        {
            // Arrange

            //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_CustomerDoesNotExist_ThrowArgumentNullException(
            [Frozen] Mock <IRepository <Entities.Customer> > customerRepoMock,
            AddCustomerAddressCommandHandler sut,
            AddCustomerAddressCommand 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')");
        }