~nunit-core/nunitv2/2.5

« back to all changes in this revision

Viewing changes to addins/RowTest/NUnitExtension.RowTest.AddIn/RowTestFramework.cs

  • Committer: charliepoole
  • Date: 2008-05-05 22:17:22 UTC
  • Revision ID: vcs-imports@canonical.com-20080505221722-7bdjujqed8pk6al3
Add back RowTestExtension as a separately compiled assembly, bundled
with NUnit, and modify build script to handle addins.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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;
 
8
 
 
9
namespace NUnitExtension.RowTest.AddIn
 
10
{
 
11
        public sealed class RowTestFramework
 
12
        {
 
13
                public const string RowTestAttribute = "NUnitExtension.RowTest.RowTestAttribute";
 
14
                public const string RowAttribute = "NUnitExtension.RowTest.RowAttribute";
 
15
                public const string SpecialValueEnum = "NUnitExtension.RowTest.SpecialValue";
 
16
                
 
17
                private RowTestFramework()
 
18
                {
 
19
                }
 
20
                
 
21
                public static bool IsRowTest(MethodInfo method)
 
22
                {
 
23
                        if (method == null)
 
24
                                return false;
 
25
                        
 
26
                        return Reflect.HasAttribute(method, RowTestAttribute, false);;
 
27
                }
 
28
                
 
29
                public static Attribute[] GetRowAttributes(MethodInfo method)
 
30
                {
 
31
                        if (method == null)
 
32
                                throw new ArgumentNullException("method");
 
33
                        
 
34
                        return Reflect.GetAttributes(method, RowAttribute, false);
 
35
                }
 
36
                
 
37
                public static object[] GetRowArguments(Attribute attribute)
 
38
                {
 
39
                        return Reflect.GetPropertyValue(attribute, "Arguments") as object[];
 
40
                }
 
41
                
 
42
                public static bool IsSpecialValue(object argument)
 
43
                {
 
44
                        if (argument == null)
 
45
                                return false;
 
46
                        
 
47
                        return argument.GetType().FullName == SpecialValueEnum;
 
48
                }
 
49
                
 
50
                public static Type GetExpectedExceptionType(Attribute attribute)
 
51
                {
 
52
                        return Reflect.GetPropertyValue(attribute, "ExpectedException") as Type;
 
53
                }
 
54
                
 
55
                public static string GetExpectedExceptionMessage(Attribute attribute)
 
56
                {
 
57
                        return Reflect.GetPropertyValue(attribute, "ExceptionMessage") as string;
 
58
                }
 
59
                
 
60
                public static string GetTestName(Attribute attribute)
 
61
                {
 
62
                        return Reflect.GetPropertyValue(attribute, "TestName") as string;
 
63
                }
 
64
        }
 
65
}