public void Test_Delete_DeletesCategoryFromDatabase()
        {
            //Arrange
              string name1 = "Home stuff";
              Category testCategory1 = new Category(name1);
              testCategory1.Save();

              string name2 = "Work stuff";
              Category testCategory2 = new Category(name2);
              testCategory2.Save();
              DateTime fakeTime = new DateTime(2016, 1, 1);

              Task testTask1 = new Task("Mow the lawn", testCategory1.GetId(),fakeTime);
              testTask1.Save();
              DateTime fakeTime1 = new DateTime(2016, 1, 1);

              Task testTask2 = new Task("Send emails", testCategory2.GetId(),fakeTime1);
              testTask2.Save();

              //Act
              testCategory1.Delete();
              List<Category> resultCategories = Category.GetAll();
              List<Category> testCategoryList = new List<Category> {testCategory2};

              List<Task> resultTasks = Task.GetAll();
              List<Task> testTaskList = new List<Task> {testTask2};

              //Assert
              Assert.Equal(testCategoryList, resultCategories);
              Assert.Equal(testTaskList, resultTasks);
        }
Ejemplo n.º 2
0
    public void Test_FindFindsTaskInDatabase()
    {
      //Arrange
      Task testTask = new Task("Mow the lawn");
      testTask.Save();

      //Act
      Task foundTask = Task.Find(testTask.GetId());

      //Assert
      Assert.Equal(testTask, foundTask);
    }
Ejemplo n.º 3
0
        public void Test_Find_FindsTaskInDatabase()
        {
            //Arrange
              DateTime fakeTime = new DateTime(2016, 1, 1);
              Task testTask = new Task("Mow the lawn", 1, fakeTime);
              testTask.Save();

              //Act
              Task foundTask = Task.Find(testTask.GetId());

              //Assert
              Assert.Equal(testTask, foundTask);
        }
Ejemplo n.º 4
0
    public void Test_Save()
    {
      //Arrange
      Task testTask = new Task("Mow the lawn");
      testTask.Save();

      //Act
      List<Task> result = Task.GetAll();
      List<Task> testList = new List<Task>{testTask};

      //Assert
      Assert.Equal(testList, result);
    }
Ejemplo n.º 5
0
        public HomeModule()
        {
          //Index
            Get["/"] = _ => {
              List<Category> AllCategories = Category.GetAll();
              return View["index.cshtml", AllCategories];
            };
            //Get: Lists
            Get["/tasks"] = _ => {
              List<Task> AllTasks = Task.GetAll();
              return View["tasks.cshtml", AllTasks];
            };
            Get["/categories"] = _ => {
              List<Category> AllCategories = Category.GetAll();
              return View["categories.cshtml", AllCategories];
            };

            Get["/categories/new"] = _ => {
              return View["categories_form.cshtml"];
            };
            Post["/categories/new"] = _ => {
              Category newCategory = new Category(Request.Form["category-name"]);
              newCategory.Save();
              return View["success.cshtml"];
            };


            Get["/tasks/new"] = _ => {
              List<Category> AllCategories = Category.GetAll();
              return View["tasks_form.cshtml", AllCategories];
            };
            Post["/tasks/new"] = _ => {
              Task newTask = new Task(Request.Form["task-description"], Request.Form["category-id"]);
              newTask.Save();
              return View["success.cshtml"];
            };

            Post["/tasks/delete"] = _ => {
              Task.DeleteAll();
              return View["cleared.cshtml"];
            };

            Get["categories/{id}"] = parameters => {
              Dictionary<string, object> model = new Dictionary<string, object>();
              var SelectedCategory = Category.Find(parameters.id);
              var CategoryTasks = SelectedCategory.GetTasks();
              model.Add("category", SelectedCategory);
              model.Add("tasks", CategoryTasks);
              return View["/category.cshtml", model];
            };
        }
Ejemplo n.º 6
0
        public void Test_Complete_CompletesTaskWhenDone()
        {
            //Arrange
              string testDescription = "Mow the lawn";
              DateTime? taskDate = new DateTime(2016, 7, 12);
              Task testTask = new Task(testDescription, taskDate);
              testTask.Save();

              //Act
              testTask.Complete();
              bool result = testTask.IsDone();

              //Assert
              Assert.Equal(true, result);
        }
Ejemplo n.º 7
0
    public void Test_SaveAssignsIdToObject()
    {
      //Arrange
      Task testTask = new Task("Mow the lawn");
      testTask.Save();

      //Act
      Task savedTask = Task.GetAll()[0];

      int result = savedTask.GetId();
      int testId = testTask.GetId();

      //Assert
      Assert.Equal(testId, result);
    }
Ejemplo n.º 8
0
        public void Test_Save_AssignsIdToObject()
        {
            //Arrange
              DateTime fakeTime = new DateTime(2016, 1, 1);
              Task testTask = new Task("Mow the lawn", 1, fakeTime);

              //Act
              testTask.Save();
              Task savedTask = Task.GetAll()[0];

              int result = savedTask.GetId();
              int testId = testTask.GetId();

              //Assert
              Assert.Equal(testId, result);
        }
Ejemplo n.º 9
0
        public void Test_Save_SavesToDatabase()
        {
            //Arrange
            DateTime myDate   = new DateTime(1999, 6, 4);
            Task     testTask = new Task("Mow the lawn", 1, myDate);

            testTask.Save();

            //Act
            List <Task> result   = Task.GetAll();
            List <Task> testList = new List <Task> {
                testTask
            };

            //Assert
            Assert.Equal(testList, result);
        }
Ejemplo n.º 10
0
        public void Test_AddCategory_AddsCategoryToTask()
        {
            //Arrange
              Task testTask = new Task("Mow the lawn", new DateTime(2016, 2, 2), false);
              testTask.Save();

              Category testCategory = new Category("Home stuff");
              testCategory.Save();

              //Act
              testTask.AddCategory(testCategory);

              List<Category> result = testTask.GetCategories();
              List<Category> testList = new List<Category>{testCategory};

              //Assert
              Assert.Equal(testList, result);
        }
Ejemplo n.º 11
0
        public void Test_CompletedTasks_ReturnsComplete_list()
        {
            //Arrange
            Task testTask = new Task("Mow the lawn", "01-02-2017", false);

            testTask.Save();
            Task testTask2 = new Task("Take out garbage", "01-02-2017", true);

            testTask2.Save();

            //Act
            List <Task> testResult   = Task.CompletedTasks();
            List <Task> resultResult = new List <Task> {
                testTask2
            };

            Assert.Equal(resultResult, testResult);
        }
