public void TestTodoRepositoryRemove() { TodoItem todo1 = new TodoItem("Some text 1"); TodoItem todo2 = new TodoItem("Some text 2"); TodoItem todo3 = new TodoItem("Some text 3"); TodoItem todo4 = new TodoItem("Some text 4"); // not in the repo IGenericList <TodoItem> todoList = new GenericList <TodoItem>(); todoList.Add(todo1); todoList.Add(todo2); todoList.Add(todo3); TodoRepository todoRepo = new TodoRepository(todoList); // Remove todo3 - should return true Assert.IsTrue(todoRepo.Remove(todo3.Id)); // Mark todo4 (which is not in the repo) - should return false Assert.IsFalse(todoRepo.Remove(todo4.Id)); // Now the item count should be 2 Assert.AreEqual(todoRepo.GetAll().Count, 2); }
public void TestTodoRepositoryMarkAsCompleted() { TodoItem todo1 = new TodoItem("Some text 1"); TodoItem todo2 = new TodoItem("Some text 2"); TodoItem todo3 = new TodoItem("Some text 3"); TodoItem todo4 = new TodoItem("Some text 4"); // not in the repo IGenericList <TodoItem> todoList = new GenericList <TodoItem>(); todoList.Add(todo1); todoList.Add(todo2); todoList.Add(todo3); TodoRepository todoRepo = new TodoRepository(todoList); // Mark todo2 as complete Assert.IsTrue(todoRepo.MarkAsCompleted(todo2.Id)); // Shouldn't be able to mark todo2 as complete if it is already complete Assert.IsFalse(todoRepo.MarkAsCompleted(todo2.Id)); // Mark todo4 (which is not in the repo) - should return false Assert.IsFalse(todoRepo.MarkAsCompleted(todo4.Id)); }
public void TestTodoRepositoryGetFiltered() { TodoItem todo1 = new TodoItem("URGENT: Some text 1"); TodoItem todo2 = new TodoItem("Some text 2"); TodoItem todo3 = new TodoItem("URGENT: Some text 3"); IGenericList <TodoItem> todoList = new GenericList <TodoItem>(); todoList.Add(todo1); todoList.Add(todo2); todoList.Add(todo3); TodoRepository todoRepo = new TodoRepository(todoList); // Test for TodoItems that are URGENT List <TodoItem> activeList = todoRepo.GetFiltered((i) => (i.Text.StartsWith("URGENT"))); // There must be exactly two URGENT items Assert.AreEqual(activeList.Count, 2); // Those two items must be todo1 and todo3 Assert.IsTrue( ((activeList[0] == todo1) && (activeList[1] == todo3)) || ((activeList[0] == todo3) && (activeList[1] == todo1)) ); }
public GenericListEnumerator(GenericList <X> genericList) { this.genericList = genericList; position = -1; }
public GenericListEnumerator(GenericList <X> genericList) { _genericList = genericList; _index = -1; _curent = default(X); }
public GenericListEnumerator(GenericList <T> genericList) { _genericList = genericList; _index = -1; }
public GenericListEnumerator(GenericList <X> inputList) { list = inputList; }
public GenericListEnumerator(GenericList <object> genericList) { this.genericList = genericList; }
public GenericListEnumerator(GenericList <T> list) { _list = list; _currentIndex = -1; }