// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, finaltodoContext context)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }



            app.UseSwagger();

            // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
            // specifying the Swagger JSON endpoint.
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
            });


            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseMvc();
            context.Database.Migrate();
        }
 public void createdata(DbContextOptions <finaltodoContext> _context)
 {
     using (var g_keep_context = new finaltodoContext(_context))
     {
         var notes = new List <Todo>()
         {
             new Todo()
             {
                 id      = 1,
                 pinned  = true,
                 heading = "header1",
                 text    = "write text here",
                 label   = new List <labels>
                 {
                     new labels
                     {
                         labelname = "label1"
                     }
                 },
                 checklist = new List <checklist>
                 {
                     new checklist
                     {
                         checkname = "checklist1"
                     }
                 }
             },
             new Todo()
             {
                 id      = 2,
                 pinned  = true,
                 heading = "header2",
                 text    = "write text here",
                 label   = new List <labels>
                 {
                     new labels
                     {
                         labelname = "label2"
                     }
                 },
                 checklist = new List <checklist>
                 {
                     new checklist
                     {
                         checkname = "checklist1"
                     }
                 }
             }
         };
         g_keep_context.Todo.AddRange(notes);
         var CountOfEntitiesBeingTracked = g_keep_context.ChangeTracker.Entries().Count();
         g_keep_context.SaveChanges();
     }
 }
        public TodoesController GetController()
        {
            var optionsBuilder = new DbContextOptionsBuilder <finaltodoContext>();

            optionsBuilder.UseInMemoryDatabase(Guid.NewGuid().ToString());


            _context    = new finaltodoContext(optionsBuilder.Options);
            _controller = new TodoesController(_context);
            createdata(optionsBuilder.Options);
            return(new TodoesController(_context));
        }
        public IntegrationTest()
        {
            //var host = new TestServer(new WebHostBuilder()
            //    .UseEnvironment("Testing")
            //    .UseStartup<Startup>());
            var host = new TestServer(new WebHostBuilder().UseEnvironment("Testing")
                                      .UseStartup <Startup>());

            _context = host.Host.Services.GetService(typeof(finaltodoContext)) as finaltodoContext;
            client   = host.CreateClient();
            _context.Todo.Add(TestNote1);
            _context.Todo.Add(TestNote2);

            _context.SaveChanges();
        }