Ejemplo n.º 12
0
        public void Task_GetComplete_ReturnAListOfTasks()
        {
            //Arrange
            Task testTask = new Task("Mow the lawn", "1999-01-01");

            testTask.Save();
            Task testTask2 = new Task("Bridge the Gap", "2000-01-01");

            testTask2.Save();

            //Act
            testTask.ToggleComplete();
            testTask.ToggleComplete();
            testTask2.ToggleComplete();

            //Assert
            Assert.Equal(1, Task.GetComplete(false).Count);
        }
Ejemplo n.º 13
0
        public void Test_FindFindsTaskInDatabase()
        {
            //Arrange
            Console.WriteLine("TEST");
            Task testTask = new Task("Mow the lawn", 1);

            Console.WriteLine("TEST2");
            testTask.Save();

            //Act
            Console.WriteLine(testTask.GetId());
            Console.WriteLine("TEST 3");
            Task foundTask = Task.Find(testTask.GetId());

            //Assert
            Console.WriteLine("TEST4");
            Assert.Equal(testTask, foundTask);
        }
Ejemplo n.º 14
0
        public void Test_GetTasks_RetrievesAllTasksWithCategory()
        {
            Category testCategory = new Category("Household chores");

            testCategory.Save();

            Task firstTask = new Task("Mow the lawn", testCategory.GetId(), DateTime.Today);

            firstTask.Save();
            Task secondTask = new Task("Do the dishes", testCategory.GetId(), DateTime.Today);

            secondTask.Save();

            List <Task> testTaskList = new List <Task> {
                firstTask, secondTask
            };
            List <Task> resultTaskList = testCategory.GetTasks();
        }
Ejemplo n.º 15
0
 public HomeModule()
 {
     Get["/"] = _ => View["add_new_task.cshtml"];
     Get["/view_all_tasks"] = _ =>
     {
         List <string> allTasks = Task.GetAll();
         return(View["view_all_tasks.cshtml", allTasks]);
     };
     Post["/tasks_cleared"] = _ => {
         Task.ClearAll();
         return(View["tasks_cleared.cshtml"]);
     };
     Post["/task_added"] = _ => {
         Task newTask = new Task(Request.Form["new-task"]);
         newTask.Save();
         return(View["task_added.cshtml", newTask]);
     };
 }
Ejemplo n.º 16
0
        public void Test_Done_DoneIsSetToTrueOrFalse()
        {
            //Arrange
            int      result       = 1;
            Category testCategory = new Category("Home stuff");

            testCategory.Save();

            Task testTask = new Task("mow the lawn", "2017-02-17");

            testTask.Save();

            //Act
            testTask.SetDone(1);

            //Assert
            Assert.Equal(result, testTask.GetDone());
        }
Ejemplo n.º 17
0
 public HomeModule()
 {
     Get["/"] = _ => {
         List <Category> AllCategories = Category.GetAll();
         return(View["index.cshtml"]);
     };
     Get["/categories"] = _ => {
         var allCategories = Category.GetAll();
         return(View["categories.cshtml", allCategories]);
     };
     Get["/tasks"] = _ => {
         List <Task> AllTasks = Task.GetAll();
         return(View ["tasks.cshtml", AllTasks]);
     };
     Get["/categories/new"] = _ => {
         return(View["categories_form.cshtml"]);
     };
     Post["/categories/new"] = _ => {
         Category newCategory = new Category(Request.Form["category-name"]);
         newCategory.Save();
         return(View["success.cshtml"]);
     };
     Get["/tasks/new"] = _ => {
         List <Category> AllCategories = Category.GetAll();
         return(View["tasks_form.cshtml", AllCategories]);
     };
     Post["/tasks/new"] = _ => {
         Task newTask = new Task(Request.Form["task-description"], Request.Form["category-id"], Request.Form["due-date"]);
         newTask.Save();
         return(View["success.cshtml"]);
     };
     Post["/tasks/delete"] = _ => {
         Task.DeleteAll();
         return(View["cleared.cshtml"]);
     };
     Get["/categories/{id}"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object>();
         var selectedCategory = Category.Find(parameters.id);
         var categoryTasks    = selectedCategory.GetTasks();
         model.Add("category", selectedCategory);
         model.Add("tasks", categoryTasks);
         return(View["category.cshtml", model]);
     };
 }
Ejemplo n.º 18
0
        public HomeModule()
        {
            Get["/form"] = _ =>
            {
                return(View["form.cshtml"]);
            };

            Post["/form"] = _ =>
            {
                Task newTask = new Task(Request.Form["task"]);
                newTask.Save();
                return(View["/form"]);
            };

            Get["/tasks"] = _ =>
            {
                return(View["home.cshtml", Task.GetAll()]);
            };
        }
Ejemplo n.º 19
0
        public void Test18_GetCategories_ReturnsAllTaskCategories()
        {
            DateTime testTime = new DateTime(2016, 1, 1);

              Task testTask = new Task("Mow the lawn",testTime);
              testTask.Save();

              Category testCategory1 = new Category("Home Stuff");
              testCategory1.Save();

              Category testCategory2 = new Category("Work Stuff");
              testCategory2.Save();

              testTask.AddCategory(testCategory1);
              List<Category> result = testTask.GetCategories();
              List<Category> testList= new List<Category>{testCategory1};

              Assert.Equal(testList,result);
        }
Ejemplo n.º 20
0
 public HomeModule()
 {
     Get["/"] = _ => {
         return(View["index.cshtml"]);
     };
     Post["/task_added"] = _ => {
         var NewTask = new Task(Request.Form["new-task"]);
         NewTask.Save();
         return(View["task_added.cshtml", NewTask]);
     };
     Get["/view_all_tasks"] = _ => {
         var AllTasks = Task.ListOfTasks;
         return(View["view_all_tasks.cshtml", AllTasks]);
     };
     Post["/tasks_cleared"] = _ => {
         Task.DeleteAll();
         return(View["tasks_cleared.cshtml"]);
     };
 }
Ejemplo n.º 21
0
 public HomeModule()
 {
     Get["/"] = _ => {
         return View["index.cshtml"];
     };
     Post["/task_added"] = _ => {
       var NewTask = new Task (Request.Form["new-task"]);
       NewTask.Save();
       return View["task_added.cshtml", NewTask];
     };
     Get["/view_all_tasks"] = _ => {
       var AllTasks = Task.ListOfTasks;
       return View["view_all_tasks.cshtml", AllTasks];
     };
     Post["/tasks_cleared"] = _ => {
       Task.DeleteAll();
       return View["tasks_cleared.cshtml"];
     };
 }
