public override void Initialize() { //NOTE The DataTypesResolver is only necessary because we are using the Save method in the MediaService //this ensures its reset PluginManager.Current = new PluginManager(); //for testing, we'll specify which assemblies are scanned for the PluginTypeResolver PluginManager.Current.AssembliesToScan = new[] { typeof(IDataType).Assembly, typeof(tinyMCE3dataType).Assembly }; DataTypesResolver.Current = new DataTypesResolver( () => PluginManager.Current.ResolveDataTypes()); base.Initialize(); //we need to use our own custom IDatabaseFactory for the DatabaseContext because we MUST ensure that //a Database instance is created per thread, whereas the default implementation which will work in an HttpContext //threading environment, or a single apartment threading environment will not work for this test because //it is multi-threaded. _dbFactory = new PerThreadDatabaseFactory(); //overwrite the local object ApplicationContext.DatabaseContext = new DatabaseContext(_dbFactory); //here we are going to override the ServiceContext because normally with our test cases we use a //global Database object but this is NOT how it should work in the web world or in any multi threaded scenario. //we need a new Database object for each thread. _uowProvider = new PerThreadPetaPocoUnitOfWorkProvider(_dbFactory); ApplicationContext.Services = new ServiceContext(_uowProvider, new FileUnitOfWorkProvider(), new PublishingStrategy()); CreateTestData(); }
public override void Initialize() { base.Initialize(); //we need to use our own custom IDatabaseFactory for the DatabaseContext because we MUST ensure that //a Database instance is created per thread, whereas the default implementation which will work in an HttpContext //threading environment, or a single apartment threading environment will not work for this test because //it is multi-threaded. _dbFactory = new PerThreadDatabaseFactory(Logger); //overwrite the local object ApplicationContext.DatabaseContext = new DatabaseContext(_dbFactory, Logger, new SqlCeSyntaxProvider(), "System.Data.SqlServerCe.4.0"); //disable cache var cacheHelper = CacheHelper.CreateDisabledCacheHelper(); //here we are going to override the ServiceContext because normally with our test cases we use a //global Database object but this is NOT how it should work in the web world or in any multi threaded scenario. //we need a new Database object for each thread. var repositoryFactory = new RepositoryFactory(cacheHelper, Logger, SqlSyntax, SettingsForTests.GenerateMockSettings()); _uowProvider = new PerThreadPetaPocoUnitOfWorkProvider(_dbFactory); var evtMsgs = new TransientMessagesFactory(); ApplicationContext.Services = new ServiceContext( repositoryFactory, _uowProvider, new FileUnitOfWorkProvider(), new PublishingStrategy(evtMsgs, Logger), cacheHelper, Logger, evtMsgs); CreateTestData(); }
public override void Initialize() { base.Initialize(); //we need to use our own custom IDatabaseFactory for the DatabaseContext because we MUST ensure that //a Database instance is created per thread, whereas the default implementation which will work in an HttpContext //threading environment, or a single apartment threading environment will not work for this test because //it is multi-threaded. _dbFactory = new PerThreadDatabaseFactory(); //overwrite the local object ApplicationContext.DatabaseContext = new DatabaseContext(_dbFactory); //here we are going to override the ServiceContext because normally with our test cases we use a //global Database object but this is NOT how it should work in the web world or in any multi threaded scenario. //we need a new Database object for each thread. _uowProvider = new PerThreadPetaPocoUnitOfWorkProvider(_dbFactory); ApplicationContext.Services = new ServiceContext(_uowProvider, new FileUnitOfWorkProvider(), new PublishingStrategy()); CreateTestData(); }