public SeedFixture() { this.context = new GetPdfOnlineDbContext("Data Source=UnitTests.db"); context.Database.Migrate(); context.Seed(); context.SaveChanges(); this.repository = new ConvertLogRepository(context); }
public void DatabaseCreateTest() { File.Delete("test.db"); GetPdfOnlineDbContext context = new GetPdfOnlineDbContext("test.db"); //context.Database.EnsureCreated(); context.Database.Migrate(); context.Seed(); context.SaveChanges(); Assert.NotNull(context); ConvertLogRepository repository = new ConvertLogRepository(context); var log = repository.GetConvertLog(new Guid("CFF29BD8-C0AB-4AC0-B932-06680205E7D2")); Assert.Equal("Document", log.FileCategoryCode); }
public ConvertLogRepository(GetPdfOnlineDbContext dbContext) { this.context = dbContext; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IApplicationLifetime life, CacheDbContext cacheDbContext, GetPdfOnlineDbContext getPdfOnlineDbContext) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); var locOptions = app.ApplicationServices.GetService <IOptions <RequestLocalizationOptions> >(); app.UseRequestLocalization(locOptions.Value); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { HotModuleReplacement = true }); } else { app.UseExceptionHandler("/Home/Error"); } app.UseCors("AllowSpecificOrigin"); app.UseDefaultFiles(); app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{culture?}/{controller=Home}/{action=Index}/{id?}"); routes.MapSpaFallbackRoute( name: "spa-fallback", defaults: new { controller = "Home", action = "Index" }); }); cacheDbContext.Database.EnsureCreated(); getPdfOnlineDbContext.Database.Migrate(); // Enable middleware to serve generated Swagger as a JSON endpoint. app.UseSwagger(c => { c.RouteTemplate = "api/{documentName}/swagger.json"; }); // Enable middleware to serve swagger-ui (HTML, JS, CSS etc.), specifying the Swagger JSON endpoint. /*app.UseSwaggerUI(c => * { * c.SwaggerEndpoint("/api/v1/swagger.json", "GetPDF.online REST API v1"); * c.RoutePrefix = "swagger"; * });*/ life.ApplicationStarted.Register(() => { var cacheRepository = app.ApplicationServices.GetService <ICacheRepository>(); var options = this.Configuration.Get <UserSettingsOptions>(); this.CreateAndOpenHosts(options.Host.TcpPort, options.LibreOffice.UseCustomUnoPath, options.LibreOffice.CustomUnoPath, options.Data.ConnectionString); Task task = DeleteExpiredDataScheduler.Start(cacheRepository); task.Wait(); }); }