当前位置: 首页>>代码示例>>C#>>正文


C# TestContext.Filter方法代码示例

本文整理汇总了C#中TestContext.Filter方法的典型用法代码示例。如果您正苦于以下问题:C# TestContext.Filter方法的具体用法?C# TestContext.Filter怎么用?C# TestContext.Filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestContext的用法示例。


在下文中一共展示了TestContext.Filter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WithGlobalFilter_WithInstanceFilter_SingleFilter_GlobalFilterEnabled_InstanceFilterDisabled

        public void WithGlobalFilter_WithInstanceFilter_SingleFilter_GlobalFilterEnabled_InstanceFilterDisabled()
        {
            using (var ctx = new TestContext(false, enableFilter1: true))
            {
                ctx.Filter<Inheritance_Interface_Entity>(QueryFilterHelper.Filter.Filter5, entities => entities.Where(x => x.ColumnInt != 5));
                ctx.Filter(QueryFilterHelper.Filter.Filter5).Disable();

                Assert.AreEqual(45, ctx.Inheritance_Interface_Entities.AsNoFilter().Sum(x => x.ColumnInt));
            }
        }
开发者ID:emmatb1,项目名称:EntityFramework-Plus,代码行数:10,代码来源:SingleFilter_GlobalFilterEnabled_InstanceFilterDisabled.cs

示例2: WithInstanceFilter_SingleFilter_Enabled

        public void WithInstanceFilter_SingleFilter_Enabled()
        {
            using (var ctx = new TestContext())
            {
                ctx.Filter<Inheritance_Interface_Entity>(QueryFilterHelper.Filter.Filter1, entities => entities.Where(x => x.ColumnInt != 1), false);
                ctx.Filter(QueryFilterHelper.Filter.Filter1).Enable();

                Assert.AreEqual(45, ctx.Inheritance_Interface_Entities.AsNoFilter().Sum(x => x.ColumnInt));
            }
        }
开发者ID:DebugOfTheRoad,项目名称:EntityFramework-Plus,代码行数:10,代码来源:SingleFilter_Enabled.cs

示例3: WithGlobalFilter_WithInstanceFilter_SingleFilter_Disable

        public void WithGlobalFilter_WithInstanceFilter_SingleFilter_Disable()
        {
            TestContext.DeleteAll(x => x.Inheritance_Interface_Entities);
            TestContext.Insert(x => x.Inheritance_Interface_Entities, 10);

            using (var ctx = new TestContext(true, enableFilter1: false))
            {
                ctx.Filter<Inheritance_Interface_Entity>(QueryFilterHelper.Filter.Filter5, entities => entities.Where(x => x.ColumnInt != 5));
                ctx.Filter(QueryFilterHelper.Filter.Filter5).Disable();

                Assert.AreEqual(45, ctx.Inheritance_Interface_Entities.Sum(x => x.ColumnInt));
            }
        }
开发者ID:emmatb1,项目名称:EntityFramework-Plus,代码行数:13,代码来源:SingleFilter_Disable.cs

示例4: WithInstanceFilter_SingleFilter_Disabled

        public void WithInstanceFilter_SingleFilter_Disabled()
        {
            TestContext.DeleteAll(x => x.Inheritance_Interface_Entities);
            TestContext.Insert(x => x.Inheritance_Interface_Entities, 10);

            using (var ctx = new TestContext())
            {
                ctx.Filter<Inheritance_Interface_Entity>(QueryFilterHelper.Filter.Filter1, entities => entities.Where(x => x.ColumnInt != 1));
                ctx.Filter(QueryFilterHelper.Filter.Filter1).Disable();

                Assert.AreEqual(45, ctx.Inheritance_Interface_Entities.AsNoFilter().Sum(x => x.ColumnInt));
            }
        }
开发者ID:DebugOfTheRoad,项目名称:EntityFramework-Plus,代码行数:13,代码来源:SingleFilter_Disabled.cs

示例5: WithGlobalFilter_WithInstanceFilter_ManyFilter_GlobalFilterDisabled_InstanceFilterDisabled

        public void WithGlobalFilter_WithInstanceFilter_ManyFilter_GlobalFilterDisabled_InstanceFilterDisabled()
        {
            using (var ctx = new TestContext(true, enableFilter1: false, enableFilter2: false, enableFilter3: false, enableFilter4: false))
            {
                ctx.Filter<Inheritance_Interface_Entity>(QueryFilterHelper.Filter.Filter5, entities => entities.Where(x => x.ColumnInt != 5));
                ctx.Filter<Inheritance_Interface_IEntity>(QueryFilterHelper.Filter.Filter6, entities => entities.Where(x => x.ColumnInt != 6));
                ctx.Filter<Inheritance_Interface_Base>(QueryFilterHelper.Filter.Filter7, entities => entities.Where(x => x.ColumnInt != 7));
                ctx.Filter<Inheritance_Interface_IBase>(QueryFilterHelper.Filter.Filter8, entities => entities.Where(x => x.ColumnInt != 8));

                ctx.Filter(QueryFilterHelper.Filter.Filter5).Disable();
                ctx.Filter(QueryFilterHelper.Filter.Filter6).Disable();
                ctx.Filter(QueryFilterHelper.Filter.Filter7).Disable();
                ctx.Filter(QueryFilterHelper.Filter.Filter8).Disable();

                Assert.AreEqual(9, ctx.Inheritance_Interface_Entities.Filter(
                    QueryFilterHelper.Filter.Filter1,
                    QueryFilterHelper.Filter.Filter2,
                    QueryFilterHelper.Filter.Filter3,
                    QueryFilterHelper.Filter.Filter4,
                    QueryFilterHelper.Filter.Filter5,
                    QueryFilterHelper.Filter.Filter6,
                    QueryFilterHelper.Filter.Filter7,
                    QueryFilterHelper.Filter.Filter8).Sum(x => x.ColumnInt));
            }
        }
