Esempio n. 1
0
        public void WithGlobalManagerFilter_ManyFilter_Enable()
        {
            TestContext.DeleteAll(x => x.Inheritance_Interface_Entities);
            TestContext.Insert(x => x.Inheritance_Interface_Entities, 10);

            using (var ctx = new TestContext())
            {
                QueryFilterHelper.CreateGlobalManagerDbSetFilter(false, enableFilter1: true, enableFilter2: true, enableFilter3: true, enableFilter4: true);
                QueryDbSetFilterManager.InitilizeGlobalFilter(ctx);

                Assert.AreEqual(35, ctx.Inheritance_Interface_Entities.Sum(x => x.ColumnInt));

                QueryFilterHelper.ClearGlobalManagerDbSetFilter();
            }
        }
Esempio n. 2
0
        public void WithGlobalManagerFilter_SingleFilter_Disabled()
        {
            TestContext.DeleteAll(x => x.Inheritance_Interface_Entities);
            TestContext.Insert(x => x.Inheritance_Interface_Entities, 10);

            using (var ctx = new TestContext())
            {
                QueryFilterHelper.CreateGlobalManagerDbSetFilter(true, enableFilter1: false);
                QueryDbSetFilterManager.InitilizeGlobalFilter(ctx);

                Assert.AreEqual(44, ctx.Inheritance_Interface_Entities.DbSetFilter(
                                    QueryFilterHelper.Filter.Filter1,
                                    QueryFilterHelper.Filter.Filter2,
                                    QueryFilterHelper.Filter.Filter3,
                                    QueryFilterHelper.Filter.Filter4).Sum(x => x.ColumnInt));

                QueryFilterHelper.ClearGlobalManagerDbSetFilter();
            }
        }