本文整理汇总了C#中System.Threading.Task.Complete方法的典型用法代码示例。如果您正苦于以下问题:C# Task.Complete方法的具体用法?C# Task.Complete怎么用?C# Task.Complete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Threading.Task
的用法示例。
在下文中一共展示了Task.Complete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestInProgressToCompletedActualOwner
public void TestInProgressToCompletedActualOwner()
{
IdentityId actualId = new IdentityId();
ILoggingService loggingService = SetupLoggerMock(new List<TaskHistoryEvent>());
Task task = new Task(
new TaskId(), TaskStatus.InProgress, string.Empty,
string.Empty, Priority.Normal, false,
DateTime.UtcNow, new IdentityId().GetIdentity(),
DateTime.UtcNow, null, actualId.GetIdentity())
{
LoggingService = loggingService
};
Assert.IsNotNull(task);
IPrincipal actualOwner = new ClaimsPrincipal(actualId.GetIdentity());
Thread.CurrentPrincipal = actualOwner;
task.Complete();
Assert.AreEqual(TaskStatus.Completed, task.Status);
Assert.AreEqual(actualId.GetIdentity(), task.ActualOwner);
Assert.IsNotNull(task.History);
Assert.AreEqual(1, task.History.Count());
TaskHistoryEvent history = task.History.ElementAt(0);
Assert.IsNotNull(history);
Assert.AreEqual(TaskStatus.InProgress, history.OldStatus);
Assert.AreEqual(TaskStatus.Completed, history.NewStatus);
Assert.AreEqual(actualId, history.UserId);
}