本文整理汇总了C#中ToDoList.Task.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# Task.Delete方法的具体用法?C# Task.Delete怎么用?C# Task.Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ToDoList.Task
的用法示例。
在下文中一共展示了Task.Delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: Test_Delete_DeletesTaskFromDatabase
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);
}