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)); } }
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)); } }
public void WithInstanceFilter_SingleFilter_Disable() { 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.Sum(x => x.ColumnInt)); } }
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.SetFiltered <Inheritance_Interface_Entity>().Sum(x => x.ColumnInt)); } }
public void ManyFilter_NoParameter() { 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_Entity>(QueryFilterHelper.Filter.Filter2, entities => entities.Where(x => x.ColumnInt != 3)); Assert.AreEqual(41, ctx.Inheritance_Interface_Entities.Sum(x => x.ColumnInt)); } }
public void WithGlobalFilter_WithInstanceFilter_ManyFilter_GlobalFilterEnabled_InstanceFilterDisabled() { 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)); 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)); } }
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)); } }
public void ManyFilter_ManyParameter() { TestContext.DeleteAll(x => x.Inheritance_Interface_Entities); TestContext.Insert(x => x.Inheritance_Interface_Entities, 10); using (var ctx = new TestContext()) { int columnInt1 = 1; int columnInt2 = 2; int columnInt3 = 3; int columnInt4 = 4; ctx.Filter <Inheritance_Interface_Entity>(QueryFilterHelper.Filter.Filter1, entities => entities.Where(x => x.ColumnInt != columnInt1 && x.ColumnInt != columnInt2)); ctx.Filter <Inheritance_Interface_Entity>(QueryFilterHelper.Filter.Filter2, entities => entities.Where(x => x.ColumnInt != columnInt3 && x.ColumnInt != columnInt4)); Assert.AreEqual(35, ctx.Inheritance_Interface_Entities.Sum(x => x.ColumnInt)); } }
public void WithGlobalFilter_WithInstanceFilter_SingleFilter_GlobalFilterDisabled_InstanceFilterEnabled() { 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), false); ctx.Filter(QueryFilterHelper.Filter.Filter5).Enable(); Assert.AreEqual(39, 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)); } }
public void SingleFilter_SingleParameter() { TestContext.DeleteAll(x => x.Inheritance_Interface_Entities); TestContext.Insert(x => x.Inheritance_Interface_Entities, 10); using (var ctx = new TestContext()) { int columnInt1 = 1; ctx.Filter <Inheritance_Interface_Entity>(QueryFilterHelper.Filter.Filter1, entities => entities.Where(x => x.ColumnInt != columnInt1)); Assert.AreEqual(44, ctx.Inheritance_Interface_Entities.Sum(x => x.ColumnInt)); } }
public void WithGlobalFilter_WithInstanceFilter_ManyFilter_GlobalFilterDisabled_InstanceFilterEnabled() { 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), 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(45, ctx.Inheritance_Interface_Entities.AsNoFilter().Sum(x => x.ColumnInt)); } }
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)); } }
public void WithInstanceFilter_ManyFilter_Exclude() { 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), 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(); ctx.Filter(QueryFilterHelper.Filter.Filter2).Disable(typeof(Inheritance_Interface_IEntity)); ctx.Filter(QueryFilterHelper.Filter.Filter3).Disable(typeof(Inheritance_Interface_Base)); ctx.Filter(QueryFilterHelper.Filter.Filter4).Disable(typeof(Inheritance_Interface_IBase)); Assert.AreEqual(44, ctx.SetFiltered <Inheritance_Interface_Entity>().Sum(x => x.ColumnInt)); } }