Ejemplo n.º 22
0
        public void Test_AddCategory_AddsCategoryToTask()
        {
            DateTime date1    = new DateTime(2008, 4, 10);
            Task     testTask = new Task("Mow the lawn", date1);

            testTask.Save();

            Category testCategory = new Category("Home Stuff");

            testCategory.Save();

            testTask.AddCategory(testCategory);

            List <Category> result   = testTask.GetCategories();
            List <Category> testList = new List <Category> {
                testCategory
            };

            Assert.Equal(testList, result);
        }
Ejemplo n.º 23
0
        public void Test_Delete_DeletesTaskAssociationsFromDatabase()
        {
            //Arrange
              Category testCategory = new Category("Home stuff");
              testCategory.Save();

              string testDescription = "Mow the lawn";
              Task testTask = new Task(testDescription, new DateTime(2016, 2, 2));
              testTask.Save();

              //Act
              testTask.AddCategory(testCategory);
              testTask.Delete();

              List<Task> resultCategoryTasks = testCategory.GetTasks();
              List<Task> testCategoryTasks = new List<Task> {};

              //Assert
              Assert.Equal(testCategoryTasks, resultCategoryTasks);
        }
Ejemplo n.º 24
0
        public void Test_GetCompletedTasks_ReturnsAllCompletedTasks()
        {
            //Arrange
            Task testTask1 = new Task("Mow the lawn", true);

            testTask1.Save();

            Task testTask2 = new Task("Buy plane ticket", false);

            testTask2.Save();

            //Act
            List <Task> savedTasks = Task.GetCompleted();
            List <Task> testList   = new List <Task> {
                testTask1
            };

            //Assert
            Assert.Equal(testList, savedTasks);
        }
Ejemplo n.º 25
0
        public void Task_Update_ReturnUpdatedTask()
        {
            //Arrange
            Task testTask = new Task("Mow the lawn", "1999-01-01");

            testTask.Save();
            Task testTask2 = new Task("Bridge the Gap", "2000-01-01");

            testTask2.Save();
            string newTaskName = "Bridge the Gap";
            string newTaskDate = "2000-01-01";

            //Act
            testTask.Update(newTaskName, newTaskDate);
            testTask.SetId(0);
            testTask2.SetId(0);

            //Assert
            Assert.Equal(testTask2, testTask);
        }
Ejemplo n.º 26
0
        public void Test_Delete_DeletesCategoryAssociationsFromDatabase()
        {
            //Arrange
              Task testTask = new Task("Mow the lawn", false);
              testTask.Save();

              string testName = "Home stuff";
              Category testCategory = new Category(testName);
              testCategory.Save();

              //Act
              testCategory.AddTask(testTask);
              testCategory.Delete();

              List<Category> resultTaskCategories = testTask.GetCategories();
              List<Category> testTaskCategories = new List<Category> {};

              //Assert
              Assert.Equal(testTaskCategories, resultTaskCategories);
        }
        public void Test_Delete_DeletesCategoryAssociationsFromDatabase()
        {
            DateTime date1    = new DateTime(2008, 4, 10);
            Task     testTask = new Task("Mow the lawn", date1);

            testTask.Save();

            string   testName     = "Home Stuff";
            Category testCategory = new Category(testName);

            testCategory.Save();

            testCategory.AddTask(testTask);
            testCategory.Delete();

            List <Category> resultTaskCategories = testTask.GetCategories();
            List <Category> testTaskCategories   = new List <Category> {
            };

            Assert.Equal(testTaskCategories, resultTaskCategories);
        }
Ejemplo n.º 28
0
        public void Test_DeleteCategory_DeletesEntireCategory()
        {
            // Arrange
            Category newCategory = new Category("Kitchen");

            newCategory.Save();
            int targetId = newCategory.GetId();

            Task firstTask = new Task("Wash Dishes", "1999-01-01");

            firstTask.Save();
            Task secondTask = new Task("Empty Dishwasher", "2000-01-01");

            secondTask.Save();

            //Act
            newCategory.Delete();

            //Assert
            Assert.Equal(0, Category.GetAll().Count);
        }
Ejemplo n.º 29
0
        public void Test_GetTasks_RetrievesAllTasksWithCategory()
        {
            Category testCategory = new Category("Household chores");

            testCategory.Save();

            Task firstTask = new Task("Mow the lawn", testCategory.GetId(), "06/15/2020");

            firstTask.Save();
            Task secondTask = new Task("Do the dishes", testCategory.GetId(), "05/15/2020");

            secondTask.Save();


            List <Task> testTaskList = new List <Task> {
                firstTask, secondTask
            };
            List <Task> resultTaskList = testCategory.GetTasks();

            Assert.Equal(testTaskList, resultTaskList);
        }
Ejemplo n.º 30
0
        public void Test_Delete_DeletesTaskAssociationsFromDatabase()
        {
            Category testCategory = new Category("Home stuff");

            testCategory.Save();

            string   testDescription = "Mow the lawn";
            DateTime date1           = new DateTime(2008, 4, 10);
            Task     testTask        = new Task(testDescription, date1);

            testTask.Save();

            testTask.AddCategory(testCategory);
            testTask.Delete();

            List <Task> resultCategoryTasks = testCategory.GetTasks();
            List <Task> testCategoryTasks   = new List <Task> {
            };

            Assert.Equal(testCategoryTasks, resultCategoryTasks);
        }
Ejemplo n.º 31
0
        public void Test_AddTask_AddsTaskToCategory()
        {
            //Arrange
              Category testCategory = new Category("Household chores");
              testCategory.Save();

              Task testTask = new Task("Mow the lawn", false);
              testTask.Save();

              Task testTask2 = new Task("Water the garden", false);
              testTask2.Save();

              //Act
              testCategory.AddTask(testTask);
              testCategory.AddTask(testTask2);

              List<Task> result = testCategory.GetTasks();
              List<Task> testList = new List<Task>{testTask, testTask2};

              //Assert
              Assert.Equal(testList, result);
        }
Ejemplo n.º 32
0
        public void Test_GetTasks_RetrievesAllTasksWithCategory()
        {
            Category testCategory = new Category("Household chores");

            testCategory.Save();
            DateTime time = new DateTime(2016, 08, 08);

            Task firstTask = new Task("Mow the lawn", time);

            firstTask.Save();
            Task secondTask = new Task("Do the dishes", time);

            secondTask.Save();

            testCategory.AddTask(firstTask);
            List <Task> testTaskList = new List <Task> {
                firstTask
            };
            List <Task> resultTaskList = testCategory.GetTasks();

            Assert.Equal(testTaskList, resultTaskList);
        }
