• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ToDoList.Task类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ToDoList.Task的典型用法代码示例。如果您正苦于以下问题:C# Task类的具体用法?C# Task怎么用?C# Task使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Task类属于ToDoList命名空间,在下文中一共展示了Task类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Test_Delete_DeletesCategoryFromDatabase

        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);
        }
开发者ID:Rouz1130,项目名称:Delete-Update-Category,代码行数:31,代码来源:CategoryTest.cs


示例2: Find

        public static Task Find(int id)
        {
            SqlConnection conn = DB.Connection();
            conn.Open();

            SqlCommand cmd = new SqlCommand("SELECT * FROM tasks WHERE id = @TaskId;", conn);
            SqlParameter taskIdParameter = new SqlParameter();
            taskIdParameter.ParameterName = "@TaskId";
            taskIdParameter.Value = id.ToString();
            cmd.Parameters.Add(taskIdParameter);
            SqlDataReader rdr = cmd.ExecuteReader();

            int foundTaskId = 0;
            string foundTaskDescription = null;
            while(rdr.Read())
            {
              foundTaskId = rdr.GetInt32(0);
              foundTaskDescription = rdr.GetString(1);
            }
            Task foundTask = new Task(foundTaskDescription, foundTaskId);

            if (rdr != null)
            {
              rdr.Close();
            }
            if (conn != null)
            {
              conn.Close();
            }

            return foundTask;
        }
开发者ID:Rouz1130,项目名称:Todo-SQL,代码行数:32,代码来源:task.cs


示例3: GetAll

    public static List<Task> GetAll()
    {
      List<Task> AllTasks = new List<Task>{};

      SqlConnection conn = DB.Connection();
      SqlDataReader rdr = null;
      conn.Open();

      SqlCommand cmd = new SqlCommand("SELECT * FROM tasks", conn);
      rdr = cmd.ExecuteReader();

      while(rdr.Read())
      {
        int taskId = rdr.GetInt32(0);
        string taskDescription = rdr.GetString(1);
        int taskCategoryId = rdr.GetInt32(2);
        Task newTask = new Task(taskDescription, taskCategoryId, taskId);
        AllTasks.Add(newTask);
      }
      if (rdr != null)
      {
        rdr.Close();
      }
      if (conn != null)
      {
        conn.Close();
      }
      return AllTasks;
    }
开发者ID:jmk22,项目名称:todo_categories_databases_CRUD,代码行数:29,代码来源:Task.cs


示例4: HomeModule

 public HomeModule()
 {
     Get["/"] = _ => {
         return View["index.cshtml"];
     };
     Get["/tasks"] = _ => {
       var AllTasks = Task.All();
       return View["tasks.cshtml", AllTasks];
     };
     Get["/tasks/new"] = _ => {
       return View["task_form.cshtml"];
     };
     Post["/tasks"] = _ => {
       var NewTask = new Task(Request.Form["new-task"]);
       var AllTasks = Task.All();
       return View["tasks.cshtml", AllTasks];
     };
     Get["/tasks/{id}"] = parameters => {
       var task = Task.Find(parameters.id);
       return View["/task.cshtml", task];
     };
     // Post["/tasks/clear"] = _ => {
     //   Task.DeleteAll();
     //   return View["tasks_cleared.cshtml"];
     // };
 }
开发者ID:jmk22,项目名称:todolist_REST_findsave,代码行数:26,代码来源:HomeModule.cs


示例5: HomeModule

        public HomeModule()
        {
            Get["/"] = _ => {
                return View["index.cshtml"];
            };
            Get["/tasks"] = _ => {
              var AllTasks = Task.All();
              return View["tasks.cshtml", AllTasks];
            };
            Get["/tasks/new"] = _ => {
              return View["task_form.cshtml"];
            };
            Get["/tasks/{id}"] = parameters => {
              var SelectedTask = Task.Find(parameters.id);
              return View["/task.cshtml", SelectedTask];
            };
            Get["/categories"] = _ => {
              var AllCategories = Category.All();
              return View["categories.cshtml", AllCategories];
            };
            Get["/categories/new"] = _ => {
              return View["category_form.cshtml"];
            };
            Post["/categories"] = _ => {
              var NewCategory = new Category(Request.Form["category-name"]);
              var AllCategories = Category.All();
              return View["categories.cshtml", AllCategories];
            };
            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["/categories/{id}/tasks/new"] = parameters => {
              Dictionary<string, object> model = new Dictionary<string, object>();
              Category SelectedCategory = Category.Find(parameters.id);
              List<Task> AllTasks = SelectedCategory.GetTasks();
              model.Add("category", SelectedCategory);
              model.Add("tasks", AllTasks);
              return View["/category_tasks_form.cshtml", model];
            };
            Post["/tasks"] = _ => {
              Dictionary<string, object> model = new Dictionary<string, object>();
              Category SelectedCategory = Category.Find(Request.Form["category-id"]);
              List<Task> CategoryTasks = SelectedCategory.GetTasks();
              string TaskDescription = Request.Form["task-description"];
              Task NewTask = new Task(TaskDescription);
              CategoryTasks.Add(NewTask);

              model.Add("tasks", CategoryTasks);
              model.Add("category", SelectedCategory);

              return View["/category.cshtml", model];
            };
        }
