示例#1
0
        public ToDoLineDbContext CreateDbContext(string[] args)
        {
            Configuration ??= ToDoLineConfigurationProvider.GetConfiguration();

            return(new ToDoLineDbContext(new DbContextOptionsBuilder <ToDoLineDbContext>()
                                         .UseSqlServer(connectionString: Configuration.GetConnectionString("AppConnectionString")).Options));
        }
示例#2
0
        static ToDoLineTestEnv()
        {
            if (!Environment.Is64BitProcess)
            {
                throw new InvalidOperationException("Please run tests in x64 process");
            }

            AssemblyContainer.Current.Init();
            AssemblyContainer.Current.AddAppAssemblies(Assembly.Load("ToDoLine"));
            Environment.CurrentDirectory = Path.Combine(Environment.CurrentDirectory, "../../../../ToDoLine");
            AspNetCoreAppEnvironmentsProvider.Current.Configuration = ToDoLineConfigurationProvider.GetConfiguration();
            IHostEnvironment hostEnv = A.Fake <IHostEnvironment>();

            hostEnv.EnvironmentName = Environments.Development;
            Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", Environments.Development);
            hostEnv.ApplicationName = "ToDoLine";
            AspNetCoreAppEnvironmentsProvider.Current.HostingEnvironment = hostEnv;
            AspNetCoreAppEnvironmentsProvider.Current.Init();
            AspNetCoreAppEnvironmentsProvider.Current.Use();
        }