Ejemplo n.º 1
0
        // 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();
        }
Ejemplo n.º 2
0
        public void DbContext()
        {
            var context = new CurrencyConverterDbContext(
                new DbContextOptionsBuilder <CurrencyConverterDbContext>()
                .UseInMemoryDatabase("currencydb").Options);

            Assert.True(context.ExchangeRates.Any());
        }
Ejemplo n.º 3
0
 public HomeController(CurrencyConverterDbContext context)
 {
     this._currencyDbContext = context;
 }