Ejemplo n.º 33
0
        public void Delete_DeletesCategoryAssociationsFromDatabase_CategoryList()
        {
            //Arrange
            Task testTask = new Task("Mow the lawn", true);

            testTask.Save();
            string   testName     = "Home stuff";
            Category testCategory = new Category(testName);

            testCategory.Save();

            //Act
            testCategory.AddTask(testTask);
            testCategory.Delete();

            List <Category> resultTaskCategories = testTask.GetCategories();
            List <Category> testTaskCategories   = new List <Category> {
            };

            //Assert
            Assert.Equal(testTaskCategories, resultTaskCategories);
        }
Ejemplo n.º 34
0
        public void Test_AddCategory_AddsCategoryToTask()
        {
            //Arrange
            Task testTask = new Task("Mow the lawn");

            testTask.Save();

            Category testCategory = new Category("Home stuff");

            testCategory.Save();

            //Act
            testTask.AddCategory(testCategory);

            List <Category> result   = testTask.GetCategories();
            List <Category> testList = new List <Category> {
                testCategory
            };

            //Assert
            Assert.Equal(testList, result);
        }
Ejemplo n.º 35
0
 public HomeModule()
 {
     Get["/"] = _ => {
       return View["index.cshtml"];
     };
     Get["/tasks"] = _ => {
       List<Task> AllTasks = Task.All();
       return View["tasks.cshtml", AllTasks];
     };
     Get["/tasks/new"] = _ => {
       return View["tasks_form.cshtml"];
     };
     Post["/tasks/new"] = _ => {
       Task newTask = new Task(Request.Form["task-description"]);
       newTask.Save();
       return View["success.cshtml"];
     };
     Post["/tasks/delete"] = _ => {
       Task.DeleteAll();
       return View["cleared.cshtml"];
     };
 }
Ejemplo n.º 36
0
 public HomeModule()
 {
     Get["/"] = _ => {
         return(View["index.cshtml"]);
     };
     Get["/tasks"] = _ => {
         List <Task> AllTasks = Task.All();
         return(View["tasks.cshtml", AllTasks]);
     };
     Get["/tasks/new"] = _ => {
         return(View["tasks_form.cshtml"]);
     };
     Post["/tasks/new"] = _ => {
         Task newTask = new Task(Request.Form["task-description"]);
         newTask.Save();
         return(View["success.cshtml"]);
     };
     // Post["/tasks/delete"] = _ => {
     //   Task.DeleteAll();
     //   return View["cleared.cshtml"];
     // };
 }
Ejemplo n.º 37
0
        public void Test_Delete_DeletesTaskAssociationsFromDatabase()
        {
            //Arrange
            Category testCategory = new Category("Home stuff");

            testCategory.Save();

            Task testTask = new Task("Mow the lawn");

            testTask.Save();

            //Act
            testTask.AddCategory(testCategory);
            testTask.Delete();

            List <Task> resultCategoryTasks = testCategory.GetTasks();
            List <Task> testCategoryTasks   = new List <Task> {
            };

            //Assert
            Assert.Equal(testCategoryTasks, resultCategoryTasks);
        }
Ejemplo n.º 38
0
        public void Test_GetCategories_ReturnsAllTaskCategories()
        {
            DateTime date1    = new DateTime(2008, 4, 10);
            Task     testTask = new Task("Mow the lawn", date1);

            testTask.Save();

            Category testCategory1 = new Category("Home stuff");

            testCategory1.Save();

            Category testCategory2 = new Category("Work stuff");

            testCategory2.Save();

            testTask.AddCategory(testCategory1);
            List <Category> result   = testTask.GetCategories();
            List <Category> testList = new List <Category> {
                testCategory1
            };

            Assert.Equal(testList, result);
        }
        public void Test_GetTasks_ReturnsAllCatergoryTasks()
        {
            DateTime date1        = new DateTime(2008, 4, 10);
            Category testCategory = new Category("Household chores");

            testCategory.Save();

            Task testTask1 = new Task("Mow the lawn", date1);

            testTask1.Save();

            Task testTask2 = new Task("Buy plane ticket", date1);

            testTask2.Save();

            testCategory.AddTask(testTask1);
            List <Task> savedTasks = testCategory.GetTasks();
            List <Task> testList   = new List <Task> {
                testTask1
            };

            Assert.Equal(testList, savedTasks);
        }
Ejemplo n.º 40
0
        public void Test_SortByDate()
        {
            //Arrange
            Task testTask1 = new Task("Mow the lawn", 1, "01-02-2017");
            Task testTask2 = new Task("Mow the lawn", 1, "01-03-2017");
            Task testTask3 = new Task("Mow the lawn", 1, "01-01-2017");

            testTask1.Save();
            testTask2.Save();
            testTask3.Save();

            //Act
            List <Task> result   = Task.OrderByDate();
            List <Task> testList = new List <Task> {
                testTask3, testTask1, testTask2
            };

            Console.WriteLine(result);
            Console.WriteLine(testList);

            //Assert
            Assert.Equal(testList, result);
        }
Ejemplo n.º 41
0
        public void UpdateProperties_UpdatePropertiesInDatabase_true()
        {
            //Arrange
            string description = "mow the lawn";
            bool   completed   = false;

            Task testTask = new Task(description, completed);

            testTask.Save();
            string newDescription = "rake leaves";
            bool   newCompleted   = true;

            //Act
            testTask.UpdateProperties(newDescription, newCompleted);
            Task result = Task.GetAll()[0];

            Console.WriteLine(result);
            Console.WriteLine(testTask);

            //Assert
            Assert.Equal(testTask, result);
            // Assert.Equal(newDescription, result.GetDescription());
        }
Ejemplo n.º 42
0
        public void Test_GetTasks_RetrieveAllTasksWithCategory()
        {
            //Arrange
            Category testCategory = new Category("Everyday chores");

            testCategory.Save();

            DateTime myDate    = new DateTime(1999, 6, 4);
            Task     firstTask = new Task("Mow the lawn", testCategory.GetId(), myDate);

            firstTask.Save();

            Task secondTask = new Task("Do the Dishes", testCategory.GetId(), myDate);

            secondTask.Save();

            List <Task> testTaskList = new List <Task> {
                firstTask, secondTask
            };
            List <Task> result = testCategory.GetTask();

            Assert.Equal(testTaskList, result);
        }
Ejemplo n.º 43
0
        public void Test_Delete_RemoveTaskFromDatabase()
        {
            // Arrange

            Task firstTask = new Task("Wash Dishes", "1999-01-01");

            firstTask.Save();
            Task secondTask = new Task("Empty Dishwasher", "2000-01-01");

            secondTask.Save();


            // Act
            List <Task> testTaskList = new List <Task> {
                secondTask
            };

            firstTask.Delete();
            List <Task> resultTaskList = Task.GetAll();

            //Assert
            Assert.Equal(testTaskList, resultTaskList);
        }
Ejemplo n.º 44
0
        public void Test_Delete_DeletesCategoryFromDatabase()
        {
            //Arrange
            string   name1         = "Home stuff";
            Category testCategory1 = new Category(name1);

            testCategory1.Save();

            string   name2         = "Work stuff";
            Category testCategory2 = new Category(name2);

            testCategory2.Save();

            Task testTask1 = new Task("Mow the lawn", testCategory1.GetId());

            testTask1.Save();
            Task testTask2 = new Task("Send emails", testCategory2.GetId());

            testTask2.Save();

            //Act
            testCategory1.Delete();
            List <Category> resultCategories = Category.GetAll();
            List <Category> testCategoryList = new List <Category> {
                testCategory2
            };

            List <Task> resultTasks  = Task.GetAll();
            List <Task> testTaskList = new List <Task> {
                testTask2
            };

            //Assert
            Assert.Equal(testCategoryList, resultCategories);
            Assert.Equal(testTaskList, resultTasks);
        }
Ejemplo n.º 45
0
        public void Test_Delete_DeletesTaskAssociationsFromDatabase()
        {
            //Arrange
            Category testCategory = new Category("Home stuff");

            testCategory.Save();

            string testDescription = "Mow the lawn";
            bool   testComplete    = false;
            Task   testTask        = new Task(testDescription, testComplete);

            testTask.Save();

            //Act
            testTask.AddCategory(testCategory);
            testTask.Delete();

            List <Task> resultCategoryTasks = testCategory.GetTasks();
            List <Task> testCategoryTasks   = new List <Task> {
            };

            //Assert
            Assert.Equal(testCategoryTasks, resultCategoryTasks);
        }
Ejemplo n.º 46
0
    public void Test_Update_UpdatesTaskInDatabase()
    {
      //Arrange
      string description = "Mow the lawn";
      Task testTask = new Task(description);
      testTask.Save();
      string newDescription = "Walk the dog";

      //Act
      testTask.Update(newDescription);
      string result = testTask.GetDescription();

      //Assert
      Assert.Equal(newDescription, result);
    }
Ejemplo n.º 47
0
        public HomeModule()
        {
            Get["/"] = _ => {
            return View["index.cshtml"];
              };
              Get["/tasks"] = _ => {
            List<Task> AllTasks = Task.GetAll();
            return View["tasks.cshtml", AllTasks];
              };
              Get["/categories"] = _ => {
            List<Category> AllCategories = Category.GetAll();
            return View["categories.cshtml", AllCategories];
              };

              //Create a new task
              Get["/tasks/new"] = _ => {
            return View["tasks_form.cshtml"];
              };
              Post["/tasks/new"] = _ => {
            DateTime newDateTime = Convert.ToDateTime((string)Request.Form["task-date"]);
            Task newTask = new Task(Request.Form["task-description"],newDateTime);
            newTask.Save();
            return View["success.cshtml"];
              };

              //Create a new category
              Get["/categories/new"] = _ => {
            return View["categories_form.cshtml"];
              };
              Post["/categories/new"] = _ => {
            Category newCategory = new Category(Request.Form["category-name"]);
            newCategory.Save();
            return View["success.cshtml"];
              };

              Get["/categories/delete/{id}"] = parameters => {
            Category newCategory = Category.Find(parameters.id);
            newCategory.Delete();
            List<Category> AllCategories = Category.GetAll();
            return View["categories.cshtml",AllCategories];
              };
              //Creates individual pages for category and task
              Get["tasks/{id}"] = parameters => {
            Dictionary<string, object> model = new Dictionary<string, object>();
            Task SelectedTask = Task.Find(parameters.id);
            List<Category> TaskCategories = SelectedTask.GetCategories();
            List<Category> AllCategories = Category.GetAll();
            model.Add("task", SelectedTask);
            model.Add("taskCategories", TaskCategories);
            model.Add("allCategories", AllCategories);
            return View["task.cshtml", model];
              };

              Post["tasks/{id}"] = parameters => {
            Dictionary<string, object> model = new Dictionary<string, object>();
            Task SelectedTask = Task.Find(parameters.id);
            SelectedTask.Update(Request.Form["description"],(bool)Request.Form["task-done"]);
            List<Category> TaskCategories = SelectedTask.GetCategories();
            List<Category> AllCategories = Category.GetAll();
            model.Add("task", SelectedTask);
            model.Add("taskCategories", TaskCategories);
            model.Add("allCategories", AllCategories);
            return View["task.cshtml", model];
              };

              Get["/tasks/delete/{id}"] = parameters => {
            Task newTask = Task.Find(parameters.id);
            newTask.Delete();
            List<Task> AllTasks = Task.GetAll();
            return View["tasks.cshtml", AllTasks];
              };

              Get["categories/{id}"] = parameters => {
            Dictionary<string, object> model = new Dictionary<string, object>();
            Category SelectedCategory = Category.Find(parameters.id);
            List<Task> CategoryTasks = SelectedCategory.GetTasks();
            List<Task> AllTasks = Task.GetAll();
            model.Add("category", SelectedCategory);
            model.Add("categoryTasks", CategoryTasks);
            model.Add("allTasks", AllTasks);
            return View["category.cshtml", model];
              };

              //Post routes for forms
              Post["task/add_category"] = _ => {
            Category category = Category.Find(Request.Form["category-id"]);
            Task task = Task.Find(Request.Form["task-id"]);
            task.AddCategory(category);
            bool retBool = (bool)Request.Form["task-done"];
            task.SetCompleted(retBool);
            return View["success.cshtml"];
              };
              Post["category/add_task"] = _ => {
            Category category = Category.Find(Request.Form["category-id"]);
            Task task = Task.Find(Request.Form["task-id"]);
            category.AddTask(task);
            return View["success.cshtml"];
              };
        }
Ejemplo n.º 48
0
    public void Test_GetCategories_ReturnsAllTaskCategories()
    {
      //Arrange
      Task testTask = new Task("Mow the lawn");
      testTask.Save();

      Category testCategory1 = new Category("Home stuff");
      testCategory1.Save();

      Category testCategory2 = new Category("Work stuff");
      testCategory2.Save();

      //Act
      testTask.AddCategory(testCategory1);
      List<Category> result = testTask.GetCategories();
      List<Category> testList = new List<Category> {testCategory1};

      //Assert
      Assert.Equal(testList, result);
    }
