public void GetFilteredFromEmptyReturnsNull() { var ToDoItem = new ToDoItem(" Groceries "); IToDoRepository repository2 = new ToDoRepository(); repository2.Add(ToDoItem); Assert.AreEqual(null, repository2.GetFiltered(a => a != a)); }
public void InputingNullFunctionThrowsException() { IToDoRepository repository = new ToDoRepository(); var ToDoItem = new ToDoItem(" Groceries "); repository.Add(ToDoItem); repository.GetFiltered(null); }
public void InputingFunctionReturnsList() { IToDoRepository repository = new ToDoRepository(); var ToDoItem = new ToDoItem(" Groceries "); repository.Add(ToDoItem); Assert.AreEqual(true, repository.GetAll().SequenceEqual(repository.GetFiltered(a => a == a))); }
public void AddingExistingItemWillThrowException() { IToDoRepository repository = new ToDoRepository(); var ToDoItem = new ToDoItem(" Groceries "); repository.Add(ToDoItem); repository.Add(ToDoItem); }
public void AddingItemWillAddToDatabase() { IToDoRepository repository = new ToDoRepository(); var ToDoItem = new ToDoItem(" Groceries "); repository.Add(ToDoItem); Assert.AreEqual(1, repository.GetAll().Count); Assert.IsTrue(repository.Get(ToDoItem.Id) != null); }
public void MarkingNonExisitingCompleteReturnFalse() { IToDoRepository repository = new ToDoRepository(); var ToDoItem = new ToDoItem(" Groceries "); var ToDoItem2 = new ToDoItem(" Groceries 1"); repository.Add(ToDoItem); Assert.AreEqual(false, repository.MarkAsCompleted(ToDoItem2.Id)); }
public void ConstructorWillAddList() { List <ToDoItem> repository = new List <ToDoItem>(); var ToDoItem = new ToDoItem(" Groceries "); repository.Add(ToDoItem); IToDoRepository repository2 = new ToDoRepository(repository); Assert.AreEqual(true, repository.SequenceEqual(repository2.GetAll())); }
public void SearchingExisitingWillReturnItem() { IToDoRepository repository = new ToDoRepository(); var ToDoItem = new ToDoItem(" Groceries "); var ToDoItem2 = new ToDoItem(" Groceries1 "); repository.Add(ToDoItem); repository.Add(ToDoItem2); Assert.AreEqual(ToDoItem, repository.Get(ToDoItem.Id)); }
public void GetActiveFromEmptyReturnsNull() { var ToDoItem = new ToDoItem(" Groceries "); ToDoItem.MarkAsCompleted(); IToDoRepository repository2 = new ToDoRepository(); repository2.Add(ToDoItem); Assert.AreEqual(null, repository2.GetActive()); }
public void GetAllReturnsAll() { List <ToDoItem> repository = new List <ToDoItem>(); var ToDoItem = new ToDoItem(" Groceries "); repository.Add(ToDoItem); IToDoRepository repository2 = new ToDoRepository(repository); repository = repository.OrderBy(i => i.DateCreated).ToList(); Assert.AreEqual(true, repository.SequenceEqual(repository2.GetAll())); }
public void MarkingExisitingCompleteWillCompleteIt() { IToDoRepository repository = new ToDoRepository(); var ToDoItem = new ToDoItem(" Groceries "); repository.Add(ToDoItem); ToDoItem.IsCompleted = true; ToDoItem.DateCompleted = DateTime.Now; Assert.AreEqual(true, repository.MarkAsCompleted(ToDoItem.Id)); Assert.AreEqual(ToDoItem, repository.Get(ToDoItem.Id)); }
public void UpdatingNonExistingWillCreateIt() { IToDoRepository repository = new ToDoRepository(); var ToDoItem = new ToDoItem(" Groceries "); var ToDoItem2 = new ToDoItem(" Groceries 1"); repository.Add(ToDoItem); repository.Update(ToDoItem2); Assert.AreEqual(ToDoItem2, repository.Get(ToDoItem2.Id)); Assert.AreEqual(2, repository.GetAll().Count); }
public void UpdatingExistingWillUpdateIt() { IToDoRepository repository = new ToDoRepository(); var ToDoItem = new ToDoItem(" Groceries "); repository.Add(ToDoItem); ToDoItem.Text = "Groceries novo"; repository.Update(ToDoItem); Assert.AreEqual(ToDoItem, repository.Get(ToDoItem.Id)); Assert.AreEqual(1, repository.GetAll().Count); }
public void RemovingExisitingWillRemoveIt() { IToDoRepository repository = new ToDoRepository(); var ToDoItem = new ToDoItem(" Groceries "); var ToDoItem2 = new ToDoItem(" Groceries1 "); repository.Add(ToDoItem); repository.Add(ToDoItem2); Assert.AreEqual(true, repository.Remove(ToDoItem.Id)); Assert.AreEqual(1, repository.GetAll().Count); }
public void SearchingNonExisitingWillReturnNull() { IToDoRepository repository = new ToDoRepository(); var ToDoItem = new ToDoItem(" Groceries "); var ToDoItem2 = new ToDoItem(" Groceries1 "); var ToDoItem3 = new ToDoItem(" Groceries2 "); repository.Add(ToDoItem); repository.Add(ToDoItem2); Assert.AreEqual(null, repository.Get(ToDoItem3.Id)); }
public void RemovingNonExisitingWillReturnFalse() { IToDoRepository repository = new ToDoRepository(); var ToDoItem = new ToDoItem(" Groceries "); var ToDoItem2 = new ToDoItem(" Groceries1 "); var ToDoItem3 = new ToDoItem(" Groceries2 "); repository.Add(ToDoItem); repository.Add(ToDoItem2); Assert.AreEqual(false, repository.Remove(ToDoItem3.Id)); Assert.AreEqual(2, repository.GetAll().Count); }
public void GetCompletedReturnsAllCompleted() { List <ToDoItem> repository = new List <ToDoItem>(); var ToDoItem = new ToDoItem(" Groceries "); var ToDoItem2 = new ToDoItem(" Groceries 1"); ToDoItem.MarkAsCompleted(); repository.Add(ToDoItem); IToDoRepository repository2 = new ToDoRepository(); repository2.Add(ToDoItem); repository2.Add(ToDoItem2); Assert.AreEqual(true, repository.SequenceEqual(repository2.GetCompleted())); }
public void AddingNullToDatabaseThrowsException() { IToDoRepository repository = new ToDoRepository(); repository.Add(null); }
public void GetAllFromEmptyReturnsNull() { IToDoRepository repository2 = new ToDoRepository(); Assert.AreEqual(null, repository2.GetAll()); }
public void UpdatingNullInDatabaseThrowsException() { IToDoRepository repository = new ToDoRepository(); repository.Update(null); }