public void CancellationTest() { var cancelationToken = new CancellationTokenSource(); var actor = new ActorB(cancelationToken.Token); var tasks = new List <Task>(100000); for (var j = 0; j < 100000; j++) { tasks.Add(actor.Add(1)); tasks.Add(actor.Verify(j)); } cancelationToken.Cancel(); AssertException(typeof(AggregateException), typeof(InvalidOperationException), () => actor.GetCounter()); AssertException(typeof(AggregateException), typeof(TaskCanceledException), () => Task.WaitAll(tasks.ToArray())); }
public void ActorOperationsInOrder() { var actor = new ActorB(); var tasks = new List <Task>(100000); for (var j = 0; j < 100000; j++) { tasks.Add(actor.Add(1)); tasks.Add(actor.Verify(j)); } Task.WaitAll(tasks.ToArray()); var t = actor.GetCounter(); t.Wait(5000); Assert.AreEqual(100000, t.Result); }