1 // ****************************************************************
\r
2 // Copyright 2007, Charlie Poole
\r
3 // This is free software licensed under the NUnit license. You may
\r
4 // obtain a copy of the license at http://nunit.org/?p=license&r=2.4
\r
5 // ****************************************************************
\r
7 using System.Reflection;
\r
8 using NUnit.Core.Extensibility;
\r
10 namespace NUnit.Core.Extensions
\r
13 /// Summary description for RepeatedTestDecorator.
\r
15 [NUnitAddin(Description="Runs a test case multiple times")]
\r
16 public class RepeatedTestDecorator : ITestDecorator, IAddin
\r
18 private static readonly string RepeatAttributeType = "NUnit.Framework.Extensions.RepeatAttribute";
\r
20 #region IAddin Members
\r
21 public bool Install(IExtensionHost host)
\r
23 IExtensionPoint decorators = host.GetExtensionPoint( "TestDecorators" );
\r
24 if ( decorators == null )
\r
27 decorators.Install( this );
\r
32 #region ITestDecorator Members
\r
33 public Test Decorate(Test test, MemberInfo member)
\r
35 if ( member == null )
\r
38 TestCase testCase = test as TestCase;
\r
39 if ( testCase == null )
\r
42 Attribute repeatAttr = Reflect.GetAttribute( member, RepeatAttributeType, true );
\r
43 if ( repeatAttr == null )
\r
46 object propVal = Reflect.GetPropertyValue( repeatAttr, "Count",
\r
47 BindingFlags.Public | BindingFlags.Instance );
\r
49 if ( propVal == null )
\r
52 int count = (int)propVal;
\r
54 return new RepeatedTestCase( testCase, count );
\r
57 // public Test Decorate( Test test, Type fixtureType )
\r