~ubuntu-branches/ubuntu/utopic/monodevelop/utopic

« back to all changes in this revision

Viewing changes to external/guiunit/src/tests/Syntax/OperatorOverrides.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-10-10 14:50:04 UTC
  • mfrom: (10.3.4)
  • Revision ID: package-import@ubuntu.com-20131010145004-80l130sny21b17sb
Tags: 4.0.12+dfsg-1
* [5dcb6e1] Fix debian/watch for new source tarball name format
* [5c68cb5] Refresh list of files removed by get-orig-source to 
  reflect 4.0.12
* [96d60a0] Imported Upstream version 4.0.12+dfsg
* [b989752] Refresh debian/patches/no_appmenu to ensure it applies
* [2a4c351] Ensure every assembly in external/ is cleaned properly
* [92762f7] Add more excluded Mac-specific modulerefs
* [bc698ba] Add symlinks to NUnit assemblies (Closes: #714246)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// ***********************************************************************
 
2
// Copyright (c) 2009 Charlie Poole
 
3
//
 
4
// Permission is hereby granted, free of charge, to any person obtaining
 
5
// a copy of this software and associated documentation files (the
 
6
// "Software"), to deal in the Software without restriction, including
 
7
// without limitation the rights to use, copy, modify, merge, publish,
 
8
// distribute, sublicense, and/or sell copies of the Software, and to
 
9
// permit persons to whom the Software is furnished to do so, subject to
 
10
// the following conditions:
 
11
// 
 
12
// The above copyright notice and this permission notice shall be
 
13
// included in all copies or substantial portions of the Software.
 
14
// 
 
15
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 
16
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
17
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 
18
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 
19
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 
20
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 
21
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
22
// ***********************************************************************
 
23
 
 
24
using System;
 
25
using NUnit.Framework.Constraints;
 
26
 
 
27
namespace NUnit.Framework.Syntax
 
28
{
 
29
    public class NotOperatorOverride : SyntaxTest
 
30
    {
 
31
        [SetUp]
 
32
        public void SetUp()
 
33
        {
 
34
            parseTree = "<not <null>>";
 
35
            staticSyntax = !Is.Null;
 
36
            inheritedSyntax = !Helper().Null;
 
37
            builderSyntax = !Builder().Null;
 
38
        }
 
39
 
 
40
        [Test]
 
41
        public void NotOperatorCanApplyToResolvableConstraintExpression()
 
42
        {
 
43
            Assert.That(GetType(), !Has.Attribute(typeof(DescriptionAttribute)));
 
44
        }
 
45
    }
 
46
 
 
47
    [TestFixture, Description("Test")]
 
48
    public class AndOperatorOverride : SyntaxTest
 
49
    {
 
50
        [SetUp]
 
51
        public void SetUp()
 
52
        {
 
53
            parseTree = "<and <greaterthan 5> <lessthan 10>>";
 
54
            staticSyntax = Is.GreaterThan(5) & Is.LessThan(10);
 
55
            inheritedSyntax = Helper().GreaterThan(5) & Is.LessThan(10);
 
56
            builderSyntax = Builder().GreaterThan(5) & Builder().LessThan(10);
 
57
        }
 
58
 
 
59
        [Test]
 
60
        public void AndOperatorCanCombineTwoResolvableConstraintExpressions()
 
61
        {
 
62
            Assert.That(GetType(), Has.Attribute(typeof(TestFixtureAttribute)) & Has.Attribute(typeof(DescriptionAttribute)));
 
63
        }
 
64
 
 
65
        [Test]
 
66
        public void AndOperatorCanCombineConstraintAndResolvableConstraintExpression()
 
67
        {
 
68
            Assert.That(GetType(), Is.EqualTo(typeof(AndOperatorOverride)) & Has.Attribute(typeof(DescriptionAttribute)));
 
69
        }
 
70
 
 
71
        [Test]
 
72
        public void AndOperatorCanCombineResolvableConstraintExpressionAndConstraint()
 
73
        {
 
74
            Assert.That(GetType(), Has.Attribute(typeof(DescriptionAttribute)) & Is.EqualTo(typeof(AndOperatorOverride)));
 
75
        }
 
76
    }
 
77
 
 
78
    [TestFixture]
 
79
    public class OrOperatorOverride : SyntaxTest
 
80
    {
 
81
        [SetUp]
 
82
        public void SetUp()
 
83
        {
 
84
            parseTree = "<or <lessthan 5> <greaterthan 10>>";
 
85
            staticSyntax = Is.LessThan(5) | Is.GreaterThan(10);
 
86
            inheritedSyntax = Helper().LessThan(5) | Is.GreaterThan(10);
 
87
            builderSyntax = Builder().LessThan(5) | Is.GreaterThan(10);
 
88
        }
 
89
 
 
90
        [Test]
 
91
        public void OrOperatorCanCombineTwoResolvableConstraintExpressions()
 
92
        {
 
93
            Assert.That(GetType(), Has.Attribute(typeof(TestFixtureAttribute)) | Has.Attribute(typeof(TestCaseAttribute)));
 
94
        }
 
95
 
 
96
        [Test]
 
97
        public void OrOperatorCanCombineResolvableConstraintExpressionAndConstraint()
 
98
        {
 
99
            Assert.That(GetType(), Has.Attribute(typeof(TestFixtureAttribute)) | Is.EqualTo(7));
 
100
        }
 
101
 
 
102
        [Test]
 
103
        public void OrOperatorCanCombineConstraintAndResolvableConstraintExpression()
 
104
        {
 
105
            Assert.That(GetType(), Is.EqualTo(7) | Has.Attribute(typeof(TestFixtureAttribute)));
 
106
        }
 
107
    }
 
108
 
 
109
    public class MixedOperatorOverrides
 
110
    {
 
111
        [Test]
 
112
        public void ComplexTests()
 
113
        {
 
114
            string expected = "<and <and <not <null>> <not <lessthan 5>>> <not <greaterthan 10>>>";
 
115
 
 
116
            Constraint c =
 
117
                Is.Not.Null & Is.Not.LessThan(5) & Is.Not.GreaterThan(10);
 
118
            Assert.That(c.ToString(), Is.EqualTo(expected).NoClip);
 
119
 
 
120
            c = !Is.Null & !Is.LessThan(5) & !Is.GreaterThan(10);
 
121
            Assert.That(c.ToString(), Is.EqualTo(expected).NoClip);
 
122
 
 
123
            Constraint x = null;
 
124
            c = !x & !Is.LessThan(5) & !Is.GreaterThan(10);
 
125
            Assert.That(c.ToString(), Is.EqualTo(expected).NoClip);
 
126
        }
 
127
    }
 
128
}