~nunit-core/nunitv2/2.5

« back to all changes in this revision

Viewing changes to addins/RowTest/NUnitExtension.RowTest.AddIn.UnitTests/RowTestFrameworkTest.cs

  • Committer: charliepoole
  • Date: 2008-05-05 22:17:22 UTC
  • Revision ID: vcs-imports@canonical.com-20080505221722-7bdjujqed8pk6al3
Add back RowTestExtension as a separately compiled assembly, bundled
with NUnit, and modify build script to handle addins.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// *********************************************************************
 
2
// Copyright 2007, Andreas Schlapsi
 
3
// This is free software licensed under the MIT license. 
 
4
// *********************************************************************
 
5
using System;
 
6
using System.Reflection;
 
7
using NUnit.Framework;
 
8
using NUnit.Framework.SyntaxHelpers;
 
9
 
 
10
namespace NUnitExtension.RowTest.AddIn.UnitTests
 
11
{
 
12
        [TestFixture]
 
13
        public class RowTestFrameworkTest : BaseTestFixture
 
14
        {
 
15
                [Test]
 
16
                public void GetRowArguments()
 
17
                {
 
18
                        object[] rowArguments = new object[] { 4, 5 };
 
19
                        RowAttribute row = new RowAttribute(rowArguments);
 
20
                        
 
21
                        object[] extractedRowArguments = RowTestFramework.GetRowArguments(row);
 
22
                        
 
23
                        Assert.That(extractedRowArguments, Is.SameAs(rowArguments));
 
24
                }
 
25
                
 
26
                [Test]
 
27
                public void IsSpecialValue_True()
 
28
                {
 
29
                        bool isSpecialValue = RowTestFramework.IsSpecialValue(SpecialValue.Null);
 
30
                        
 
31
                        Assert.That(isSpecialValue, Is.True);
 
32
                }
 
33
                
 
34
                [Test]
 
35
                public void IsSpecialValue_False()
 
36
                {
 
37
                        bool isSpecialValue = RowTestFramework.IsSpecialValue(42);
 
38
                        
 
39
                        Assert.That(isSpecialValue, Is.False);
 
40
                }
 
41
                
 
42
                [Test]
 
43
                public void IsSpecialValue_Null()
 
44
                {
 
45
                        bool isSpecialValue = RowTestFramework.IsSpecialValue(null);
 
46
                        
 
47
                        Assert.That(isSpecialValue, Is.False);
 
48
                }
 
49
 
 
50
                [Test]
 
51
                public void GetExpectedExceptionType()
 
52
                {
 
53
                        Type expectedExceptionType = typeof(ArgumentException);
 
54
                        RowAttribute row = CreateRowAttribute();
 
55
                        row.ExpectedException = expectedExceptionType;
 
56
                        
 
57
                        Type extractedExpectedExceptionType = RowTestFramework.GetExpectedExceptionType(row);
 
58
                        
 
59
                        Assert.That(extractedExpectedExceptionType, Is.SameAs(expectedExceptionType));
 
60
                }
 
61
                
 
62
                [Test]
 
63
                public void GetExpectedExceptionMessage()
 
64
                {
 
65
                        string expectedExceptionMessage = "Expected Exception Message.";
 
66
                        Type expectedExceptionType = typeof(ArgumentException);
 
67
                        RowAttribute row = CreateRowAttribute();
 
68
                        row.ExceptionMessage = expectedExceptionMessage;
 
69
                        
 
70
                        string extractedExceptionMessage = RowTestFramework.GetExpectedExceptionMessage(row);
 
71
                        
 
72
                        Assert.That(extractedExceptionMessage, Is.SameAs(expectedExceptionMessage));
 
73
                }
 
74
                
 
75
                [Test]
 
76
                public void GetTestName()
 
77
                {
 
78
                        string testName = "UnitTest";
 
79
                        RowAttribute row = CreateRowAttribute();
 
80
                        row.TestName = testName;
 
81
                        
 
82
                        string extractedTestName = RowTestFramework.GetTestName(row);
 
83
                        
 
84
                        Assert.That(extractedTestName, Is.EqualTo(testName));
 
85
                }
 
86
                
 
87
                [Test]
 
88
                public void IsRowTest_False()
 
89
                {
 
90
                        MethodInfo method = GetTestClassMethod("MethodWithoutRowTestAttribute");
 
91
 
 
92
                        bool isRowTest = RowTestFramework.IsRowTest(method);
 
93
                        
 
94
                        Assert.That(isRowTest, Is.False);
 
95
                }
 
96
                
 
97
                [Test]
 
98
                public void IsRowTest_True()
 
99
                {
 
100
                        MethodInfo method = GetTestClassMethod("MethodWithRowTestAttribute");
 
101
 
 
102
                        bool isRowTest = RowTestFramework.IsRowTest(method);
 
103
                        
 
104
                        Assert.That(isRowTest, Is.True);
 
105
                }
 
106
                
 
107
                [Test]
 
108
                public void IsRowTest_MethodIsNull()
 
109
                {
 
110
                        bool isRowTest = RowTestFramework.IsRowTest(null);
 
111
                        
 
112
                        Assert.That(isRowTest, Is.False);
 
113
                }
 
114
                
 
115
                [Test]
 
116
                public void GetRowAttributes_NoRows()
 
117
                {
 
118
                        MethodInfo method = GetTestClassMethod("MethodWithRowTestAttribute");
 
119
                        
 
120
                        Attribute[] rowAttributes = RowTestFramework.GetRowAttributes(method);
 
121
                        
 
122
                        Assert.That(rowAttributes.Length, Is.EqualTo(0));
 
123
                }
 
124
                
 
125
                [Test]
 
126
                public void GetRowAttributes_TwoRows()
 
127
                {
 
128
                        MethodInfo method = GetTestClassMethod("RowTestMethodWith2Rows");
 
129
                        
 
130
                        Attribute[] rowAttributes = RowTestFramework.GetRowAttributes(method);
 
131
                        
 
132
                        Assert.That(rowAttributes.Length, Is.EqualTo(2));
 
133
                }
 
134
                
 
135
                private RowAttribute CreateRowAttribute()
 
136
                {
 
137
                        return new RowAttribute(4, 5);
 
138
                }
 
139
        }
 
140
}