public async void Test1() { //var configuration = new ConfigurationBuilder() // .SetBasePath(Directory.GetCurrentDirectory() + "\\..\\..\\..\\..") // .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) // .Build(); var options = new DbContextOptionsBuilder <JunSpaContext>() .UseSqlServer("Server=tcp:junspadbserver.database.windows.net,1433;Initial Catalog=JunSpaDb;Persist Security Info=False;User ID=jun;Password=Qwer1234;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;") .Options; using (var context = new JunSpaContext(options)) { var vc = new BoardsController(context); var okObjResult = (OkObjectResult)await vc.List(); var boards = (List <Board>)okObjResult.Value; Assert.Equal(boards.Count, 3); } }
public CommentsController(JunSpaContext context) { _context = context; }
// 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, JunSpaContext context) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); //app.UseApplicationInsightsRequestTelemetry(); //app.UseApplicationInsightsExceptionTelemetry(); app.UseCors("AllowAll"); DbInitializer.Initialize(context); // Enable middleware to serve generated Swagger as a JSON endpoint. app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS etc.), specifying the Swagger JSON endpoint. app.UseSwaggerUi(); // If your client secret is base64 encoded, then uncomment these two lines //var keyAsBase64 = Configuration["auth0:clientSecret"].Replace('_', '/').Replace('-', '+'); //var secret = Convert.FromBase64String(keyAsBase64); // If your client secret is base64 encoded, then comment out this line, and rather use 2 lines above var secret = Encoding.UTF8.GetBytes(Configuration["auth0:clientSecret"]); var options = new JwtBearerOptions { TokenValidationParameters = { ValidIssuer = $"https://{Configuration["auth0:domain"]}/", ValidAudience = Configuration["auth0:clientId"], IssuerSigningKey = new SymmetricSecurityKey(secret) } }; app.UseJwtBearerAuthentication(options); // It should be after JwtBearerAuth app.UseMvc(); }
public TestsController(JunSpaContext context) { _context = context; }
public BoardsController(JunSpaContext context) { _context = context; }