public static EFTodoItemsContext GetMockedContext()
        {
            var options = new DbContextOptionsBuilder <EFTodoItemsContext>()
                          .UseInMemoryDatabase("TodoItems")
                          .Options;

            var dbContext = new EFTodoItemsContext(options);

            dbContext.Set <TodoItem>().Add(new TodoItem {
                Text = "Task 1", IsCompleted = true
            });
            dbContext.Set <TodoItem>().Add(new TodoItem {
                Text = "Task 2", IsCompleted = false
            });
            dbContext.Set <TodoItem>().Add(new TodoItem {
                Text = "Task 3", IsCompleted = false
            });
            dbContext.Set <TodoItem>().Add(new TodoItem {
                Text = "Task 4", IsCompleted = true
            });
            dbContext.Set <TodoItem>().Add(new TodoItem {
                Text = "Task 5", IsCompleted = false
            });

            return(dbContext);
        }
Beispiel #2
0
 public TodoItemAsyncRepository(EFTodoItemsContext context)
 {
     _context = context;
 }