开发者ID:emmatb1,项目名称:EntityFramework-Plus,代码行数:25,代码来源:ManyFilter_GlobalFilterDisabled_InstanceFilterDisabled.cs

示例6: WithGlobalFilter_WithInstanceFilter_ManyFilter_GlobalFilterEnabled_InstanceFilterEnabled

        public void WithGlobalFilter_WithInstanceFilter_ManyFilter_GlobalFilterEnabled_InstanceFilterEnabled()
        {
            TestContext.DeleteAll(x => x.Inheritance_Interface_Entities);
            TestContext.Insert(x => x.Inheritance_Interface_Entities, 10);

            using (var ctx = new TestContext(false, enableFilter1: true, enableFilter2: true, enableFilter3: true, enableFilter4: true))
            {
                ctx.Filter<Inheritance_Interface_Entity>(QueryFilterHelper.Filter.Filter5, entities => entities.Where(x => x.ColumnInt != 5), false);
                ctx.Filter<Inheritance_Interface_IEntity>(QueryFilterHelper.Filter.Filter6, entities => entities.Where(x => x.ColumnInt != 6), false);
                ctx.Filter<Inheritance_Interface_Base>(QueryFilterHelper.Filter.Filter7, entities => entities.Where(x => x.ColumnInt != 7), false);
                ctx.Filter<Inheritance_Interface_IBase>(QueryFilterHelper.Filter.Filter8, entities => entities.Where(x => x.ColumnInt != 8), false);

                ctx.Filter(QueryFilterHelper.Filter.Filter5).Enable();
                ctx.Filter(QueryFilterHelper.Filter.Filter6).Enable();
                ctx.Filter(QueryFilterHelper.Filter.Filter7).Enable();
                ctx.Filter(QueryFilterHelper.Filter.Filter8).Enable();

                Assert.AreEqual(9, ctx.Inheritance_Interface_Entities.Filter(
                    QueryFilterHelper.Filter.Filter1,
                    QueryFilterHelper.Filter.Filter2,
                    QueryFilterHelper.Filter.Filter3,
                    QueryFilterHelper.Filter.Filter4,
                    QueryFilterHelper.Filter.Filter5,
                    QueryFilterHelper.Filter.Filter6,
                    QueryFilterHelper.Filter.Filter7,
                    QueryFilterHelper.Filter.Filter8).Sum(x => x.ColumnInt));
            }
        }
开发者ID:DebugOfTheRoad,项目名称:EntityFramework-Plus,代码行数:28,代码来源:ManyFilter_GlobalFilterEnabled_InstanceFilterEnabled.cs

示例7: WithInstanceFilter_ManyFilter

        public void WithInstanceFilter_ManyFilter()
        {
            TestContext.DeleteAll(x => x.Inheritance_Interface_Entities);
            TestContext.Insert(x => x.Inheritance_Interface_Entities, 10);

            using (var ctx = new TestContext())
            {
                ctx.Filter<Inheritance_Interface_Entity>(QueryFilterHelper.Filter.Filter1, entities => entities.Where(x => x.ColumnInt != 1));
                ctx.Filter<Inheritance_Interface_IEntity>(QueryFilterHelper.Filter.Filter2, entities => entities.Where(x => x.ColumnInt != 2));
                ctx.Filter<Inheritance_Interface_Base>(QueryFilterHelper.Filter.Filter3, entities => entities.Where(x => x.ColumnInt != 3));
                ctx.Filter<Inheritance_Interface_IBase>(QueryFilterHelper.Filter.Filter4, entities => entities.Where(x => x.ColumnInt != 4));

                Assert.AreEqual(35, ctx.Inheritance_Interface_Entities.Sum(x => x.ColumnInt));
            }
        }
开发者ID:emmatb1,项目名称:EntityFramework-Plus,代码行数:15,代码来源:ManyFilter.cs

示例8: WithInstanceFilter_ManyFilter_Enable

        public void WithInstanceFilter_ManyFilter_Enable()
        {
            using (var ctx = new TestContext())
            {
                ctx.Filter<Inheritance_Interface_Entity>(QueryFilterHelper.Filter.Filter1, entities => entities.Where(x => x.ColumnInt != 1), false);
                ctx.Filter<Inheritance_Interface_IEntity>(QueryFilterHelper.Filter.Filter2, entities => entities.Where(x => x.ColumnInt != 2), false);
                ctx.Filter<Inheritance_Interface_Base>(QueryFilterHelper.Filter.Filter3, entities => entities.Where(x => x.ColumnInt != 3), false);
                ctx.Filter<Inheritance_Interface_IBase>(QueryFilterHelper.Filter.Filter4, entities => entities.Where(x => x.ColumnInt != 4), false);

                ctx.Filter(QueryFilterHelper.Filter.Filter1).Enable();
                ctx.Filter(QueryFilterHelper.Filter.Filter2).Enable();
                ctx.Filter(QueryFilterHelper.Filter.Filter3).Enable();
                ctx.Filter(QueryFilterHelper.Filter.Filter4).Enable();

                Assert.AreEqual(35, ctx.Inheritance_Interface_Entities.Sum(x => x.ColumnInt));
            }
        }
开发者ID:emmatb1,项目名称:EntityFramework-Plus,代码行数:17,代码来源:ManyFilter_Enable.cs


注:本文中的TestContext.Filter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。