Debian Codegraph @

external/rx/Ix/NET/Tests/Tests.cs

raw
1 // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
2 using System;
3 using System.Text;
4 using System.Collections.Generic;
5 using System.Linq;
6 #if NUNIT
7 using NUnit.Framework;
8 using TestClassAttribute = NUnit.Framework.TestFixtureAttribute;
9 using TestMethodAttribute = NUnit.Framework.TestAttribute;
10 using TestInitializeAttribute = NUnit.Framework.SetUpAttribute;
11 #else
12 using Microsoft.VisualStudio.TestTools.UnitTesting;
13 #endif
14
15 namespace Tests
16 {
17 [TestClass]
18 public partial class Tests
19 {
20 public void AssertThrows<E>(Action a)
21 where E : Exception
22 {
23 try
24 {
25 a();
26 Assert.Fail();
27 }
28 catch (E)
29 {
30 }
31 }
32
33 public void AssertThrows<E>(Action a, Func<E, bool> assert)
34 where E : Exception
35 {
36 try
37 {
38 a();
39 Assert.Fail();
40 }
41 catch (E e)
42 {
43 Assert.IsTrue(assert(e));
44 }
45 }
46
47 public void NoNext<T>(IEnumerator<T> e)
48 {
49 Assert.IsFalse(e.MoveNext());
50 }
51
52 public void HasNext<T>(IEnumerator<T> e, T value)
53 {
54 Assert.IsTrue(e.MoveNext());
55 Assert.AreEqual(value, e.Current);
56 }
57 }
58 }