public CommandAPIControllerTests()
 {
     optionsBuilder = new DbContextOptionsBuilder <CommandAPIContext>();
     optionsBuilder.UseInMemoryDatabase("UnitTestInMemDB");
     dbContext = new CommandAPIContext(optionsBuilder.Options);
     //create an instance of controller passing the dbContext created
     controller = new CommandAPIController(dbContext);
 }
예제 #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env,
                              CommandAPIContext context)
        {
            context.Database.Migrate();
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();//for our endpoints specified
                //within configure services method
                // endpoints.MapGet("/", async context =>
                // {
                //     await context.Response.WriteAsync("Hello World!");
                // });
            });
        }
예제 #3
0
 //dependency injected value
 // public CommandAPIController(ICommandAPIRepo repo)
 // {
 //     _repo = repo;
 // }
 public CommandAPIController(CommandAPIContext ctx)
 {
     _context = ctx;
 }
예제 #4
0
 public DbCommandAPIRepo(CommandAPIContext ctx)
 {
     _context = ctx;
 }