~nunit-core/nunitv2/2.5

« back to all changes in this revision

Viewing changes to addins/RowTest/NUnitExtension.RowTest.AddIn.UnitTests/RowTestNameBuilderTest.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 RowTestNameBuilderTest : BaseTestFixture
 
14
        {
 
15
                [Test]
 
16
                public void Initialize()
 
17
                {
 
18
                        MethodInfo method = GetRowTestMethodWith2Rows();
 
19
                        object[] arguments = new object[] { 5, 6 };
 
20
                        string baseTestName = "UnitTest";
 
21
                        
 
22
                        RowTestNameBuilder testNameBuilder = new RowTestNameBuilder(method, baseTestName, arguments);
 
23
                        
 
24
                        Assert.That(testNameBuilder.Method, Is.SameAs(method));
 
25
                        Assert.That(testNameBuilder.BaseTestName, Is.EqualTo(baseTestName));
 
26
                        Assert.That(testNameBuilder.Arguments, Is.SameAs(arguments));
 
27
                }
 
28
                
 
29
                [Test]
 
30
                public void TestName_IsMethodName()
 
31
                {
 
32
                        RowTestNameBuilder testNameBuilder = CreateRowTestNameBuilder(GetRowTestMethodWith2Rows(), 5, 6);
 
33
 
 
34
                        string testName = testNameBuilder.TestName;
 
35
                        
 
36
                        string expectedTestName = Method_RowTestMethodWith2Rows + "(5, 6)";
 
37
                        Assert.That(testName, Is.EqualTo(expectedTestName));
 
38
                }
 
39
                
 
40
                [Test]
 
41
                public void TestName_IsProvided()
 
42
                {
 
43
                        string providedTestName = "UnitTest";
 
44
                        
 
45
                        RowTestNameBuilder testNameBuilder =
 
46
                                        CreateRowTestNameBuilder(providedTestName, GetRowTestMethodWith2Rows(), 5, 6);
 
47
 
 
48
                        string testName = testNameBuilder.TestName;
 
49
                        
 
50
                        string expectedTestName = providedTestName + "(5, 6)";
 
51
                        Assert.That(testName, Is.EqualTo(expectedTestName));
 
52
                }
 
53
                
 
54
                [Test]
 
55
                public void TestName_ProvidedTestNameIsEmpty()
 
56
                {
 
57
                        RowTestNameBuilder testNameBuilder = 
 
58
                                        CreateRowTestNameBuilder(string.Empty, GetRowTestMethodWith2Rows(), 5, 6);
 
59
 
 
60
                        string testName = testNameBuilder.TestName;
 
61
                        
 
62
                        string expectedTestName = Method_RowTestMethodWith2Rows + "(5, 6)";
 
63
                        Assert.That(testName, Is.EqualTo(expectedTestName));
 
64
                }
 
65
                
 
66
                [Test]
 
67
                public void FullTestName()
 
68
                {
 
69
                        RowTestNameBuilder testNameBuilder = CreateRowTestNameBuilder(GetRowTestMethodWith2Rows(), 5, 6);
 
70
 
 
71
                        string fullTestName = testNameBuilder.FullTestName;
 
72
                        
 
73
                        string expectedTestName = typeof(TestClass).FullName + "." + Method_RowTestMethodWith2Rows + "(5, 6)";
 
74
                        Assert.That(fullTestName, Is.EqualTo(expectedTestName));
 
75
                }
 
76
                
 
77
                [Test]
 
78
                public void TestName_NullArgument()
 
79
                {
 
80
                        RowTestNameBuilder testNameBuilder = CreateRowTestNameBuilder(GetRowTestMethodWithNullArgument(), null);
 
81
                        
 
82
                        string testName = testNameBuilder.TestName;
 
83
                        
 
84
                        string expectedTestName = Method_RowTestMethodWithNullArgument + "(null)";
 
85
                        Assert.That(testName, Is.EqualTo(expectedTestName));
 
86
                }
 
87
                
 
88
#if NET_2_0
 
89
                [Test]
 
90
                public void TestName_SecondArgumentIsNull()
 
91
                {
 
92
                        RowTestNameBuilder testNameBuilder = CreateRowTestNameBuilder(GetRowTestMethodWithNormalAndNullArgument(), 5, null);
 
93
                        
 
94
                        string testName = testNameBuilder.TestName;
 
95
                        
 
96
                        string expectedTestName = Method_RowTestMethodWithNormalAndNullArgument + "(5, null)";
 
97
                        Assert.That(testName, Is.EqualTo(expectedTestName));
 
98
                }
 
99
#endif
 
100
                
 
101
                private RowTestNameBuilder CreateRowTestNameBuilder(params object[] arguments)
 
102
                {
 
103
                        return CreateRowTestNameBuilder(GetRowTestMethodWith2Rows(), arguments);
 
104
                }
 
105
                
 
106
                private RowTestNameBuilder CreateRowTestNameBuilder(MethodInfo method, params object[] arguments)
 
107
                {
 
108
                        return CreateRowTestNameBuilder(null, method, arguments);
 
109
                }
 
110
                
 
111
                private RowTestNameBuilder CreateRowTestNameBuilder(
 
112
                                string baseTestName,
 
113
                                MethodInfo method,
 
114
                                params object[] arguments)
 
115
                {
 
116
                        return new RowTestNameBuilder(method, baseTestName, arguments);
 
117
                }
 
118
        }
 
119
}