예제 #1
0
        public void ShouldTransformAddressToDto()
        {
            var param = new Db.Address
            {
                AddressId = 1,
                City = "Ipsum City",
                Country = "Dolor Republic",
                State = "Lorem State",
                StreetAddress = "Foo Street",
                Zip = 1,
                UserId = 1,
                User = new Db.User { UserId = 1 }
            };

            var result = AddressMapper.ToDto(param);

            Assert.IsInstanceOf(typeof(Address), result);
            Assert.NotNull(result);
        }
예제 #2
0
        public void ShouldUpdateAddress()
        {
            var dbResult = new Address
            {
                AddressId = 3,
                StreetAddress = "Wiggle",
                City = "Berry",
                State = "Carrot",
                Country = "Gumbo",
                Zip = 1234,
                UserId = 5,
                User = new User
                {
                    UserId = 5,
                    UserName = "******"
                }
            };
            _addressRepository = new Mock<IAddressRepository>();
            _addressRepository.Setup(a => a.Edit(It.IsAny<Address>())).Returns(dbResult);

            _addressLogic = new AddressLogic(_addressRepository.Object);

            var result = _addressLogic.Update(new Common.Contracts.Address
            {
                AddressId = 3,
                StreetAddress = "Wiggle",
                City = "Berry",
                State = "Carrot",
                Country = "Gumbo",
                Zip = 1234
            });

            Assert.IsNotNull(result);
            Assert.AreEqual(5, result.UserId);
        }