~ubuntu-branches/debian/sid/nunit/sid

« back to all changes in this revision

Viewing changes to src/NUnitFramework/tests-net45/AfterDelayedTests.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2014-09-16 13:43:36 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20140916134336-kjxz48tty6lx2ja5
Tags: 2.6.3+dfsg-1
* [c7bd1b5] Imported Upstream version 2.6.3+dfsg
* [bcb4bf8] Move nunit-console-runner to GAC-installed libnunit2.6, 
  don't treat it as a private lib. This lib is signed, and treated 
  as a GAC lib by consumers such as MonoDevelop.
* [7f08e99] Bump version to 2.6.3 as required
* [84535eb] Refreshed patches
* [8479f61] Split package up into per-assembly packages. This makes 
  ABI tracking easier in the future, as we can meaningfully have GAC 
  policy for cases where ABI isn't truly bumped, and no policy for 
  cases where it is. For example, if nunit.framework bumps ABI but 
  nunit.core does not, previously we would need to rebuild everything 
  using NUnit, but under the new split packaging, that rebuild would 
  not be needed for apps only using nunit.core.
* [17a7dc7] Add missing nunit.mocks.dll to nunit.pc

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#if NET_3_5 || NET_4_0 || NET_4_5
 
2
using System;
 
3
using System.Threading.Tasks;
 
4
using NUnit.Framework;
 
5
using NUnit.Framework.Constraints;
 
6
 
 
7
namespace nunit.framework.tests.net45
 
8
{
 
9
        [TestFixture]
 
10
        public class AfterDelayedTests
 
11
        {
 
12
                [Test]
 
13
                public void ConstraintSuccess()
 
14
                {
 
15
                        Assert.IsTrue(new DelayedConstraint(new EqualConstraint(1), 100)
 
16
                                .Matches(async () => await One()));
 
17
                }
 
18
 
 
19
                [Test]
 
20
                public void ConstraintFailure()
 
21
                {
 
22
                        Assert.IsFalse(new DelayedConstraint(new EqualConstraint(2), 100)
 
23
                                .Matches(async () => await One()));
 
24
                }
 
25
 
 
26
                [Test]
 
27
                public void ConstraintError()
 
28
                {
 
29
                        Assert.Throws<InvalidOperationException>(() => 
 
30
                                new DelayedConstraint(new EqualConstraint(1), 100).Matches(async () => await Throw()));
 
31
                }
 
32
 
 
33
                [Test]
 
34
                public void ConstraintVoidDelegateFailureAsDelegateIsNotCalled()
 
35
                {
 
36
                        Assert.IsFalse(new DelayedConstraint(new EqualConstraint(1), 100)
 
37
                                .Matches(new TestDelegate(async () => { await One(); })));
 
38
                }
 
39
 
 
40
                [Test]
 
41
                public void ConstraintVoidDelegateExceptionIsFailureAsDelegateIsNotCalled()
 
42
                {
 
43
                        Assert.IsFalse(new DelayedConstraint(new EqualConstraint(1), 100)
 
44
                                .Matches(new TestDelegate(async () => { await Throw(); })));
 
45
                }
 
46
 
 
47
                [Test]
 
48
                public void SyntaxSuccess()
 
49
                {
 
50
                        Assert.That(async () => await One(), Is.EqualTo(1).After(100));
 
51
                }
 
52
 
 
53
 
 
54
                [Test]
 
55
                public void SyntaxFailure()
 
56
                {
 
57
                        Assert.Throws<AssertionException>(() =>
 
58
                                Assert.That(async () => await One(), Is.EqualTo(2).After(100)));
 
59
                }
 
60
 
 
61
                [Test]
 
62
                public void SyntaxError()
 
63
                {
 
64
                        Assert.Throws<InvalidOperationException>(() =>
 
65
                                Assert.That(async () => await Throw(), Is.EqualTo(1).After(100)));
 
66
                }
 
67
 
 
68
                [Test]
 
69
                public void SyntaxVoidDelegateExceptionIsFailureAsCodeIsNotCalled()
 
70
                {
 
71
                        Assert.Throws<AssertionException>(() =>
 
72
                                Assert.That(new TestDelegate(async () => await Throw()), Is.EqualTo(1).After(100)));
 
73
                }
 
74
 
 
75
                private static async Task<int> One()
 
76
                {
 
77
                        return await Task.Run(() => 1);
 
78
                }
 
79
 
 
80
                private static async Task Throw()
 
81
                {
 
82
                        await One();
 
83
                        throw new InvalidOperationException();
 
84
                }
 
85
        }
 
86
}
 
87
#endif
 
 
b'\\ No newline at end of file'