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