Beispiel #1
0
        public void Addressee_Service_Add_ShouldHandlerException()
        {
            //Arrange
            var addresseeCmd = ObjectMother.AddresseeCommandToRegister();

            _mockAddresseeRepository.Setup(er => er.Add(It.IsAny <Addressee>())).Throws <Exception>();

            //Action
            Action act = () => _addresseeService.Add(addresseeCmd);

            //Assert
            act.Should().Throw <Exception>();
            _mockAddresseeRepository.Verify(er => er.Add(It.IsAny <Addressee>()), Times.Once);
        }
Beispiel #2
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);
        }