コード例 #1
0
        public void ShippingCompany_Service_Add_Sucessfully()
        {
            //Arrange
            var shippingCompany    = ObjectMother.ShippingCompanyValidWithIdWithAddress();
            var shippingCompanyCmd = ObjectMother.ShippingCompanyCommandToRegister();

            _mockShippingCompanyRepository.Setup(er => er.Add(It.IsAny <ShippingCompany>())).Returns(shippingCompany);

            //Action
            var addShippingCompany = _shippingCompanyService.Add(shippingCompanyCmd);

            //Verificar
            _mockShippingCompanyRepository.Verify(er => er.Add(It.IsAny <ShippingCompany>()), Times.Once);
            addShippingCompany.Should().Be(shippingCompany.Id);
        }
コード例 #2
0
        public IHttpActionResult Add(ShippingCompanyRegisterCommand command)
        {
            var validador = command.Validate();

            if (!validador.IsValid)
            {
                return(HandleValidationFailure(validador.Errors));
            }

            return(HandleCallback(_service.Add(command)));
        }