Example #1
0
        public void QueryDataSourceCommand_OutsideInterface()
        {
            var entityRepos  = new ImplicitQueryDataSourceCommandRepository();
            var genericRepos = NewRepos(entityRepos);

            var command = new QueryDataSourceCommandInfo
            {
                GenericFilter = new[] { new FilterCriteria {
                                            Property = "Name", Operation = "StartsWith", Value = "b"
                                        } },
                OrderByProperty = "Data",
                RecordsPerPage  = 3,
                PageNumber      = 2
            };

            Assert.AreEqual("b4, b5 / 5", Dump(genericRepos.ExecuteQueryDataSourceCommand(command)));

            command = new QueryDataSourceCommandInfo
            {
                GenericFilter = new[] { new FilterCriteria {
                                            Property = "Data", Operation = "Equal", Value = "xxx"
                                        } },
                OrderByProperty = "Name",
                RecordsPerPage  = 3,
                PageNumber      = 2
            };
            Assert.AreEqual(" / 0", Dump(genericRepos.ExecuteQueryDataSourceCommand(command)));
        }
Example #2
0
        public void QueryDataSourceCommand()
        {
            var entityRepos  = new ImplicitQueryDataSourceCommandRepository();
            var genericRepos = NewRepos(entityRepos);

            var command = new QueryDataSourceCommandInfo
            {
                GenericFilter = new[] { new FilterCriteria {
                                            Property = "Name", Operation = "StartsWith", Value = "b"
                                        } },
                OrderByProperty = "Name",
                RecordsPerPage  = 3,
                PageNumber      = 2
            };

            Assert.AreEqual("a1, b1, b2 / 10", Dump(NewRepos(new ExplicitQueryDataSourceCommandRepository()).ExecuteQueryDataSourceCommand(command)));
            Assert.AreEqual(0, entityRepos.DropQueryCount());
            Assert.AreEqual("b4, b5 / 5", Dump(genericRepos.ExecuteQueryDataSourceCommand(command)));
            Assert.AreEqual(2, entityRepos.DropQueryCount()); // Paging should result with two queries: selecting items and count.

            command = new QueryDataSourceCommandInfo();
            Assert.AreEqual("a1, b1, b2, b3, b4, b5 / 6", Dump(genericRepos.ExecuteQueryDataSourceCommand(command)));
            Assert.AreEqual(1, entityRepos.DropQueryCount()); // Without paging, there is no need for two queries.

            command = new QueryDataSourceCommandInfo {
                Filter = "1"
            };
            Assert.AreEqual("a1, b1 / 2", Dump(genericRepos.ExecuteQueryDataSourceCommand(command)));
            Assert.AreEqual(1, entityRepos.DropQueryCount()); // Without paging, there is no need for two queries.

            command = new QueryDataSourceCommandInfo {
                Filter = "1", GenericFilter = new[] { new FilterCriteria {
                                                          Property = "Name", Operation = "StartsWith", Value = "b"
                                                      } }
            };
            Assert.AreEqual("b1 / 1", Dump(genericRepos.ExecuteQueryDataSourceCommand(command)));
            Assert.AreEqual(1, entityRepos.DropQueryCount()); // Without paging, there is no need for two queries.

            command = new QueryDataSourceCommandInfo {
                Filter = "1", GenericFilter = new[] { new FilterCriteria {
                                                          Filter = "System.String", Value = "b"
                                                      } }
            };
            Assert.AreEqual("b1 / 1", Dump(genericRepos.ExecuteQueryDataSourceCommand(command)));
            Assert.AreEqual(1, entityRepos.DropQueryCount()); // Without paging, there is no need for two queries.

            command = new QueryDataSourceCommandInfo {
                Filter = "b", PageNumber = 2, RecordsPerPage = 2, OrderByProperty = "Name"
            };
            Assert.AreEqual("b3, b4 / 5", Dump(genericRepos.ExecuteQueryDataSourceCommand(command)));
            Assert.AreEqual(1, entityRepos.DropQueryCount()); // Enumerable filter will cause GenericRepository to materialize of the query, so it will be executed only once even though the paging is used.
        }
Example #3
0
        public void QueryDataSourceCommand_Null()
        {
            var entityRepos  = new ImplicitQueryDataSourceCommandRepository();
            var genericRepos = NewRepos(entityRepos);

            var command = new QueryDataSourceCommandInfo
            {
                GenericFilter = new[] { new FilterCriteria {
                                            Property = "Data", Operation = "Equal", Value = null
                                        } },
                OrderByProperty = "Name",
                RecordsPerPage  = 3,
                PageNumber      = 2
            };

            Assert.AreEqual("b3, b4, b5 / 6", Dump(genericRepos.ExecuteQueryDataSourceCommand(command)));
        }