Esempio n. 1
0
        public WarmupInMemory()
        {
            //Mock IHttpContextAccessor
            var mockHttpContextAccessor = new Mock <IHttpContextAccessor>();
            var serviceCollection       = new ServiceCollection();


            var configurationExpression = new MapperConfigurationExpression();

            AdminUiMapperConfiguration.RegisterMappings().ForEach(p => configurationExpression.AddProfile(p));
            var automapperConfig = new MapperConfiguration(configurationExpression);


            void Options(DbContextOptionsBuilder opt) => opt.UseInMemoryDatabase("JpTests").EnableSensitiveDataLogging();

            serviceCollection
            .ConfigureJpAdmin <AspNetUserTest>()
            .WithSqlServer(Options);

            serviceCollection.AddDbContext <EventStoreContext>(Options);
            serviceCollection.TryAddSingleton(automapperConfig.CreateMapper());
            serviceCollection.AddMediatR(typeof(WarmupInMemory));
            serviceCollection.TryAddSingleton(mockHttpContextAccessor.Object);

            Services = serviceCollection.BuildServiceProvider();
        }
        public static void ConfigureDefaultSettings(this IServiceCollection services)
        {
            var configurationExpression = new MapperConfigurationExpression();

            AdminUiMapperConfiguration.RegisterMappings().ForEach(p => configurationExpression.AddProfile(p));
            var automapperConfig = new MapperConfiguration(configurationExpression);

            services.TryAddSingleton(automapperConfig.CreateMapper());
            // Adding MediatR for Domain Events and Notifications
            services.AddMediatR(typeof(Startup));
        }
Esempio n. 3
0
        public ConfigurationWarmup()
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("app.json", optional: true, reloadOnChange: true);

            this.Configuration = builder.Build();

            var teste = Configuration.GetConnectionString("SqlServer");
            var mockHttpContextAccessor = new Mock <IHttpContextAccessor>();

            this.ServiceCollection = new ServiceCollection();

            var configurationExpression = new MapperConfigurationExpression();

            AdminUiMapperConfiguration.RegisterMappings().ForEach(p => configurationExpression.AddProfile(p));
            var automapperConfig = new MapperConfiguration(configurationExpression);

            ServiceCollection.TryAddSingleton(automapperConfig.CreateMapper());
            ServiceCollection.AddMediatR(typeof(WarmupInMemory));
            ServiceCollection.TryAddSingleton <IHttpContextAccessor>(mockHttpContextAccessor.Object);
        }
Esempio n. 4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            var database   = Configuration.GetValue <DatabaseType>("ApplicationSettings:DatabaseType");
            var connString = Configuration.GetConnectionString("SSOConnection");

            services
            .ConfigureJpAdmin <AspNetUser>()
            .AddDatabase(database, connString);


            var configurationExpression = new MapperConfigurationExpression();

            AdminUiMapperConfiguration.RegisterMappings().ForEach(p => configurationExpression.AddProfile(p));
            var automapperConfig = new MapperConfiguration(configurationExpression);

            services.TryAddSingleton(automapperConfig.CreateMapper());
            // Adding MediatR for Domain Events and Notifications
            services.AddMediatR(typeof(Startup));

            RegisterServices(services);
        }