Mercurial > pub > ImplabNet
diff Implab.Test/AsyncTests.cs @ 149:eb793fbbe4ea v2
fixed promises cancellation
author | cin |
---|---|
date | Wed, 06 May 2015 17:11:27 +0300 |
parents | 706fccb85524 |
children | ec91a6dfa5b3 |
line wrap: on
line diff
--- a/Implab.Test/AsyncTests.cs Wed Apr 15 07:30:20 2015 +0300 +++ b/Implab.Test/AsyncTests.cs Wed May 06 17:11:27 2015 +0300 @@ -746,33 +746,31 @@ public void ChainedCancel2Test() { // при отмене цепочки обещаний, вложенные операции также должны отменяться var pSurvive = new Promise<bool>(); - var hemStarted = new ManualResetEvent(false); + var hemStarted = new Signal(); var p = PromiseHelper .Sleep(1, "Hi, HAL!") - .Chain(x => { + .Chain(() => { hemStarted.Set(); // запускаем две асинхронные операции var result = PromiseHelper - .Sleep(100000000, "HEM ENABLED!!!") - .Then(s => { - pSurvive.Resolve(false); - return s; - }); + .Sleep(2000, "HEM ENABLED!!!") + .Then(() => pSurvive.Resolve(false)); result .On(() => pSurvive.Resolve(true), PromiseEventType.Cancelled); - + return result; }); - hemStarted.WaitOne(); + hemStarted.Wait(); p.Cancel(); try { p.Join(); + Assert.Fail(); } catch (OperationCanceledException) { - Assert.IsTrue(pSurvive.Join()); } + Assert.IsTrue(pSurvive.Join()); } [TestMethod]