示例#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));
        }
示例#2
0
        public void InputingNullFunctionThrowsException()
        {
            IToDoRepository repository = new ToDoRepository();
            var             ToDoItem   = new ToDoItem(" Groceries ");

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

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

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

            repository2.Add(ToDoItem);
            Assert.AreEqual(null, repository2.GetActive());
        }
示例#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()));
        }
示例#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));
        }
示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#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));
        }
示例#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);
        }
示例#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()));
        }
示例#18
0
        public void AddingNullToDatabaseThrowsException()
        {
            IToDoRepository repository = new ToDoRepository();

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

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

            repository.Update(null);
        }