summaryrefslogtreecommitdiff
path: root/external/rx/Ix/NET/Tests/Tests.cs
blob: c313f4b8fd71e97c61d2a8dc242fe8711b848245 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
#if NUNIT
using NUnit.Framework;
using TestClassAttribute = NUnit.Framework.TestFixtureAttribute;
using TestMethodAttribute = NUnit.Framework.TestAttribute;
using TestInitializeAttribute = NUnit.Framework.SetUpAttribute;
#else
using Microsoft.VisualStudio.TestTools.UnitTesting;
#endif

namespace Tests
{
    [TestClass]
    public partial class Tests
    {
        public void AssertThrows<E>(Action a)
            where E : Exception
        {
            try
            {
                a();
                Assert.Fail();
            }
            catch (E)
            {
            }
        }

        public void AssertThrows<E>(Action a, Func<E, bool> assert)
            where E : Exception
        {
            try
            {
                a();
                Assert.Fail();
            }
            catch (E e)
            {
                Assert.IsTrue(assert(e));
            }
        }

        public void NoNext<T>(IEnumerator<T> e)
        {
            Assert.IsFalse(e.MoveNext());
        }

        public void HasNext<T>(IEnumerator<T> e, T value)
        {
            Assert.IsTrue(e.MoveNext());
            Assert.AreEqual(value, e.Current);
        }
    }
}