/src/NUnit/core/Extensibility/TestDecoratorCollection.cs
C# | 44 lines | 28 code | 6 blank | 10 comment | 0 complexity | b66f35c5aecf27d7df8fddb3f58c69ca MD5 | raw file
1// **************************************************************** 2// Copyright 2007, Charlie Poole 3// This is free software licensed under the NUnit license. You may 4// obtain a copy of the license at http://nunit.org. 5// **************************************************************** 6using System; 7using System.Collections; 8using System.Reflection; 9 10namespace NUnit.Core.Extensibility 11{ 12 /// <summary> 13 /// TestDecoratorCollection is an ExtensionPoint for TestDecorators and 14 /// implements the ITestDecorator interface itself, passing calls 15 /// on to the individual decorators. 16 /// </summary> 17 public class TestDecoratorCollection : ExtensionPoint, IExtensionPoint2, ITestDecorator 18 { 19 #region Constructor 20 public TestDecoratorCollection(IExtensionHost host) 21 : base( "TestDecorators", host, 10 ) { } 22 #endregion 23 24 #region ITestDecorator Members 25 26 public Test Decorate(Test test, MemberInfo member) 27 { 28 Test decoratedTest = test; 29 30 foreach( ITestDecorator decorator in Extensions ) 31 decoratedTest = decorator.Decorate( decoratedTest, member ); 32 33 return decoratedTest; 34 } 35 #endregion 36 37 #region ExtensionPoint Overrides 38 protected override bool IsValidExtension(object extension) 39 { 40 return extension is ITestDecorator; 41 } 42 #endregion 43 } 44}