magritton
10/17/2017 - 4:23 PM

Unit testing expression result. This test two expressions againt each other

Unit testing expression result. This test two expressions againt each other

--Test Expression Result

DataTableHelper dataTableHelper = new DataTableHelper();
            var user = users[0];
            Expression<Func<User,string>> filterCol = dataTableHelper.createFilter(1);
            Expression<Func<User, string>> testExpression = u => u.LastName;
            Assert.AreEqual(testExpression.Compile().Invoke(user), filterCol.Compile().Invoke(user));
DataTableHelper dataTableHelper = new DataTableHelper();
var user = users[1];
            Expression<Func<User, bool>> filterCol = dataTableHelper.createSearch("TestLast2");
            Assert.IsTrue(filterCol.Compile().Invoke(user));
            user = users[0];
            Assert.IsFalse(filterCol.Compile().Invoke(user));