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 RowTestNameBuilder
13
private MethodInfo _method;
14
private string _baseTestName;
15
private object[] _arguments;
16
private string _argumentList;
18
public RowTestNameBuilder(MethodInfo method, string baseTestName, object[] arguments)
21
_baseTestName = baseTestName;
22
_arguments = arguments;
25
public MethodInfo Method
27
get { return _method; }
30
public string BaseTestName
32
get { return _baseTestName; }
35
public object[] Arguments
37
get { return _arguments; }
40
public string TestName
44
string baseTestName = _baseTestName;
46
if (baseTestName == null || baseTestName.Length == 0)
47
baseTestName = _method.Name;
49
return baseTestName + GetArgumentList();
53
public string FullTestName
55
get { return _method.DeclaringType.FullName + "." + TestName; }
58
private string GetArgumentList()
60
if (_argumentList == null)
61
_argumentList = "(" + CreateArgumentList() + ")";
66
private string CreateArgumentList()
68
if (_arguments == null)
71
StringBuilder argumentListBuilder = new StringBuilder();
73
for (int i = 0; i < _arguments.Length; i++)
76
argumentListBuilder.Append(", ");
78
argumentListBuilder.Append (GetArgumentString (_arguments[i]));
81
return argumentListBuilder.ToString();
84
private string GetArgumentString (object argument)
89
return argument.ToString();