1
// *********************************************************************
2
// Copyright 2007, Andreas Schlapsi
3
// This is free software licensed under the MIT license.
4
// *********************************************************************
6
using System.Reflection;
8
using NUnit.Framework.SyntaxHelpers;
10
namespace NUnitExtension.RowTest.AddIn.UnitTests
13
public class RowTestNameBuilderTest : BaseTestFixture
16
public void Initialize()
18
MethodInfo method = GetRowTestMethodWith2Rows();
19
object[] arguments = new object[] { 5, 6 };
20
string baseTestName = "UnitTest";
22
RowTestNameBuilder testNameBuilder = new RowTestNameBuilder(method, baseTestName, arguments);
24
Assert.That(testNameBuilder.Method, Is.SameAs(method));
25
Assert.That(testNameBuilder.BaseTestName, Is.EqualTo(baseTestName));
26
Assert.That(testNameBuilder.Arguments, Is.SameAs(arguments));
30
public void TestName_IsMethodName()
32
RowTestNameBuilder testNameBuilder = CreateRowTestNameBuilder(GetRowTestMethodWith2Rows(), 5, 6);
34
string testName = testNameBuilder.TestName;
36
string expectedTestName = Method_RowTestMethodWith2Rows + "(5, 6)";
37
Assert.That(testName, Is.EqualTo(expectedTestName));
41
public void TestName_IsProvided()
43
string providedTestName = "UnitTest";
45
RowTestNameBuilder testNameBuilder =
46
CreateRowTestNameBuilder(providedTestName, GetRowTestMethodWith2Rows(), 5, 6);
48
string testName = testNameBuilder.TestName;
50
string expectedTestName = providedTestName + "(5, 6)";
51
Assert.That(testName, Is.EqualTo(expectedTestName));
55
public void TestName_ProvidedTestNameIsEmpty()
57
RowTestNameBuilder testNameBuilder =
58
CreateRowTestNameBuilder(string.Empty, GetRowTestMethodWith2Rows(), 5, 6);
60
string testName = testNameBuilder.TestName;
62
string expectedTestName = Method_RowTestMethodWith2Rows + "(5, 6)";
63
Assert.That(testName, Is.EqualTo(expectedTestName));
67
public void FullTestName()
69
RowTestNameBuilder testNameBuilder = CreateRowTestNameBuilder(GetRowTestMethodWith2Rows(), 5, 6);
71
string fullTestName = testNameBuilder.FullTestName;
73
string expectedTestName = typeof(TestClass).FullName + "." + Method_RowTestMethodWith2Rows + "(5, 6)";
74
Assert.That(fullTestName, Is.EqualTo(expectedTestName));
78
public void TestName_NullArgument()
80
RowTestNameBuilder testNameBuilder = CreateRowTestNameBuilder(GetRowTestMethodWithNullArgument(), null);
82
string testName = testNameBuilder.TestName;
84
string expectedTestName = Method_RowTestMethodWithNullArgument + "(null)";
85
Assert.That(testName, Is.EqualTo(expectedTestName));
90
public void TestName_SecondArgumentIsNull()
92
RowTestNameBuilder testNameBuilder = CreateRowTestNameBuilder(GetRowTestMethodWithNormalAndNullArgument(), 5, null);
94
string testName = testNameBuilder.TestName;
96
string expectedTestName = Method_RowTestMethodWithNormalAndNullArgument + "(5, null)";
97
Assert.That(testName, Is.EqualTo(expectedTestName));
101
private RowTestNameBuilder CreateRowTestNameBuilder(params object[] arguments)
103
return CreateRowTestNameBuilder(GetRowTestMethodWith2Rows(), arguments);
106
private RowTestNameBuilder CreateRowTestNameBuilder(MethodInfo method, params object[] arguments)
108
return CreateRowTestNameBuilder(null, method, arguments);
111
private RowTestNameBuilder CreateRowTestNameBuilder(
114
params object[] arguments)
116
return new RowTestNameBuilder(method, baseTestName, arguments);