Exemple #1
0
        public void DatabaseExists_ReturnsTrue()
        {
            var optionsBuilder = new DbContextOptionsBuilder <YgoProAnalyticsDatabase>();

            optionsBuilder.UseSqlServer(YgoProAnalyticsDatabase.ConnectionString(_adminConfig.DBUser, _adminConfig.DBPassword));
            using (YgoProAnalyticsDatabase db = new YgoProAnalyticsDatabase(optionsBuilder.Options))
            {
                Assert.IsTrue((db.Database.GetService <IDatabaseCreator>() as RelationalDatabaseCreator).Exists());
            }
        }
Exemple #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
            services.AddMemoryCache();
            services.AddMediatR();
            services.AddSingleton <IAdminConfig, AdminConfig>();
            var adminConfig = services.BuildServiceProvider().GetService <IAdminConfig>();

            services.AddDbContext <YgoProAnalyticsDatabase>(
                options => options
                .UseSqlServer(YgoProAnalyticsDatabase.ConnectionString(adminConfig.DBUser, adminConfig.DBPassword))
                .ConfigureWarnings(warnings => warnings.Throw(RelationalEventId.QueryClientEvaluationWarning))
                );
            _addAutomapper(services);
            _addCors(services);
            _registerScopedServices(services);

            services.AddScheduler(builder =>
            {
                //builder.AddJobs(Assembly.GetExecutingAssembly());
                builder.AddJob <UpdatesJob>();
            });
        }