Exemple #1
0
        public void Addressee_Service_Add_Sucessfully()
        {
            //Arrange
            var addressee    = ObjectMother.AddresseeValidWithIdWithAddress();
            var addresseeCmd = ObjectMother.AddresseeCommandToRegister();

            _mockAddresseeRepository.Setup(er => er.Add(It.IsAny <Addressee>())).Returns(addressee);

            //Action
            var addAddressee = _addresseeService.Add(addresseeCmd);

            //Assert
            _mockAddresseeRepository.Verify(er => er.Add(It.IsAny <Addressee>()), Times.Once);
            addAddressee.Should().Be(addressee.Id);
        }
        public IHttpActionResult Add(AddresseeRegisterCommand command)
        {
            var validador = command.Validate();

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

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