Beispiel #1
0
        public void GetFilteredFromEmptyReturnsNull()
        {
            var             ToDoItem    = new ToDoItem(" Groceries ");
            IToDoRepository repository2 = new ToDoRepository();

            repository2.Add(ToDoItem);
            Assert.AreEqual(null, repository2.GetFiltered(a => a != a));
        }
Beispiel #2
0
        public void InputingNullFunctionThrowsException()
        {
            IToDoRepository repository = new ToDoRepository();
            var             ToDoItem   = new ToDoItem(" Groceries ");

            repository.Add(ToDoItem);
            repository.GetFiltered(null);
        }
Beispiel #3
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 #4
0
        public void AddingExistingItemWillThrowException()
        {
            IToDoRepository repository = new ToDoRepository();
            var             ToDoItem   = new ToDoItem(" Groceries ");

            repository.Add(ToDoItem);
            repository.Add(ToDoItem);
        }
Beispiel #5
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 #6
0
        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));
        }
Beispiel #7
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 #8
0
        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));
        }
Beispiel #9
0
        public void GetActiveFromEmptyReturnsNull()
        {
            var ToDoItem = new ToDoItem(" Groceries ");

            ToDoItem.MarkAsCompleted();
            IToDoRepository repository2 = new ToDoRepository();

            repository2.Add(ToDoItem);
            Assert.AreEqual(null, repository2.GetActive());
        }
Beispiel #10
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 #11
0
        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));
        }
Beispiel #12
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 #13
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 #14
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 #15
0
        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));
        }
Beispiel #16
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 #17
0
        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()));
        }
Beispiel #18
0
        public void AddingNullToDatabaseThrowsException()
        {
            IToDoRepository repository = new ToDoRepository();

            repository.Add(null);
        }
Beispiel #19
0
        public void GetAllFromEmptyReturnsNull()
        {
            IToDoRepository repository2 = new ToDoRepository();

            Assert.AreEqual(null, repository2.GetAll());
        }
Beispiel #20
0
        public void UpdatingNullInDatabaseThrowsException()
        {
            IToDoRepository repository = new ToDoRepository();

            repository.Update(null);
        }