[1146] | 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/?p=license&r=2.4
|
---|
| 5 | // ****************************************************************
|
---|
| 6 |
|
---|
| 7 | using System;
|
---|
| 8 | using NUnit.Core.Extensibility;
|
---|
| 9 |
|
---|
| 10 | namespace NUnit.Core.Extensions
|
---|
| 11 | {
|
---|
| 12 | /// <summary>
|
---|
| 13 | /// SampleSuiteExtensionBuilder knows how to build a SampleSuiteExtension
|
---|
| 14 | /// </summary>
|
---|
| 15 | public class SampleSuiteExtensionBuilder : ISuiteBuilder
|
---|
| 16 | {
|
---|
| 17 | #region ISuiteBuilder Members
|
---|
| 18 |
|
---|
| 19 | // This builder delegates all the work to the constructor of the
|
---|
| 20 | // extension suite. Many builders will need to do more work,
|
---|
| 21 | // looking for other attributes, setting properties on the
|
---|
| 22 | // suite and locating methods for tests, setup and teardown.
|
---|
| 23 | public Test BuildFrom(Type type)
|
---|
| 24 | {
|
---|
| 25 | if ( CanBuildFrom( type ) )
|
---|
| 26 | return new SampleSuiteExtension( type );
|
---|
| 27 | return null;
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | // The builder recognizes the types that it can use by the presense
|
---|
| 31 | // of SampleSuiteExtensionAttribute. Note that an attribute does not
|
---|
| 32 | // have to be used. You can use any arbitrary set of rules that can be
|
---|
| 33 | // implemented using reflection on the type.
|
---|
| 34 | public bool CanBuildFrom(Type type)
|
---|
| 35 | {
|
---|
| 36 | return Reflect.HasAttribute( type, "NUnit.Core.Extensions.SampleSuiteExtensionAttribute", false );
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | #endregion
|
---|
| 40 | }
|
---|
| 41 | }
|
---|