public void ShippingCompany_Service_Update_Sucessfully()
        {
            //Arrange
            var shippingCompany    = ObjectMother.ShippingCompanyValidWithIdWithAddress();
            var shippingCompanyCmd = ObjectMother.ShippingCompanyCommandToUpdate();
            var updated            = true;

            _mockShippingCompanyRepository.Setup(e => e.GetById(shippingCompanyCmd.Id)).Returns(shippingCompany);
            _mockShippingCompanyRepository.Setup(er => er.Update(shippingCompany)).Returns(updated);

            //Action
            var updatedShippingCompany = _shippingCompanyService.Update(shippingCompanyCmd);

            //Verificar
            _mockShippingCompanyRepository.Verify(e => e.GetById(shippingCompanyCmd.Id), Times.Once);
            _mockShippingCompanyRepository.Verify(er => er.Update(shippingCompany), Times.Once);
            updatedShippingCompany.Should().BeTrue();
        }
Ejemplo n.º 2
0
        public IHttpActionResult Update(ShippingCompanyUpdateCommand shippingCompany)
        {
            var validador = shippingCompany.Validate();

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

            return(HandleCallback(_service.Update(shippingCompany)));
        }
        public async Task <IActionResult> Put([FromBody] ShippingCompanyDto shippingCompanyDto)
        {
            _ = await _shippingCompanyService.Update(shippingCompanyDto);

            return(Response(shippingCompanyDto.ShippingCompanyId));
        }