1
// *********************************************************************
2
// Copyright 2007, Andreas Schlapsi
3
// This is free software licensed under the MIT license.
4
// *********************************************************************
6
using System.Reflection;
9
namespace NUnitExtension.RowTest.AddIn
11
public class RowTestFactory
13
public RowTestFactory()
17
public RowTestSuite CreateRowTestSuite(MethodInfo method)
20
throw new ArgumentNullException("method");
22
RowTestSuite testSuite = new RowTestSuite(method);
23
NUnitFramework.ApplyCommonAttributes(method, testSuite);
28
public RowTestCase CreateRowTestCase(Attribute row, MethodInfo method)
31
throw new ArgumentNullException("row");
34
throw new ArgumentNullException("method");
36
object[] rowArguments = RowTestFramework.GetRowArguments(row);
37
rowArguments = FilterSpecialValues(rowArguments);
39
string testName = RowTestFramework.GetTestName(row);
40
Type expectedExceptionType = RowTestFramework.GetExpectedExceptionType(row);
42
RowTestCase testCase = new RowTestCase(method, testName, rowArguments);
43
if (expectedExceptionType != null)
45
testCase.ExceptionExpected = true;
46
testCase.ExpectedExceptionType = expectedExceptionType;
47
testCase.ExpectedMessage = RowTestFramework.GetExpectedExceptionMessage(row);
53
private object[] FilterSpecialValues(object[] arguments)
55
if (arguments == null)
58
for (int i = 0; i < arguments.Length; i++)
60
if (RowTestFramework.IsSpecialValue(arguments[i]))
61
arguments[i] = MapSpecialValue(arguments[i]);
67
private object MapSpecialValue(object specialValue)
69
switch (specialValue.ToString())