Ejemplo n.º 49
0
    public void Test_Delete_DeletesTaskFromDatabase()
    {
      //Arrange
      Category testCategory = new Category("Home stuff");
      testCategory.Save();

      string description1 = "Mow the lawn";
      Task testTask1 = new Task(description1);
      testTask1.Save();

      string description2 = "Do homework";
      Task testTask2 = new Task(description2);
      testTask2.Save();

      //Act
      testTask1.AddCategory(testCategory);
      testTask1.Delete();

      List<Task> resultTasks = Task.GetAll();
      List<Task> testTaskList = new List<Task> {testTask2};

      List<Task> resultCategoryTasks = testCategory.GetTasks();
      List<Task> testCategoryTasks = new List<Task> {};

      //Assert
      Assert.Equal(testTaskList, resultTasks);
      Assert.Equal(testCategoryTasks, resultCategoryTasks);
    }
Ejemplo n.º 50
0
        public void Test_Save_SavesToDatabase()
        {
            //Arrange
              DateTime? taskDate = new DateTime(2016, 7, 12);
              Task testTask = new Task("Mow the lawn", taskDate);

              //Act
              testTask.Save();
              List<Task> result = Task.GetAll();
              List<Task> testList = new List<Task>{testTask};

              //Assert
              Assert.Equal(testList, result);
        }
Ejemplo n.º 51
0
        public HomeModule()
        {
            Get["/"] = _ => {
              return View["index.cshtml"];
            };
            Get["/due-date"] = _ => {
              return View["dueDate_form.cshtml"];
            };

            Get["/duedate"] = _ => {
              List<Task> AllTasks = Task.FindDueDate(Request.Query["latest-date"]);
              return View["tasks.cshtml",AllTasks];
            };

            Get["/tasks"] = _ => {
            List<Task> AllTasks = Task.GetAll();
            return View["tasks.cshtml", AllTasks];
            };
            Get["/categories"] = _ => {
              List<Category> AllCategories = Category.GetAll();
              return View["categories.cshtml", AllCategories];
            };

            Get["/categories/new"] = _ => {
            return View["categories_form.cshtml"];
            };
            Post["/categories/new"] = _ => {
              Category newCategory = new Category(Request.Form["category-name"]);
              newCategory.Save();
              return View["success.cshtml"];
            };
            Get["/tasks/new"] = _ => {
              List<Category> AllCategories = Category.GetAll();
              return View["tasks_form.cshtml", AllCategories];
            };
            Post["/tasks/new"] = _ => {
              Task newTask = new Task(Request.Form["task-description"], Request.Form["category-id"], Request.Form["new-date"]);
              newTask.Save();
              return View["success.cshtml"];
            };

            Post["/tasks/delete"] = _ => {
              Task.DeleteAll();
              return View["cleared.cshtml"];
            };

            Get["/categories/{id}"] = parameters => {
              Dictionary<string, object> model = new Dictionary<string, object>();
              var SelectedCategory = Category.Find(parameters.id);
              var CategoryTasks = SelectedCategory.GetTasks();
              model.Add("category", SelectedCategory);
              model.Add("tasks", CategoryTasks);
              return View["category.cshtml", model];
            };

            Get["category/edit/{id}"] = parameters => {
              Category SelectedCategory = Category.Find(parameters.id);
              return View["category_edit.cshtml", SelectedCategory];
            };

            Patch["category/edit/{id}"] = parameters=>{
              Category SelectedCategory = Category.Find(parameters.id);
              SelectedCategory.Update(Request.Form["category-name"]);
              return View["success.cshtml"];
            };

            Get["category/delete/{id}"] = parameters => {
              Category SelectedCategory = Category.Find(parameters.id);
              return View["category_delete.cshtml", SelectedCategory];
            };
            Delete["category/delete/{id}"] = parameters => {
              Category SelectCategory = Category.Find(parameters.id);
              SelectCategory.Delete();
              return View["success.cshtml"];
            };
        }
        public HomeModule()
        {
            //Index
            Get["/"] = _ => {
              return View["index.cshtml"];
            };

            //Get lists
            Get["/tasks"] = _ => {
              List<Task> AllTasks = Task.GetAll();
              return View["tasks.cshtml", AllTasks];
            };
            Get["/categories"] = _ => {
              List<Category> AllCategories = Category.GetAll();
              return View["categories.cshtml", AllCategories];
            };

            //Create a new task
            Get["/tasks/new"] = _ => {
              return View["tasks_form.cshtml"];
            };
            Post["/tasks/new"] = _ => {
              Task newTask = new Task(Request.Form["task-description"]);
              newTask.Save();
              return View["success.cshtml"];
            };

            //Create a new category
            Get["/categories/new"] = _ => {
              return View["categories_form.cshtml"];
            };
            Post["/categories/new"] = _ => {
              Category newCategory = new Category(Request.Form["category-name"]);
              newCategory.Save();
              return View["success.cshtml"];
            };

            //View individual task/category pages
            Get["tasks/{id}"] = parameters => {
              Dictionary<string, object> model = new Dictionary<string, object>();
              Task SelectedTask = Task.Find(parameters.id);
              List<Category> TaskCategories = SelectedTask.GetCategories();
              List<Category> AllCategories = Category.GetAll();
              model.Add("task", SelectedTask);
              model.Add("taskCategories", TaskCategories);
              model.Add("allCategories", AllCategories);
              return View["task.cshtml", model];
            };

            Get["categories/{id}"] = parameters => {
              Dictionary<string, object> model = new Dictionary<string, object>();
              Category SelectedCategory = Category.Find(parameters.id);
              List<Task> CategoryTasks = SelectedCategory.GetTasks();
              List<Task> AllTasks = Task.GetAll();
              model.Add("category", SelectedCategory);
              model.Add("categoryTasks", CategoryTasks);
              model.Add("allTasks", AllTasks);
              return View["category.cshtml", model];
            };

            //Add category to task
            Post["task/add_category"] = _ => {
              Category category = Category.Find(Request.Form["category-id"]);
              Task task = Task.Find(Request.Form["task-id"]);
              task.AddCategory(category);
              return View["success.cshtml"];
            };
            Post["category/add_task"] = _ => {
              Category category = Category.Find(Request.Form["category-id"]);
              Task task = Task.Find(Request.Form["task-id"]);
              category.AddTask(task);
              return View["success.cshtml"];
            };

        }
