Beispiel #1
0
        public void ConvertExpressionTypeTest()
        {
            Expression<Func<UserDTO, bool>> expression = dto => dto.UserName.Contains("11");
            Func<User, bool> newFunc = ExpressionConvertor<UserDTO, User>.Convert(expression).Compile();

            User u = new User("111", "password", null);
            bool b = newFunc(u);
            Assert.IsTrue(b);

            u = new User("ert", "password", null);
            b = newFunc(u);
            Assert.IsTrue(!b);
        }
Beispiel #2
0
        public void UpdateAllNotNullOrEmptyTest()
        {
            User user = new User("qianlifeng", "qlf", "[email protected]", "test", null);
            UserDTO userDTO = new UserDTO
                {
                    UserName = "qianlifeng2",
                    NickName = "qlf2"
                };

            User userNew = ReflectUtil.UpdateNotEmptyValues(userDTO, user);

            Assert.IsTrue(userNew.UserName == userDTO.UserName);
            Assert.IsTrue(userNew.NickName == userDTO.NickName);
            Assert.IsTrue(userNew.Email != userDTO.Email);
        }