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 RowTestFrameworkTest : BaseTestFixture
16
public void GetRowArguments()
18
object[] rowArguments = new object[] { 4, 5 };
19
RowAttribute row = new RowAttribute(rowArguments);
21
object[] extractedRowArguments = RowTestFramework.GetRowArguments(row);
23
Assert.That(extractedRowArguments, Is.SameAs(rowArguments));
27
public void IsSpecialValue_True()
29
bool isSpecialValue = RowTestFramework.IsSpecialValue(SpecialValue.Null);
31
Assert.That(isSpecialValue, Is.True);
35
public void IsSpecialValue_False()
37
bool isSpecialValue = RowTestFramework.IsSpecialValue(42);
39
Assert.That(isSpecialValue, Is.False);
43
public void IsSpecialValue_Null()
45
bool isSpecialValue = RowTestFramework.IsSpecialValue(null);
47
Assert.That(isSpecialValue, Is.False);
51
public void GetExpectedExceptionType()
53
Type expectedExceptionType = typeof(ArgumentException);
54
RowAttribute row = CreateRowAttribute();
55
row.ExpectedException = expectedExceptionType;
57
Type extractedExpectedExceptionType = RowTestFramework.GetExpectedExceptionType(row);
59
Assert.That(extractedExpectedExceptionType, Is.SameAs(expectedExceptionType));
63
public void GetExpectedExceptionMessage()
65
string expectedExceptionMessage = "Expected Exception Message.";
66
Type expectedExceptionType = typeof(ArgumentException);
67
RowAttribute row = CreateRowAttribute();
68
row.ExceptionMessage = expectedExceptionMessage;
70
string extractedExceptionMessage = RowTestFramework.GetExpectedExceptionMessage(row);
72
Assert.That(extractedExceptionMessage, Is.SameAs(expectedExceptionMessage));
76
public void GetTestName()
78
string testName = "UnitTest";
79
RowAttribute row = CreateRowAttribute();
80
row.TestName = testName;
82
string extractedTestName = RowTestFramework.GetTestName(row);
84
Assert.That(extractedTestName, Is.EqualTo(testName));
88
public void IsRowTest_False()
90
MethodInfo method = GetTestClassMethod("MethodWithoutRowTestAttribute");
92
bool isRowTest = RowTestFramework.IsRowTest(method);
94
Assert.That(isRowTest, Is.False);
98
public void IsRowTest_True()
100
MethodInfo method = GetTestClassMethod("MethodWithRowTestAttribute");
102
bool isRowTest = RowTestFramework.IsRowTest(method);
104
Assert.That(isRowTest, Is.True);
108
public void IsRowTest_MethodIsNull()
110
bool isRowTest = RowTestFramework.IsRowTest(null);
112
Assert.That(isRowTest, Is.False);
116
public void GetRowAttributes_NoRows()
118
MethodInfo method = GetTestClassMethod("MethodWithRowTestAttribute");
120
Attribute[] rowAttributes = RowTestFramework.GetRowAttributes(method);
122
Assert.That(rowAttributes.Length, Is.EqualTo(0));
126
public void GetRowAttributes_TwoRows()
128
MethodInfo method = GetTestClassMethod("RowTestMethodWith2Rows");
130
Attribute[] rowAttributes = RowTestFramework.GetRowAttributes(method);
132
Assert.That(rowAttributes.Length, Is.EqualTo(2));
135
private RowAttribute CreateRowAttribute()
137
return new RowAttribute(4, 5);