Ejemplo n.º 53
0
        public HomeModule()
        {
            //Index
            Get["/"] = _ => {
              List<Category> AllCategories = Category.GetAll();
              return View["index.cshtml", AllCategories];
            };

            //Get: Lists
            Get["/tasks"] = _ => {
              List<Task> AllTasks = Task.GetAll();
              return View["tasks.cshtml", AllTasks];
            };
            Get["/categories"] = _ => {
              List<Category> AllCategories = Category.GetAll();
              return View["categories.cshtml", AllCategories];
            };

            //Create new category
            Get["/categories/new"] = _ => {
              return View["categories_form.cshtml"];
            };
            Post["/categories/new"] = _ => {
              Category newCategory = new Category(Request.Form["category-name"]);
              newCategory.Save();
              return View["success.cshtml"];
            };

            //Create new task
            Get["/tasks/new"] = _ => {
              List<Category> AllCategories = Category.GetAll();
              return View["tasks_form.cshtml", AllCategories];
            };
            Post["/tasks/new"] = _ => {
              Task newTask = new Task(Request.Form["task-description"], Request.Form["category-id"]);
              newTask.Save();
              return View["success.cshtml"];
            };

            //"Clear All" routes
            Post["/tasks/clear"] = _ => {
              Task.DeleteAll();
              return View["cleared.cshtml"];
            };
            Post["/categories/clear"] = _ => {
              Category.DeleteAll();
              return View["cleared.cshtml"];
            };

            //View specific category
            Get["categories/{id}"] = parameters => {
              Dictionary<string, object> model = new Dictionary<string, object>();
              var SelectedCategory = Category.Find(parameters.id);
              var CategoryTasks = SelectedCategory.GetTasks();
              model.Add("category", SelectedCategory);
              model.Add("tasks", CategoryTasks);
              return View["category.cshtml", model];
            };

            //Edit specific category
            Get["category/edit/{id}"] = parameters => {
              Category SelectedCategory = Category.Find(parameters.id);
              return View["category_edit.cshtml", SelectedCategory];
            };
            Patch["category/edit/{id}"] = parameters => {
              Category SelectedCategory = Category.Find(parameters.id);
              SelectedCategory.Update(Request.Form["category-name"]);
              return View["success.cshtml"];
            };

            //Delete specific category
            Get["category/delete/{id}"] = parameters => {
              Category SelectedCategory = Category.Find(parameters.id);
              return View["category_delete.cshtml", SelectedCategory];
            };
            Delete["category/delete/{id}"] = parameters => {
              Category SelectedCategory = Category.Find(parameters.id);
              SelectedCategory.Delete();
              return View["success.cshtml"];
            };
        }
Ejemplo n.º 54
0
        public HomeModule()
        {
            Get["/"] = _ => {
            List<Category> AllCategories = Category.GetAll();
            return View["index.cshtml", AllCategories];
              };
              Get["/tasks"] = _ => {
            List<Task> AllTasks = Task.GetAll();
            return View["tasks.cshtml", AllTasks];
              };
              Get["/categories"] = _ => {
            List<Category> AllCategories = Category.GetAll();
            return View["categories.cshtml", AllCategories];
              };
              Get["/categories/new"] = _ => {
            return View["categories_form.cshtml"];
              };
              Post["/categories/new"] = _ => {
            Category newCategory = new Category(Request.Form["category-name"]);
            newCategory.Save();
            return View["success.cshtml"];
              };
              Get["/tasks/new"] = _ => {
            return View["tasks_form.cshtml"];
              };
              Post["/tasks/new"] = _ => {
            Task newTask = new Task(Request.Form["task-description"],Request.Form["task-dueDate"]);
            newTask.Save();
            return View["success.cshtml"];
              };
              Post["/tasks/delete"] = _ => {
            Task.DeleteAll();
            return View["cleared.cshtml"];
              };
              Get["/categories/{id}"] = parameters => {
            Dictionary<string, object> model = new Dictionary<string, object>();
            var SelectedCategory = Category.Find(parameters.id);
            var CategoryTasks = SelectedCategory.GetTasks();
            model.Add("category", SelectedCategory);
            model.Add("tasks", CategoryTasks);
            return View["category.cshtml", model];
              };
              Get["category/edit/{id}"] = parameters => {
            Category SelectedCategory = Category.Find(parameters.id);
            return View["category_edit.cshtml", SelectedCategory];
              };
              Patch["category/edit/{id}"] = parameters => {
            Category SelectedCategory = Category.Find(parameters.id);
            SelectedCategory.Update(Request.Form["category-name"]);
            return View["success.cshtml"];
              };
              Get["category/delete/{id}"] = parameters => {
            Category SelectedCategory = Category.Find(parameters.id);
            return View["category_delete.cshtml", SelectedCategory];
              };
              Delete["category/delete/{id}"] = parameters => {
            Category SelectedCategory = Category.Find(parameters.id);
            SelectedCategory.Delete();
            return View["success.cshtml"];
              };

              Get["tasks/{id}"]=parameters=>{
            Dictionary<string, object> model = new Dictionary<string, object>();
            Task SelectedTask = Task.Find(parameters.id);
            List<Category> TaskCategories = SelectedTask.GetCategories();
            List<Category> AllCategories = Category.GetAll();
            model.Add("task",SelectedTask);
            model.Add("taskCategories",TaskCategories);
            model.Add("allCategories",AllCategories);
            return View["task.cshtml",model];
              };

              Get["categories/{id}"] = parameters => {
            Dictionary<string, object> model = new Dictionary<string, object>();
            Category selectedCategory = Category.Find(parameters.id);
            List<Task> categoryTasks = selectedCategory.GetTasks();
            List<Task> allTasks = Task.GetAll();
            model.Add("category", selectedCategory);
            model.Add("categoryTasks", categoryTasks);
            model.Add("allTasks", allTasks);
            return View["category.cshtml", model];
              };
              Post["task/add_category"] = _ =>{
            Category category= Category.Find(Request.Form["category-id"]);
            Task task = Task.Find(Request.Form["task-id"]);
            task.AddCategory(category);
            return View["success.cshtml"];
              };
              Post["category/add_task"] = _ => {
            Category category = Category.Find(Request.Form["category-id"]);
            Task task = Task.Find(Request.Form["task-id"]);
            category.AddTask(task);
            return View["success.cshtml"];
              };
        }
Ejemplo n.º 55
0
        public void Test_GetTasks_RetrievesAllTaskWithCategory()
        {
            Category testCategory = new Category("Household chores");
              testCategory.Save();

              DateTime fakeTime = new DateTime(2014, 1, 1);
              Task firstTask = new Task ("Mow the lawn", testCategory.GetId(), fakeTime);
              firstTask.Save();
              Task secondTask = new Task("Do the dishes", testCategory.GetId(), fakeTime);
              secondTask.Save();

              List<Task> testTaskList = new List<Task> {firstTask, secondTask};
              List<Task> resultTaskList = testCategory.GetTasks();

              Assert.Equal(testTaskList, resultTaskList);
        }
