// 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, LearnAspDotNetCoreContext context) { loggerFactory.AddConsole(); loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); //app.UseFileServer(enableDirectoryBrowsing:env.IsDevelopment()); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); DbInitializer.Initialize(context); }
public void TestQuestions_Day_1() { var dbContextTest = new LearnAspDotNetCoreContext(); var testObjectMock = MockingTools.GetMockDbSet <Test>(this.GenerateTestObjects()); dbContextTest.Test = testObjectMock; QuestionController questionController = new QuestionController(dbContextTest); var result = questionController.Questions_Day_1(); var viewResult = Assert.IsType <ViewResult>(result); Console.WriteLine("Checking View Name - " + viewResult.ViewName); Console.WriteLine(viewResult.ViewName); var model = Assert.IsAssignableFrom <TestComposite>( viewResult.ViewData.Model); Assert.Equal(2, model.tests.Count()); Assert.Equal("Test 1", model.tests[0].Title); }
public QuestionController(LearnAspDotNetCoreContext context, ILoggerFactory logger, IScramble scramble) { _context = context; _logger = logger.CreateLogger("TodoApi.Controllers.TodoController"); _scramble = scramble; }