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); }
public void UpdateAllNotNullOrEmptyTest() { User user = new User("qianlifeng", "qlf", "*****@*****.**", "test", null); UserDTO userDTO = new UserDTO { UserName = "******", 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); }