Ejemplo n.º 56
0
        public HomeModule()
        {
            Get["/"] = _ => {
            List<Category> categoryList = Category.GetAll();
            return View["index.cshtml", categoryList];
              };

              Delete["/"]=_=>{
            Category.DeleteAll();
            Task.DeleteAll();
            List<Category> categoryList = Category.GetAll();
            return View["index.cshtml", categoryList];
              };

              Get["/category/add"] = _ => View["add_category.cshtml"];

              Post["/category/add"] = _ => {
            Category newCategory = new Category(Request.Form["name"]);
            newCategory.Save();
            List<Category> categoryList = Category.GetAll();
            return View["index.cshtml", categoryList];
              };

              Get["/task/add"] = _ => {
            List<Category> categoryList = Category.GetAll();
            return View["add_task.cshtml", categoryList];
              };

              Post["/task/add"] = _ => {
            Task newTask = new Task(Request.Form["description"], Request.Form["date"]);
            newTask.Save();
            List<Category> categoryList = Category.GetAll();
            return View["index.cshtml", categoryList];
              };

              Get["/task/all"] = _ => {
            List<Task> allTasks = Task.GetAll();
            return View["task_list.cshtml", allTasks];
              };

              Get["/category/{id}"] = parameters => {
            Category currentCategory = Category.Find(parameters.id);
            Console.WriteLine(currentCategory.GetName());
            List<Task> tasksInCategory = currentCategory.GetTasks();
            Console.WriteLine(tasksInCategory.Count);
            return View["task_list.cshtml", tasksInCategory];
              };

              Get["task/{id}"] = parameters => {
            Dictionary<string, object> model = new Dictionary<string, object>();
            Task SelectedTask = Task.Find(parameters.id);
            List<Category> TaskCategories = SelectedTask.GetCategories();
            List<Category> AllCategories = Category.GetAll();
            model.Add("task", SelectedTask);
            model.Add("taskCategories", TaskCategories);
            model.Add("allCategories", AllCategories);
            return View["task.cshtml", model];
              };

              Get["category/{id}"] = parameters => {
            Dictionary<string, object> model = new Dictionary<string, object>();
            Category SelectedCategory = Category.Find(parameters.id);
            List<Task> CategoryTasks = SelectedCategory.GetTasks();
            List<Task> AllTasks = Task.GetAll();
            model.Add("category", SelectedCategory);
            model.Add("categoryTasks", CategoryTasks);
            model.Add("allTasks", AllTasks);
            return View["category.cshtml", model];
              };

              Post["task/add_category"] = _ => {
            Category category = Category.Find(Request.Form["category-id"]);
            Task task = Task.Find(Request.Form["task-id"]);
            task.AddCategory(category);
            Dictionary<string, object> model = new Dictionary<string, object>();
            model.Add("task", task);
            model.Add("taskCategories", task.GetCategories());
            model.Add("allCategories", Category.GetAll());
            return View["task.cshtml", model];
              };

              Post["category/add_task"] = _ => {
            Category category = Category.Find(Request.Form["category-id"]);
            Task task = Task.Find(Request.Form["task-id"]);
            category.AddTask(task);
            Dictionary<string, object> model = new Dictionary<string, object>();
            model.Add("category", category);
            model.Add("categoryTasks", category.GetTasks());
            model.Add("allTasks", Task.GetAll());
            return View["category.cshtml", model];
              };

              Delete["category/{id}/delete"] = parameters =>
              {
            Category category = Category.Find(parameters.id);
            category.Delete();
            List<Category> categoryList = Category.GetAll();
            return View["index.cshtml", categoryList];
              };

              Delete["task/{id}/delete"] = parameters =>
              {
            Task task = Task.Find(parameters.id);
            task.Delete();
            List<Category> categoryList = Category.GetAll();
            return View["index.cshtml", categoryList];
              };

              Patch["task/{id}/complete"] = parameters =>
              {
            Task task = Task.Find(parameters.id);
            task.Complete();
            Dictionary<string, object> model = new Dictionary<string, object>();
            List<Category> TaskCategories = task.GetCategories();
            List<Category> AllCategories = Category.GetAll();
            model.Add("task", task);
            model.Add("taskCategories", TaskCategories);
            model.Add("allCategories", AllCategories);
            return View["task.cshtml", model];
              };
        }
        public void Test_Delete_DeletesCategoryAssociationsFromDatabase()
        {
            //Arrange
              DateTime testTime = new DateTime(2016, 1, 1);

              Task testTask = new Task("Mow the lawn",testTime);
              testTask.Save();

              string testName = "Home stuff";
              Category testCategory = new Category(testName);
              testCategory.Save();

              //Act
              testCategory.AddTask(testTask);
              testCategory.Delete();

              List<Category> resultTaskCategories = testTask.GetCategories();
              List<Category> testTaskCategories = new List<Category> {};
              List<Task> resultsTasks= Task.GetAll();
              List<Task> testTasks= new List<Task>{testTask};

              //Assert
              Assert.Equal(testTaskCategories, resultTaskCategories);
              Assert.Equal(testTasks, resultsTasks);
        }
Ejemplo n.º 58
0
        public void Test_FindFindsTaskInDatabase()
        {
            //Arrange
              Task testTask = new Task("Mow the lawn", new DateTime(2016, 2, 2), false);
              testTask.Save();

              //Act
              Task result = Task.Find(testTask.GetId());

              //Assert
              Assert.Equal(testTask, result);
        }
Ejemplo n.º 59
0
        public void Test_GetTasks_ReturnsAllCategoryTasks()
        {
            //Arrange
              Category testCategory = new Category("Household chores");
              testCategory.Save();

              Task testTask1 = new Task("Mow the lawn", false);
              testTask1.Save();

              Task testTask2 = new Task("Buy plane ticket", false);
              testTask2.Save();

              //Act
              testCategory.AddTask(testTask1);
              List<Task> savedTasks = testCategory.GetTasks();
              List<Task> testList = new List<Task> {testTask1};

              //Assert
              Assert.Equal(testList, savedTasks);
        }
        public void Test_GetTasks_ReturnAllCategoryTasks()
        {
            Category testCategory = new Category("Househould chores");
              testCategory.Save();
              DateTime testTime = new DateTime(2016, 1, 1);

              Task testTask1= new Task("Mow the lawn",testTime);
              testTask1.Save();

              Task testTask2 = new Task("Buy plane ticket",testTime);
              testTask2.Save();

              testCategory.AddTask(testTask1);
              List<Task> savedTasks = testCategory.GetTasks();
              List<Task> testList= new List<Task>{testTask1};
              Assert.Equal(testList,savedTasks);
        }