~nunit-core/nunitv2/2.5

« back to all changes in this revision

Viewing changes to addins/RowTest/NUnitExtension.RowTest.AddIn/RowTestAddIn.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
using NUnit.Core.Extensibility;
 
9
 
 
10
namespace NUnitExtension.RowTest.AddIn
 
11
{
 
12
        [NUnitAddin(Name = "Row Test Extension")]
 
13
        public class RowTestAddIn : IAddin, ITestCaseBuilder
 
14
        {
 
15
                private RowTestFactory _testFactory;
 
16
                
 
17
                public RowTestAddIn()
 
18
                {
 
19
                        _testFactory = new RowTestFactory();
 
20
                }
 
21
                
 
22
                public bool Install(IExtensionHost host)
 
23
                {
 
24
                        if (host == null)
 
25
                                throw new ArgumentNullException("host");
 
26
                        
 
27
                        IExtensionPoint testCaseBuilders = host.GetExtensionPoint("TestCaseBuilders");
 
28
                        if (testCaseBuilders == null)
 
29
                                return false;
 
30
                        
 
31
                        testCaseBuilders.Install(this);
 
32
                        return true;
 
33
                }
 
34
 
 
35
        public bool CanBuildFrom(MethodInfo method)
 
36
        {
 
37
            return CanBuildFrom(method, null);
 
38
        }
 
39
 
 
40
            public bool CanBuildFrom(MethodInfo method, Test suite)
 
41
        {
 
42
                        return RowTestFramework.IsRowTest(method);
 
43
                }
 
44
 
 
45
        public Test BuildFrom(MethodInfo method)
 
46
        {
 
47
            return BuildFrom(method, null);
 
48
        }
 
49
 
 
50
            public Test BuildFrom(MethodInfo method, Test suite)
 
51
        {
 
52
                        if (method == null)
 
53
                                throw new ArgumentNullException("method");
 
54
                        
 
55
                        RowTestSuite methods = _testFactory.CreateRowTestSuite(method);
 
56
                        Attribute[] rows = RowTestFramework.GetRowAttributes(method);
 
57
 
 
58
                        foreach (Attribute row in rows)
 
59
                                methods.Add(_testFactory.CreateRowTestCase(row, method));
 
60
                        
 
61
                        return methods;
 
62
                }
 
63
        }
 
64
}