public void Test_GetCompleted_ReturnsIfComplete_true() { //Arrange Task testTask = new Task("Mow the lawn", "01-02-2017", false); testTask.Save(); //Act bool testResult = testTask.GetCompleted(); bool result = false; Assert.Equal(testResult, result); }
public override bool Equals(System.Object otherTask) { if (!(otherTask is Task)) { return(false); } else { Task newTask = (Task)otherTask; bool idEquality = (this.GetId() == newTask.GetId()); bool descriptionEquality = (this.GetDescription() == newTask.GetDescription()); bool completedEquality = (this.GetCompleted() == newTask.GetCompleted()); return(idEquality && descriptionEquality && completedEquality); } }
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); }
public HomeModule() { Get["/"] = _ => { return(View["index.cshtml"]); }; Get["/tasks"] = _ => { List <Task> AllTasks = Task.GetAll(); return(View["tasks.cshtml", AllTasks]); }; Get["/tasks/completed"] = _ => { List <Task> CompletedTasks = Task.GetCompleted(); return(View["tasks_completed.cshtml", CompletedTasks]); }; Get["/categories"] = _ => { List <Category> AllCategories = Category.GetAll(); return(View["categories.cshtml", AllCategories]); }; //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"]); }; //Create a new task Get["/tasks/new"] = _ => { return(View["tasks_form.cshtml"]); }; Post["/tasks/new"] = _ => { Task newTask = new Task(Request.Form["task-description"], Request.Form["completed"]); newTask.Save(); return(View["success.cshtml"]); }; Post["/tasks/delete"] = _ => { Task.DeleteAll(); return(View["cleared.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"]); }; Get["tasks/{id}/edit"] = parameters => { Task SelectedTask = Task.Find(parameters.id); return(View["task_update_form.cshtml", SelectedTask]); }; Patch["tasks/{id}/updated"] = parameters => { Task SelectedTask = Task.Find(parameters.id); SelectedTask.UpdateProperties(Request.Form["new-task-description"], Request.Form["new-completed"]); return(View["success.cshtml", SelectedTask]); }; Post["/tasks/delete"] = _ => { Task.DeleteAll(); return(View["success.cshtml"]); }; }