public void Add_ThrowsAddingExceptionTest()
        {
            TestHelper.ClearDatabase(options);

            TaskNote task = new TaskNote {
                Name = "1"
            };
            TaskNote task2 = new TaskNote {
                Name = "2"
            };
            TaskTreeManager manager = new TaskTreeManager(options);

            manager.Add(task);
            Action act1 = () => manager.Add(task);

            manager.Add(task2);
            Action act2 = () => manager.Add(task2);

            Assert.Throws <AddingException>(act1);
            Assert.Throws <AddingException>(act2);
        }
        public void GetAncestor_Test()
        {
            TestHelper.ClearDatabase(options);

            TaskNote[]      tasks = { new TaskNote {
                                          Name = "1"
                                      }, new TaskNote   {
                                          Name = "2"
                                      }, new TaskNote   {
                                          Name = "3"
                                      } };
            TaskTreeManager manager = new TaskTreeManager(options);

            manager.Add(tasks[0]);
            manager.Add(tasks[1], tasks[0]);
            manager.Add(tasks[2], tasks[0]);

            Assert.Null(manager.GetAncestor(tasks[0].Id));
            Assert.Equal(tasks[0].Id, manager.GetAncestor(tasks[1].Id).Id);
            Assert.Equal(tasks[0].Id, manager.GetAncestor(tasks[2].Id).Id);
        }
        public void GetDescendants_Test()
        {
            TestHelper.ClearDatabase(options);

            TaskNote[]      tasks = { new TaskNote {
                                          Name = "1"
                                      }, new TaskNote   {
                                          Name = "2"
                                      }, new TaskNote   {
                                          Name = "3"
                                      } };
            TaskTreeManager manager = new TaskTreeManager(options);

            manager.Add(tasks[0]);
            manager.Add(tasks[1], tasks[0]);
            manager.Add(tasks[2], tasks[0]);
            List <TaskNote> Descendants = manager.GetDescendants(tasks[0].Id);

            Assert.Equal(2, Descendants.Count);
            Assert.Single(Descendants.Where(d => d.Id == tasks[1].Id));
            Assert.Single(Descendants.Where(d => d.Id == tasks[2].Id));
            Assert.Empty(manager.GetDescendants(tasks[1].Id));
        }
        public void Add_ThrowsNotFoundExceptionTest()
        {
            TestHelper.ClearDatabase(options);

            TaskNote[]      tasks = { new TaskNote {
                                          Name = "1"
                                      }, new TaskNote   {
                                          Name = "2"
                                      } };
            TaskTreeManager manager = new TaskTreeManager(options);

            Action act = () => manager.Add(tasks[0], tasks[1]);

            Assert.Throws <NotFoundException>(act);
        }
        public void Update_UpdateTest()
        {
            TestHelper.ClearDatabase(options);

            TaskNote task = new TaskNote {
                Name = "1t"
            };
            TaskTreeManager manager = new TaskTreeManager(options);

            manager.Add(task);
            task.Name = "1t_updated";
            manager.Update(task);

            Assert.Equal(task.Name, manager.Find(task.Id).Name);
        }