Type fixture pattern implementation.
Namespace: MbUnit.Framework
Assembly: MbUnit.Framework (in MbUnit.Framework.dll)
Syntax
| C# | Visual Basic | Visual C++ |
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] public sealed class TypeFixtureAttribute : TestFixturePatternAttribute
<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple := False, Inherited := True)> _ Public NotInheritable Class TypeFixtureAttribute _ Inherits TestFixturePatternAttribute
[AttributeUsageAttribute(AttributeTargets::Class, AllowMultiple = false, Inherited = true)] public ref class TypeFixtureAttribute sealed : public TestFixturePatternAttribute
Members
| All Members | Constructors | Properties | Methods | Explicit Interface Implementations |
| Member | Description | |
|---|---|---|
| TypeFixtureAttribute(Type) |
Creates a fixture for the testedType type.
| |
| TypeFixtureAttribute(Type, String) |
Creates a fixture for the testedType type
and a description
| |
| ApartmentState | (Inherited from TestFixturePatternAttribute.) | |
| Description | (Inherited from PatternAttribute.) | |
| Equals(Object) | Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute.) | |
| Finalize()()() | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) | |
| GetHashCode()()() | Returns the hash code for this instance. (Inherited from Attribute.) | |
| _Attribute..::.GetIDsOfNames(Guid%, IntPtr, UInt32, UInt32, IntPtr) | (Inherited from Attribute.) | |
| GetRun()()() |
Creates the execution logic
(Overrides TestFixturePatternAttribute..::.GetRun()()().) | |
| GetTimeOut()()() | (Inherited from TestFixturePatternAttribute.) | |
| GetType()()() | Gets the Type of the current instance. (Inherited from Object.) | |
| _Attribute..::.GetTypeInfo(UInt32, UInt32, IntPtr) | (Inherited from Attribute.) | |
| _Attribute..::.GetTypeInfoCount(UInt32%) | (Inherited from Attribute.) | |
| _Attribute..::.Invoke(UInt32, Guid%, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) | (Inherited from Attribute.) | |
| IsDefaultAttribute()()() | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from Attribute.) | |
| Match(Object) | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.) | |
| MemberwiseClone()()() | Creates a shallow copy of the current Object. (Inherited from Object.) | |
| TimeOut |
Gets or sets the fixture timeout in minutes.
(Inherited from TestFixturePatternAttribute.) | |
| ToString()()() | (Inherited from Object.) | |
| TypeId | When implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute.) |
Remarks
Implements: Type Test Pattern
Logic:
{Provider}
[SetUp]
{Test}
[TearDown]
| |
This fixture is quite similar to the Simple Test pattern, but it applies to any instance of a particular type provided by the user.
The test fixture first looks for methods tagged with the ProviderAttribute method. These method must return an object assignable with the tested type. This instance will be feeded to the other methods of the fixture.
Examples
This example shows the squeleton of a fixture tests the IDictionary interface, the fixture implements the Type Test pattern.
The tested instances are feeded by the methods tagged with the ProviderAttribute. These methods must return an instance that is assignable with IDictionary. Subsequent will receive the created instance as parameter.
[TypeFixture(typeof(IDictionary),"IDictionary interface fixture")]
public void DictionaryTest
{
[Provider(typeof(Hashtable))]
public Hashtable ProvideHashtable()
{
return new Hashtable();
}
[Provider(typeof(SortedList))]
public SortedList ProvideSortedList()
{
return new SortedList();
}
// tests
[Test]
[ExpectedException(typeof(ArgumentException))]
public void AddDuplicate(IDictionary dic) // dic comes from a provider class
{
dic.Add("key",null);
dic.Add("key",null); // boom
}
}
| |
Inheritance Hierarchy
System..::.Object
System..::.Attribute
MbUnit.Core.Framework..::.PatternAttribute
MbUnit.Core.Framework..::.TestFixturePatternAttribute
MbUnit.Framework..::.TypeFixtureAttribute
System..::.Attribute
MbUnit.Core.Framework..::.PatternAttribute
MbUnit.Core.Framework..::.TestFixturePatternAttribute
MbUnit.Framework..::.TypeFixtureAttribute
See Also
MbUnit.Framework Namespace