2010-04-02 Jb Evain <jbevain@novell.com>
[mcs.git] / nunit24 / NUnitExtensions / core / RowTest / RowTestFramework.cs
blob581a53aec45b2ae5e8eae5b0ca64279aba5a845d
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.Core;
9 namespace NUnit.Core.Extensions.RowTest
11 public sealed class RowTestFramework
13 public const string RowTestAttribute = "NUnit.Framework.Extensions.RowTestAttribute";
14 public const string RowAttribute = "NUnit.Framework.Extensions.RowAttribute";
15 public const string SpecialValueEnum = "NUnit.Framework.Extensions.SpecialValue";
17 private RowTestFramework()
21 public static bool IsRowTest(MethodInfo method)
23 if (method == null)
24 return false;
26 return Reflect.HasAttribute(method, RowTestAttribute, false);;
29 public static Attribute[] GetRowAttributes(MethodInfo method)
31 if (method == null)
32 throw new ArgumentNullException("method");
34 return Reflect.GetAttributes(method, RowAttribute, false);
37 public static object[] GetRowArguments(Attribute attribute)
39 return Reflect.GetPropertyValue(attribute, "Arguments") as object[];
42 public static bool IsSpecialValue(object argument)
44 if (argument == null)
45 return false;
47 return argument.GetType().FullName == SpecialValueEnum;
50 public static Type GetExpectedExceptionType(Attribute attribute)
52 return Reflect.GetPropertyValue(attribute, "ExpectedException") as Type;
55 public static string GetExpectedExceptionMessage(Attribute attribute)
57 return Reflect.GetPropertyValue(attribute, "ExceptionMessage") as string;
60 public static string GetTestName(Attribute attribute)
62 return Reflect.GetPropertyValue(attribute, "TestName") as string;