comparison Implab.Test/RunnableComponentTests.cs @ 188:3071220371f8 ref20160224

Updated VS project
author cin
date Fri, 22 Apr 2016 12:59:31 +0300
parents 822aab37b107
children d45bdf510514
comparison
equal deleted inserted replaced
187:dd4a3590f9c6 188:3071220371f8
7 #if MONO 7 #if MONO
8 8
9 using NUnit.Framework; 9 using NUnit.Framework;
10 using TestClassAttribute = NUnit.Framework.TestFixtureAttribute; 10 using TestClassAttribute = NUnit.Framework.TestFixtureAttribute;
11 using TestMethodAttribute = NUnit.Framework.TestAttribute; 11 using TestMethodAttribute = NUnit.Framework.TestAttribute;
12 12 using AssertFailedException = NUnit.Framework.AssertionException;
13 #else 13 #else
14 14
15 using Microsoft.VisualStudio.TestTools.UnitTesting; 15 using Microsoft.VisualStudio.TestTools.UnitTesting;
16 16
17 #endif 17 #endif
22 22
23 static void ShouldThrow(Action action) { 23 static void ShouldThrow(Action action) {
24 try { 24 try {
25 action(); 25 action();
26 Assert.Fail(); 26 Assert.Fail();
27 } catch(AssertionException) { 27 } catch (AssertFailedException) {
28 throw; 28 throw;
29 } catch { 29 } catch {
30 } 30 }
31 } 31 }
32 32
129 var p = comp.Start(); 129 var p = comp.Start();
130 Assert.AreEqual(ExecutionState.Starting, comp.State); 130 Assert.AreEqual(ExecutionState.Starting, comp.State);
131 p.Cancel(); 131 p.Cancel();
132 ShouldThrow(() => p.Join(1000)); 132 ShouldThrow(() => p.Join(1000));
133 Assert.AreEqual(ExecutionState.Failed, comp.State); 133 Assert.AreEqual(ExecutionState.Failed, comp.State);
134 Assert.IsInstanceOfType(typeof(OperationCanceledException), comp.LastError); 134
135 Assert.IsInstanceOfType(comp.LastError, typeof(OperationCanceledException));
135 136
136 comp.Dispose(); 137 comp.Dispose();
137 } 138 }
138 139
139 [TestMethod] 140 [TestMethod]
182 var p = comp.Stop(); 183 var p = comp.Stop();
183 Assert.AreEqual(ExecutionState.Stopping, comp.State); 184 Assert.AreEqual(ExecutionState.Stopping, comp.State);
184 p.Cancel(); 185 p.Cancel();
185 ShouldThrow(() => p.Join(1000)); 186 ShouldThrow(() => p.Join(1000));
186 Assert.AreEqual(ExecutionState.Failed, comp.State); 187 Assert.AreEqual(ExecutionState.Failed, comp.State);
187 Assert.IsInstanceOfType(typeof(OperationCanceledException), comp.LastError); 188 Assert.IsInstanceOfType(comp.LastError, typeof(OperationCanceledException));
188 189
189 comp.Dispose(); 190 comp.Dispose();
190 } 191 }
191 192
192 } 193 }