Beispiel #1
0
        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)));
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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()));
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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()));
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        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);
        }
Beispiel #8
0
        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);
        }
Beispiel #9
0
        public void GetAllFromEmptyReturnsNull()
        {
            IToDoRepository repository2 = new ToDoRepository();

            Assert.AreEqual(null, repository2.GetAll());
        }