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);
 }
Exemplo n.º 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!");
                // });
            });
        }
Exemplo n.º 3
0
 //dependency injected value
 // public CommandAPIController(ICommandAPIRepo repo)
 // {
 //     _repo = repo;
 // }
 public CommandAPIController(CommandAPIContext ctx)
 {
     _context = ctx;
 }
Exemplo n.º 4
0
 public DbCommandAPIRepo(CommandAPIContext ctx)
 {
     _context = ctx;
 }