private IEnumerable <T> TestFilter <T>(string property, string operation, object value, IEnumerable <T> items)
        {
            var genericFilter       = new FilterCriteria(property, operation, value);
            var genericFilterHelper = new GenericFilterHelper(new DomainObjectModelMock());
            var filterObject        = genericFilterHelper.ToFilterObjects(new FilterCriteria[] { genericFilter }).Single();
            var filterExpression    = genericFilterHelper.ToExpression <T>((IEnumerable <PropertyFilter>)filterObject.Parameter);
            var filteredItems       = items.AsQueryable().Where(filterExpression).ToList();

            return(filteredItems);
        }
        private static void TestFilterByName(string expected, IEnumerable<C> items, string operation, object value)
        {
            var genericFilter = new FilterCriteria("Name", operation, value);
            Console.WriteLine("genericFilter: " + genericFilter.Property + " " + genericFilter.Operation + " " + genericFilter.Value);

            var genericFilterHelper = new GenericFilterHelper(new DomainObjectModelMock());
            var filterObject = genericFilterHelper.ToFilterObjects(new FilterCriteria[] { genericFilter }).Single();
            Console.WriteLine("filterObject.FilterType: " + filterObject.FilterType.FullName);
            var filterExpression = genericFilterHelper.ToExpression<C>((IEnumerable<PropertyFilter>)filterObject.Parameter);

            var filteredItems = items.AsQueryable().Where(filterExpression).ToList();
            Assert.AreEqual(expected, TestUtility.DumpSorted(filteredItems, item => item.Name ?? "<null>"), "Testing '" + operation + " " + value + "'.");
        }
Exemple #3
0
        private static void TestFilterByName(string expected, IEnumerable <C> items, string operation, object value)
        {
            var genericFilter = new FilterCriteria("Name", operation, value);

            Console.WriteLine("genericFilter: " + genericFilter.Property + " " + genericFilter.Operation + " " + genericFilter.Value);

            var genericFilterHelper = new GenericFilterHelper(new DomainObjectModelMock());
            var filterObject        = genericFilterHelper.ToFilterObjects(new FilterCriteria[] { genericFilter }).Single();

            Console.WriteLine("filterObject.FilterType: " + filterObject.FilterType.FullName);
            var filterExpression = genericFilterHelper.ToExpression <C>((IEnumerable <PropertyFilter>)filterObject.Parameter);

            var filteredItems = items.AsQueryable().Where(filterExpression).ToList();

            Assert.AreEqual(expected, TestUtility.DumpSorted(filteredItems, item => item.Name ?? "<null>"), "Testing '" + operation + " " + value + "'.");
        }
        private static string TestFilterByName(IEnumerable <C> items, string operation, object value)
        {
            var genericFilter = new FilterCriteria("Name", operation, value);

            Console.WriteLine("genericFilter: " + genericFilter.Property + " " + genericFilter.Operation + " " + genericFilter.Value);

            var genericFilterHelper = new GenericFilterHelper(new DomainObjectModelMock(), new DataStructureReadParametersStub());
            var filterObject        = genericFilterHelper.ToFilterObjects(typeof(C).FullName, new FilterCriteria[] { genericFilter }).Single();

            Console.WriteLine("filterObject.FilterType: " + filterObject.FilterType.FullName);
            var filterExpression = genericFilterHelper.ToExpression <C>((IEnumerable <PropertyFilter>)filterObject.Parameter);

            var filteredItems = items.AsQueryable().Where(filterExpression).ToList();

            return(TestUtility.DumpSorted(filteredItems, item => item.Name ?? "<null>"));
        }