コード例 #1
0
ファイル: TestBase.cs プロジェクト: BSG-Africa/EFCore
        protected void CleanPrimarySchema(ILifetimeScope requestContainer)
        {
            var alphaPrimaryRepo = requestContainer.GetService <IPrimaryRepository <Alpha> >();
            var betaPrimaryRepo  = requestContainer.GetService <IPrimaryRepository <Beta> >();
            var gammaPrimaryRepo = requestContainer.GetService <IPrimaryRepository <Gamma> >();
            var contextSession   = requestContainer.GetService <IDbContextSession <PrimaryContext> >();

            using (var transaction = contextSession.StartNewTransaction())
            {
                betaPrimaryRepo.Truncate(transaction);
                gammaPrimaryRepo.Truncate(transaction);
                alphaPrimaryRepo.TruncateWithForeignKeys(transaction);
                transaction.Commit();
            }
        }
コード例 #2
0
        public override void ConfigureContainerAfterBuild(ILifetimeScope container)
        {
            var testAssembly = Assembly.GetAssembly(typeof(TestContainerBootstrap));

            // Cache Timeouts
            var contextSettingsSetupService = container.GetService <IContextSettingsSetupService>();

            contextSettingsSetupService.BuildAndCacheAllSettings(testAssembly);

            // Cache Support Types
            var supportTypeSetupService = container.GetService <IContextSupportTypeSetupService>();

            supportTypeSetupService.BuildAndCacheAllContextSupportingTypes(testAssembly);

            // Cache Mappings
            var mappingSetupService = container.GetService <ITableMappingSetupService>();

            mappingSetupService.BuildAndCacheAllTableMappings(testAssembly);

            // WarmUp Contexts
            // var warmUpService = container.GetService<IContextWarmUpService>();
            // warmUpService.WarmUpAllContexts(testAssembly);
        }