Ejemplo n.º 1
0
        public virtual void Initialize()
        {
            _testDatabaseStrategy = new SqlCeDatabaseStrategy();
            using (var tempContext = _testDatabaseStrategy.CreateContext())
            {
                TestData.Add2TodoListsAnd3TodoItems(tempContext);
                tempContext.SaveChanges();
            }

            // initialise the repository we are testing
            var context = _testDatabaseStrategy.CreateContext();
            _uow = new UnitOfWork(context);
        }
 private void UpdateRepository()
 {
     _uow.Dispose();
     _uow = new UnitOfWork(_testDatabaseStrategy.CreateContext());
     _todoItemRepository = _uow.TodoItemRepository;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Initiate a new todo list for new user
        /// </summary>
        /// <param name="userName"></param>
        private static void InitiateDatabaseForNewUser(string userName)
        {
            //TodoItemContext db = new TodoItemContext();
            var uow = new UnitOfWork();
            var repository = uow.TodoListRepository;
            TodoList todoList = new TodoList();
            todoList.UserId = userName;
            todoList.Title = "My Todo List #1";
            todoList.Todos = new List<TodoItem>();

            todoList.Todos.Add(new TodoItem() { Title = "Todo item #1", TodoListId = todoList.TodoListId, IsDone = false, Deadline = DateTime.Now.AddDays(1), Priority = 0 });
            todoList.Todos.Add(new TodoItem() { Title = "Todo item #2", TodoListId = todoList.TodoListId, IsDone = false, Deadline = DateTime.Now.AddDays(1), Priority = 1 });
            repository.Add(todoList);
            uow.Save();
        }