本文整理匯總了C#中ToDoList.Category.Delete方法的典型用法代碼示例。如果您正苦於以下問題:C# Category.Delete方法的具體用法?C# Category.Delete怎麽用?C# Category.Delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ToDoList.Category
的用法示例。
在下文中一共展示了Category.Delete方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
}
示例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);
}
示例3: 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);
}
示例4: T8_Delete_DeletesCategoryFromDatabase
public void T8_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();
//Act
testCategory1.Delete();
List<Category> resultCategories = Category.GetAll();
List<Category> testCategoryList = new List<Category> {testCategory2};
//Assert
Assert.Equal(testCategoryList, resultCategories);
}