Пример #1
0
        public BackendTestBase(ITestOutputHelper output)
        {
            var startup  = new Startup(Config, AppSettings.SourceType.TestEnvironmentVariables);
            var services = new ServiceCollection();

            AddICurrentUserAccessor(services);

            startup.ConfigureServices(services);
            var provider = services.BuildServiceProvider();

            ContextInjector = provider.GetService <IDbContextInjector>();
            DatabaseInitializer.CleanUp(ContextInjector.WriteContext);

            var loggerConfiguration = new LoggerConfiguration()
                                      .WriteTo.TestOutput(output)
                                      .WriteTo.Console();

            var logFileName = _appSettingsForTests.LogDirectory;

            if (!string.IsNullOrEmpty(logFileName))
            {
                loggerConfiguration.WriteTo.File(logFileName, rollingInterval: RollingInterval.Day);
            }

            Log.Logger    = loggerConfiguration.CreateLogger();
            _scopeFactory = provider.GetService <IServiceScopeFactory>();
        }
Пример #2
0
 public void Dispose()
 {
     DatabaseInitializer.CleanUp(ContextInjector.WriteContext);
     ContextInjector?.Dispose();
 }