public TestContext() : base(My.Config.ConnectionStrings.TestDatabase) { Database.SetInitializer(new CreateDatabaseIfNotExists <TestContext>()); // BE careful, this one also need to clear filter! QueryFilterManager.ClearQueryCache(this); }
public TestContext(DbConnection connection) : base(connection, true) { // BE careful, this one also need to clear filter! QueryFilterManager.ClearQueryCache(this); QueryDbSetFilterManager.GlobalFilters.Clear(); QueryDbSetFilterManager.GlobalInitializeFilterActions.Clear(); }
public TestContext() #endif { #if EF5 || EF6 Database.SetInitializer(new TestContextInitializer()); #elif EFCORE Database.EnsureCreated(); #endif #if EF6 // BE careful, this one also need to clear filter! QueryFilterManager.ClearQueryCache(this); #endif }
public TestContext(bool isEnabled, string fixResharper = null, bool?enableFilter1 = null, bool?enableFilter2 = null, bool?enableFilter3 = null, bool?enableFilter4 = null, bool?excludeClass = null, bool?excludeInterface = null, bool?excludeBaseClass = null, bool?excludeBaseInterface = null, bool?includeClass = null, bool?includeInterface = null, bool?includeBaseClass = null, bool?includeBaseInterface = null) #endif { #if EF5 || EF6 Database.SetInitializer(new CreateDatabaseIfNotExists <TestContext>()); #elif EFCORE Database.EnsureCreated(); #endif #if EFCORE // TODO: Remove this when cast issue will be fixed QueryFilterManager.GlobalFilters.Clear(); QueryFilterManager.GlobalInitializeFilterActions.Clear(); #endif #if EF6 // Clear query cache QueryFilterManager.ClearQueryCache(this); #endif if (enableFilter1 != null) { this.Filter <Inheritance_Interface_Entity>(QueryFilterHelper.Filter.Filter1, entities => entities.Where(x => x.ColumnInt != 1), isEnabled); if (!isEnabled && enableFilter1.Value) { this.Filter(QueryFilterHelper.Filter.Filter1).Enable(); } else if (isEnabled && !enableFilter1.Value) { this.Filter(QueryFilterHelper.Filter.Filter1).Disable(); } } if (enableFilter2 != null) { this.Filter <Inheritance_Interface_IEntity>(QueryFilterHelper.Filter.Filter2, entities => entities.Where(x => x.ColumnInt != 2), isEnabled); if (!isEnabled && enableFilter2.Value) { this.Filter(QueryFilterHelper.Filter.Filter2).Enable(); } else if (isEnabled && !enableFilter2.Value) { this.Filter(QueryFilterHelper.Filter.Filter2).Disable(); } } if (enableFilter3 != null) { this.Filter <Inheritance_Interface_Base>(QueryFilterHelper.Filter.Filter3, entities => entities.Where(x => x.ColumnInt != 3), isEnabled); if (!isEnabled && enableFilter3.Value) { this.Filter(QueryFilterHelper.Filter.Filter3).Enable(); } else if (isEnabled && !enableFilter3.Value) { this.Filter(QueryFilterHelper.Filter.Filter3).Disable(); } } if (enableFilter4 != null) { this.Filter <Inheritance_Interface_IBase>(QueryFilterHelper.Filter.Filter4, entities => entities.Where(x => x.ColumnInt != 4), isEnabled); if (!isEnabled && enableFilter4.Value) { this.Filter(QueryFilterHelper.Filter.Filter4).Enable(); } else if (isEnabled && !enableFilter4.Value) { this.Filter(QueryFilterHelper.Filter.Filter4).Disable(); } } if (excludeClass != null && excludeClass.Value) { this.Filter(QueryFilterHelper.Filter.Filter1).Disable(typeof(Inheritance_Interface_Entity)); } if (excludeInterface != null && excludeInterface.Value) { this.Filter(QueryFilterHelper.Filter.Filter2).Disable(typeof(Inheritance_Interface_IEntity)); } if (excludeBaseClass != null && excludeBaseClass.Value) { this.Filter(QueryFilterHelper.Filter.Filter3).Disable(typeof(Inheritance_Interface_Base)); } if (excludeBaseInterface != null && excludeBaseInterface.Value) { this.Filter(QueryFilterHelper.Filter.Filter4).Disable(typeof(Inheritance_Interface_IBase)); } if (includeClass != null && includeClass.Value) { this.Filter(QueryFilterHelper.Filter.Filter1).Enable(typeof(Inheritance_Interface_IEntity)); } if (includeInterface != null && includeInterface.Value) { this.Filter(QueryFilterHelper.Filter.Filter2).Enable(typeof(Inheritance_Interface_IEntity)); } if (includeBaseClass != null && includeBaseClass.Value) { this.Filter(QueryFilterHelper.Filter.Filter3).Enable(typeof(Inheritance_Interface_Base)); } if (includeBaseInterface != null && includeBaseInterface.Value) { this.Filter(QueryFilterHelper.Filter.Filter4).Enable(typeof(Inheritance_Interface_IBase)); } }
public TestContext(bool isEnabled, string fixResharper = null, bool?enableFilter1 = null, bool?enableFilter2 = null, bool?enableFilter3 = null, bool?enableFilter4 = null, bool?excludeClass = null, bool?excludeInterface = null, bool?excludeBaseClass = null, bool?excludeBaseInterface = null, bool?includeClass = null, bool?includeInterface = null, bool?includeBaseClass = null, bool?includeBaseInterface = null) : base(My.Config.ConnectionStrings.TestDatabase) { Database.SetInitializer(new CreateDatabaseIfNotExists <TestContext>()); // Clear query cache QueryFilterManager.ClearQueryCache(this); if (enableFilter1 != null) { this.Filter <Inheritance_Interface_Entity>(QueryFilterHelper.Filter.Filter1, entities => entities.Where(x => x.ColumnInt != 1), isEnabled); if (!isEnabled && enableFilter1.Value) { this.Filter(QueryFilterHelper.Filter.Filter1).Enable(); } else if (isEnabled && !enableFilter1.Value) { this.Filter(QueryFilterHelper.Filter.Filter1).Disable(); } } if (enableFilter2 != null) { this.Filter <Inheritance_Interface_IEntity>(QueryFilterHelper.Filter.Filter2, entities => entities.Where(x => x.ColumnInt != 2), isEnabled); if (!isEnabled && enableFilter2.Value) { this.Filter(QueryFilterHelper.Filter.Filter2).Enable(); } else if (isEnabled && !enableFilter2.Value) { this.Filter(QueryFilterHelper.Filter.Filter2).Disable(); } } if (enableFilter3 != null) { this.Filter <Inheritance_Interface_Base>(QueryFilterHelper.Filter.Filter3, entities => entities.Where(x => x.ColumnInt != 3), isEnabled); if (!isEnabled && enableFilter3.Value) { this.Filter(QueryFilterHelper.Filter.Filter3).Enable(); } else if (isEnabled && !enableFilter3.Value) { this.Filter(QueryFilterHelper.Filter.Filter3).Disable(); } } if (enableFilter4 != null) { this.Filter <Inheritance_Interface_IBase>(QueryFilterHelper.Filter.Filter4, entities => entities.Where(x => x.ColumnInt != 4), isEnabled); if (!isEnabled && enableFilter4.Value) { this.Filter(QueryFilterHelper.Filter.Filter4).Enable(); } else if (isEnabled && !enableFilter4.Value) { this.Filter(QueryFilterHelper.Filter.Filter4).Disable(); } } if (excludeClass != null && excludeClass.Value) { this.Filter(QueryFilterHelper.Filter.Filter1).Disable(typeof(Inheritance_Interface_Entity)); } if (excludeInterface != null && excludeInterface.Value) { this.Filter(QueryFilterHelper.Filter.Filter2).Disable(typeof(Inheritance_Interface_IEntity)); } if (excludeBaseClass != null && excludeBaseClass.Value) { this.Filter(QueryFilterHelper.Filter.Filter3).Disable(typeof(Inheritance_Interface_Base)); } if (excludeBaseInterface != null && excludeBaseInterface.Value) { this.Filter(QueryFilterHelper.Filter.Filter4).Disable(typeof(Inheritance_Interface_IBase)); } if (includeClass != null && includeClass.Value) { this.Filter(QueryFilterHelper.Filter.Filter1).Enable(typeof(Inheritance_Interface_IEntity)); } if (includeInterface != null && includeInterface.Value) { this.Filter(QueryFilterHelper.Filter.Filter2).Enable(typeof(Inheritance_Interface_IEntity)); } if (includeBaseClass != null && includeBaseClass.Value) { this.Filter(QueryFilterHelper.Filter.Filter3).Enable(typeof(Inheritance_Interface_Base)); } if (includeBaseInterface != null && includeBaseInterface.Value) { this.Filter(QueryFilterHelper.Filter.Filter4).Enable(typeof(Inheritance_Interface_IBase)); } }