开发者ID:jmk22,项目名称:nancy_todolist_categories_complexobjectsinobjects,代码行数:58,代码来源:HomeModule.cs


示例6: Test_EqualOverrideTrueForSameDescription

    public void Test_EqualOverrideTrueForSameDescription()
    {
      //Arrange, Act
      Task firstTask = new Task("Mow the lawn");
      Task secondTask = new Task("Mow the lawn");

      //Assert
      Assert.Equal(firstTask, secondTask);
    }
开发者ID:jtf86,项目名称:Final-Nancy-ToDo,代码行数:9,代码来源:TaskTest.cs


示例7: Test_Equal_ReturnsTrueIfDescriptionsAreTheSame

        public void Test_Equal_ReturnsTrueIfDescriptionsAreTheSame()
        {
            //Arrange, Act
              Task firstTask = new Task("Mow the lawn");
              Task secondTask = new Task("Mow the lawn");

              //Assert
              Assert.Equal(firstTask, secondTask);
        }
开发者ID:Rouz1130,项目名称:Todo-SQL,代码行数:9,代码来源:TaskTest.cs


示例8: Test_Equal_ReturnsTrueIfDescriptionsAreTheSame

        public void Test_Equal_ReturnsTrueIfDescriptionsAreTheSame()
        {
            //Arrange, Act
              DateTime fakeTime = new DateTime(2016, 1, 1);
              Task firstTask = new Task("Mow the lawn", 1, fakeTime);
              Task secondTask = new Task("Mow the lawn", 1, fakeTime);

              //Assert
              Assert.Equal(firstTask, secondTask);
        }
开发者ID:Rouz1130,项目名称:Delete-Update-Category,代码行数:10,代码来源:TaskTest.cs


示例9: Test_FindFindsTaskInDatabase

    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);
    }
开发者ID:jtf86,项目名称:Final-Nancy-ToDo,代码行数:12,代码来源:TaskTest.cs


示例10: Test_Save

    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);
    }
开发者ID:jtf86,项目名称:Final-Nancy-ToDo,代码行数:13,代码来源:TaskTest.cs


示例11: Test_Find_FindsTaskInDatabase

        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);
        }
开发者ID:Rouz1130,项目名称:Delete-Update-Category,代码行数:13,代码来源:TaskTest.cs


示例12: 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];
            };

            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];
            };
        }
开发者ID:jtf86,项目名称:todo_rzor_databases_12m,代码行数:51,代码来源:HomeModule.cs


示例13: Test_SaveAssignsIdToObject

    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);
    }
开发者ID:jtf86,项目名称:Final-Nancy-ToDo,代码行数:15,代码来源:TaskTest.cs


示例14: Test_Complete_CompletesTaskWhenDone

        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);
        }
开发者ID:CharlesEwel,项目名称:csharp-todo-week4,代码行数:15,代码来源:TaskTest.cs


示例15: Test_Save_AssignsIdToObject

        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);
        }
开发者ID:Rouz1130,项目名称:Delete-Update-Category,代码行数:16,代码来源:TaskTest.cs


示例16: Test_AddCategory_AddsCategoryToTask

        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);
        }
开发者ID:nlarion,项目名称:ToDoCsharp,代码行数:18,代码来源:TaskTest.cs


示例17: Test18_GetCategories_ReturnsAllTaskCategories

        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);
        }
开发者ID:Rick1970,项目名称:todo-with-join-statement,代码行数:19,代码来源:TaskTest.cs


示例18: HomeModule

 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"];
     };
 }
开发者ID:jmk22,项目名称:todolist-razor,代码行数:19,代码来源:HomeModule.cs


示例19: 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


示例20: Test_Delete_DeletesTaskAssociationsFromDatabase

        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);
        }
开发者ID:nlarion,项目名称:ToDoCsharp,代码行数:20,代码来源:TaskTest.cs



注:本文中的ToDoList.Task类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Controls.EventArgs类代码示例发布时间:2022-05-26
下一篇:
C# ToDoList.Category类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap