當前位置: 首頁>>代碼示例>>C#>>正文


C# Category.AddTask方法代碼示例

本文整理匯總了C#中ToDoList.Category.AddTask方法的典型用法代碼示例。如果您正苦於以下問題:C# Category.AddTask方法的具體用法?C# Category.AddTask怎麽用?C# Category.AddTask使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ToDoList.Category的用法示例。


在下文中一共展示了Category.AddTask方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Test_AddTask_AddsTaskToCategory

        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);
        }
開發者ID:Rouz1130,項目名稱:todo_manyTomany,代碼行數:22,代碼來源:CategoryTest.cs

示例2: Test_Delete_DeletesCategoryAssociationsFromDatabase

        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);
        }
開發者ID:Rouz1130,項目名稱:todo_manyTomany,代碼行數:20,代碼來源:CategoryTest.cs

示例3: Test_GetTasks_ReturnAllCategoryTasks

        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);
        }
開發者ID:Rick1970,項目名稱:todo-with-join-statement,代碼行數:17,代碼來源:CategoryTest.cs

示例4: Test_Delete_DeletesCategoryAssociationsFromDatabase

        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);
        }
開發者ID:Rick1970,項目名稱:todo-with-join-statement,代碼行數:25,代碼來源:CategoryTest.cs

示例5: HomeModule

        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"]);
              newTask.Save();
              Category taskCategory = new Category(Request.Form["category-id"]);
              Console.WriteLine("taskCategory: {0}", taskCategory.GetName());
              taskCategory.AddTask(newTask);
              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];
            };

            //View specific task
            Get["tasks/{id}"] = parameters => {
              Dictionary<string, object> model = new Dictionary<string, object>();
              Task SelectedTask = Task.Find(parameters.id);
              return View["task.cshtml", SelectedTask];
            };

            //Edit specific category
            Get["category/edit/{id}"] = parameters => {
              Category SelectedCategory = Category.Find(parameters.id);
              return View["category_edit.cshtml", SelectedCategory];
            };
            Post["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];
            };
            Post["category/delete/{id}"] = parameters => {
              Category SelectedCategory = Category.Find(parameters.id);
              SelectedCategory.Delete();
              return View["success.cshtml"];
            };
        }
開發者ID:jmk22,項目名稱:todo_categories_databasesextended,代碼行數:91,代碼來源:HomeModule.cs

示例6: Test_GetTasks_ReturnsAllCategoryTasks

        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);
        }
開發者ID:Rouz1130,項目名稱:todo_manyTomany,代碼行數:20,代碼來源:CategoryTest.cs

示例7: Test_GetTasks_RetrievesAllTasksWithCategory

 public void Test_GetTasks_RetrievesAllTasksWithCategory()
 {
     Category testCategory = new Category("Household chores");
       testCategory.Save();
       Task firstTask = new Task("Mow the lawn", new DateTime(2016,2,2), false);
       firstTask.Save();
       Task secondTask = new Task("Do the dishes",new DateTime(2016,2,2), false);
       secondTask.Save();
       testCategory.AddTask(firstTask);
       List<Task> testTaskList = new List<Task> {firstTask};
       List<Task> resultTaskList = testCategory.GetTasks();
       Assert.Equal(testTaskList, resultTaskList);
 }
開發者ID:nlarion,項目名稱:ToDoCsharp,代碼行數:13,代碼來源:CategoryTest.cs


注:本文中的ToDoList.Category.AddTask方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。