Exemple #1
0
        public void TestMethodPredicate()
        {
            var peopleList = new List <People>()
            {
                new People {
                    Name = "Name1", Age = 41, Height = 1.1
                },
                new People {
                    Name = "Name2", Age = 42, Height = 1.2
                },
                new People {
                    Name = "Name3", Age = 43, Height = 1.3
                }
            };

            var predicate = new PredicateUtils();
            var filter    = new PeopleFilter {
                AgeFilter = 42
            };
            var result = predicate.FilterList(peopleList, filter);

            Assert.IsTrue(result.Any());
            Assert.AreEqual(result.First().Name, "Name2");

            filter = new PeopleFilter {
                Name = "Name3"
            };
            result = predicate.FilterList(peopleList, filter);
            Assert.IsTrue(result.Any());
            Assert.AreEqual(result.First().Age, 43);
        }
Exemple #2
0
        public void TestMethodGeneratePredicate1()
        {
            var predicate   = new PredicateUtils();
            var filterClass = new PeopleFilter {
                Height = 182
            };
            var filter = predicate.GeneratePredicate(filterClass);

            Assert.AreEqual(filter, "Height=182");
        }