Exemplo n.º 1
0
        public void GetInMemoryDbValuesIsTrue()
        {
            Environment.SetEnvironmentVariable(EnvironmentVariables.InMemoryDb, bool.TrueString.ToLower());
            var result = EnvironmentVariables.GetInMemoryDbValue();

            result.Should().BeTrue();
        }
        public void GetInMemoryDbValuesIsTrue()
        {
            Environment.SetEnvironmentVariable(EnvironmentVariables.InMemoryDb, "true");
            var result = EnvironmentVariables.GetInMemoryDbValue();

            result.Should().BeTrue();
        }
        public void GetInMemoryDbValueIsFalse()
        {
            Environment.SetEnvironmentVariable(EnvironmentVariables.InMemoryDb, "false");
            var result = EnvironmentVariables.GetInMemoryDbValue();

            result.Should().BeFalse();
        }
        public static void Configure(IServiceCollection services)
        {
            var serviceProvider   = services.BuildServiceProvider();
            var connectionStrings = serviceProvider.GetService <IOptions <ConnectionStringsConfiguration> >();

            services.AddDbContext <VideoGameContext>(options =>
            {
                if (EnvironmentVariables.GetInMemoryDbValue())
                {
                    options.UseInMemoryDatabase("Onion.Pattern");
                }
                else
                {
                    options.UseSqlServer(connectionStrings.Value.VideoGamesConnection);
                }
            });
            services.AddScoped <DbContext>(provider => provider.GetService <VideoGameContext>());

            ConfigureNonAsync(services);
            ConfigureAsync(services);
        }
Exemplo n.º 5
0
        /// <summary>
        /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        /// </summary>
        /// <param name="application"></param>
        /// <param name="loggerFactory"></param>
        /// <param name="apiVersionDescriptionProvider"></param>
        public void Configure(IApplicationBuilder application,
                              ILoggerFactory loggerFactory,
                              IApiVersionDescriptionProvider apiVersionDescriptionProvider)
        {
            if (environment.IsEnvironment(EnvironmentTypes.Local))
            {
                application.UseDeveloperExceptionPage();

                application.UseStaticFiles();

                SwaggerStartupConfiguration.Configure(application, apiVersionDescriptionProvider);
            }

            CorrelationMiddleware.Configure(application);

            if (EnvironmentVariables.GetInMemoryDbValue())
            {
                var context = application.ApplicationServices.GetService <DataContext>();
                //MockDataInjector.Inject(context);
            }
            application.UseMvc();
        }