本文整理汇总了C#中Task.Merge方法的典型用法代码示例。如果您正苦于以下问题:C# Task.Merge方法的具体用法?C# Task.Merge怎么用?C# Task.Merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Task
的用法示例。
在下文中一共展示了Task.Merge方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestMerge_FullMerge
public void TestMerge_FullMerge()
{
//Arrange
Task mainTask = new Task()
{
Complete = false,
Description = "mainDesc",
Due = new DateTime(2010, 11, 1),
Id = new Guid("00000000-0000-0000-0000-000000000003"),
Name = "mainName",
TaskListId = new Guid("00000000-0000-0000-0000-000000000001")
};
Task mergeTask = new Task()
{
Complete = true,
Description = "mergeDesc",
Due = new DateTime(2010, 12, 2),
Id = new Guid("00000000-0000-0000-0000-000000000004"),
Name = "mergeName",
TaskListId = new Guid("00000000-0000-0000-0000-000000000002")
};
//Act
mainTask.Merge(mergeTask);
//Assert
Assert.AreEqual(true, mainTask.Complete);
Assert.AreEqual("mergeDesc", mainTask.Description);
Assert.AreEqual(new DateTime(2010, 12, 2), mainTask.Due);
Assert.AreEqual(new Guid("00000000-0000-0000-0000-000000000003"), mainTask.Id); // Should not change
Assert.AreEqual("mergeName", mainTask.Name);
Assert.AreEqual(new Guid("00000000-0000-0000-0000-000000000002"), mainTask.TaskListId);
}
示例2: TestMerge_EmptyMerge
public void TestMerge_EmptyMerge()
{
//Arrange
Task mainTask = new Task()
{
Complete = true,
Description = "mainDesc",
Due = new DateTime(2010, 11, 1),
Id = new Guid("00000000-0000-0000-0000-000000000003"),
Name = "mainName",
TaskListId = new Guid("00000000-0000-0000-0000-000000000001")
};
Task mergeTask = new Task()
{
};
//Act
mainTask.Merge(mergeTask);
//Assert
Assert.AreEqual(false, mainTask.Complete); //bool is not nullable so default will be false
Assert.AreEqual("mainDesc", mainTask.Description);
Assert.AreEqual(new DateTime(2010, 11, 1), mainTask.Due);
Assert.AreEqual(new Guid("00000000-0000-0000-0000-000000000003"), mainTask.Id); // Should not change
Assert.AreEqual("mainName", mainTask.Name);
Assert.AreEqual(new Guid("00000000-0000-0000-0000-000000000001"), mainTask.TaskListId);
}