예제 #1
0
        public LoginServiceTest()
        {
            var dbOptions = new DbContextOptionsBuilder <MvcTodoContext>().UseInMemoryDatabase("test").Options;
            var dbContext = new MvcTodoContext(dbOptions);
            var repo      = new MvcTodo.Repo.UserRepo(dbContext);

            dbContext.Users.RemoveRange(dbContext.Users);
            dbContext.Users.Add(new User()
            {
                Username = "******",
                Password = PasswordUtils.Hashpassword("test")
            });
            dbContext.SaveChanges();
            this.service = new MvcTodo.Services.AuthService(repo);
        }
예제 #2
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new MvcTodoContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <MvcTodoContext> >()))
            {
                // Look for any movies.
                if (context.TodoList.Any())
                {
                    return;   // DB has been seeded
                }

                context.TodoList.AddRange(
                    new TodoItem
                {
                    Title  = "When Harry Met Sally",
                    IsDone = true
                },

                    new TodoItem
                {
                    Title  = "Ghostbusters ",
                    IsDone = false
                },

                    new TodoItem
                {
                    Title  = "Ghostbusters 2",
                    IsDone = true
                },

                    new TodoItem
                {
                    Title  = "Rio Bravo",
                    IsDone = false
                }
                    );
                context.SaveChanges();
            }
        }
예제 #3
0
 public TodoItemsController(MvcTodoContext context)
 {
     _context = context;
 }
예제 #4
0
 public UserRepo(MvcTodoContext context)
 {
     this.context = context;
 }