public void Initialize()
        {
            _context = new JoggingDbContext(new DbContextOptionsBuilder <JoggingDbContext>().UseInMemoryDatabase().Options);
            _context.Database.EnsureDeleted();//make sure we don't share state between tests

            _context.Users.Add(_regularUser1 = new User()
            {
                Id = 123, Email = "[email protected]", FirstName = "Joe", LastName = "User", Role = UserRole.User
            });
            _context.Users.Add(_regularUser2 = new User()
            {
                Id = 234, Email = "[email protected]", FirstName = "Moe", LastName = "User", Role = UserRole.User
            });
            _context.Users.Add(_adminUser = new User()
            {
                Id = 345, Email = "*****@*****.**", FirstName = "Le", LastName = "Admin", Role = UserRole.Admin
            });
            _context.SaveChanges();

            _userService = new DummyUserService(_regularUser1);
            _controller  = new EntriesController(_context, _userService);
        }
Exemple #2
0
 public UsersController(ILoginService userService, JoggingDbContext context, IEmailNotifier emailNotifier)
 {
     _loginService  = userService;
     _context       = context;
     _emailNotifier = emailNotifier;
 }
Exemple #3
0
 public EntriesController(JoggingDbContext context, ILoginService userService)
 {
     _context     = context;
     _userService = userService;
 }
 public AuthenticationMiddleware(RequestDelegate next, JoggingDbContext context)
 {
     _next    = next;
     _context = context;
 }
Exemple #5
0
 public LoginService(IHttpContextAccessor httpContextAccessor, JoggingDbContext context)
 {
     _httpContextAccessor = httpContextAccessor;
     _context             = context;
 }
Exemple #6
0
        // 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, JoggingDbContext ctx)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions {
                    HotModuleReplacement = true
                });

                //TestDatanitializer.Initialize(ctx);
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseCookieAuthentication();

            app.UseMiddleware <AuthenticationMiddleware>();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");

                routes.MapSpaFallbackRoute(
                    name: "spa-fallback",
                    defaults: new { controller = "Home", action = "Index" });
            });
        }