Mercurial > pub > ImplabNet
comparison Implab.Test/AsyncTests.cs @ 145:706fccb85524 v2
RC: cancellation support for promises + tests
author | cin |
---|---|
date | Sun, 08 Mar 2015 02:52:27 +0300 |
parents | f75cfa58e3d4 |
children | eb793fbbe4ea |
comparison
equal
deleted
inserted
replaced
144:8c0b95069066 | 145:706fccb85524 |
---|---|
5 | 5 |
6 #if MONO | 6 #if MONO |
7 | 7 |
8 using NUnit.Framework; | 8 using NUnit.Framework; |
9 using TestClassAttribute = NUnit.Framework.TestFixtureAttribute; | 9 using TestClassAttribute = NUnit.Framework.TestFixtureAttribute; |
10 using TestMethod = NUnit.Framework.TestAttribute; | 10 using TestMethodAttribute = NUnit.Framework.TestAttribute; |
11 | 11 |
12 #else | 12 #else |
13 | 13 |
14 using Microsoft.VisualStudio.TestTools.UnitTesting; | 14 using Microsoft.VisualStudio.TestTools.UnitTesting; |
15 | 15 |
49 } | 49 } |
50 | 50 |
51 [TestMethod] | 51 [TestMethod] |
52 public void CancelExceptionTest() { | 52 public void CancelExceptionTest() { |
53 var p = new Promise<bool>(); | 53 var p = new Promise<bool>(); |
54 p.Cancel(); | 54 p.CancelOperation(null); |
55 | 55 |
56 var p2 = p.Then(x => x, null, reason => { | 56 var p2 = p.Then(x => x, null, reason => { |
57 throw new ApplicationException("CANCELLED"); | 57 throw new ApplicationException("CANCELLED"); |
58 }); | 58 }); |
59 | 59 |
67 } | 67 } |
68 | 68 |
69 [TestMethod] | 69 [TestMethod] |
70 public void ContinueOnCancelTest() { | 70 public void ContinueOnCancelTest() { |
71 var p = new Promise<bool>(); | 71 var p = new Promise<bool>(); |
72 p.Cancel(); | 72 p.CancelOperation(null); |
73 | 73 |
74 var p2 = p | 74 var p2 = p |
75 .Then<bool>(x => x, null, reason => { | 75 .Then(x => x, null, reason => { |
76 throw new ApplicationException("CANCELLED"); | 76 throw new ApplicationException("CANCELLED"); |
77 }) | 77 }) |
78 .Then(x => x, e => true); | 78 .Then(x => x, e => true); |
79 | 79 |
80 Assert.AreEqual(true, p2.Join()); | 80 Assert.AreEqual(true, p2.Join()); |