public void ShouldGetAddressByUser()
        {
            var expected = _addresses.Where(a => a.UserId == 1).ToList();
            _addressRepository = new Mock<IAddressRepository>();
            _addressRepository.Setup(a => a.Find(It.IsAny<Expression<Func<Address, bool>>>(), true))
                .Returns(expected);

            _addressLogic = new AddressLogic(_addressRepository.Object);

            var result = _addressLogic.GetByUser(1);

            Assert.AreEqual(1, result.AddressId);
            Assert.AreEqual(1, result.UserId);
        }
        public void ShouldThrowExceptionWhenGetAddressByUserFails()
        {
            _addressRepository = new Mock<IAddressRepository>();
            _addressRepository.Setup(a => a.Find(It.IsAny<Expression<Func<Address, bool>>>(), true))
                .Throws(new Exception());

            _addressLogic = new AddressLogic(_addressRepository.Object);

            Assert.Throws<BlogException>(() => _addressLogic.GetByUser(1));
        }
        public void ShouldErrorWhenGetAddressByUserFoundNoRecord()
        {
            _addressRepository = new Mock<IAddressRepository>();
            _addressRepository.Setup(a => a.Find(It.IsAny<Expression<Func<Address, bool>>>(), true))
                .Returns(new List<Address>());

            _addressLogic = new AddressLogic(_addressRepository.Object);

            var result = _addressLogic.GetByUser(1);

            Assert.IsNotNull(result.Error);
            Assert.AreEqual((int)Constants.Error.RecordNotFound, result.Error.Id);
            Assert.AreEqual("No address found for user with Id 1", result.Error.Message);
        }