// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, CurrencyConverterDbContext context) { if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); var rates = new ExchangeManager().GetExchangeRates(); var timePoints = rates.Select(x => x.Time).Distinct(); context.AddRange(rates); context.AddRange(timePoints.Select(x => new ExchangeRate() { Time = x.Date, Currency = "EUR", Rate = 1 })); context.SaveChanges(); }
public void DbContext() { var context = new CurrencyConverterDbContext( new DbContextOptionsBuilder <CurrencyConverterDbContext>() .UseInMemoryDatabase("currencydb").Options); Assert.True(context.ExchangeRates.Any()); }
public HomeController(CurrencyConverterDbContext context) { this._currencyDbContext = context; }