Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

55 lines
1.4 KiB
C#

// *********************************************************************
// Copyright 2007, Andreas Schlapsi
// This is free software licensed under the MIT license.
// *********************************************************************
using System;
using System.Reflection;
using NUnit.Core;
using NUnit.Core.Extensibility;
namespace NUnit.Core.Extensions.RowTest
{
[NUnitAddin(Name = "Row Test Extension")]
public class RowTestAddIn : IAddin, ITestCaseBuilder
{
private RowTestFactory _testFactory;
public RowTestAddIn()
{
_testFactory = new RowTestFactory();
}
public bool Install(IExtensionHost host)
{
if (host == null)
throw new ArgumentNullException("host");
IExtensionPoint testCaseBuilders = host.GetExtensionPoint("TestCaseBuilders");
if (testCaseBuilders == null)
return false;
testCaseBuilders.Install(this);
return true;
}
public bool CanBuildFrom(MethodInfo method)
{
return RowTestFramework.IsRowTest(method);
}
public Test BuildFrom(MethodInfo method)
{
if (method == null)
throw new ArgumentNullException("method");
RowTestSuite suite = _testFactory.CreateRowTestSuite(method);
Attribute[] rows = RowTestFramework.GetRowAttributes(method);
foreach (Attribute row in rows)
suite.Add(_testFactory.CreateRowTestCase(row, method));
return suite;
}
}
}