ConstructFixtureCommand
ConstructFixtureCommand constructs the user test object if necessary.
using NUnit.Framework.Interfaces;
namespace NUnit.Framework.Internal.Commands
{
public class ConstructFixtureCommand : BeforeTestCommand
{
public ConstructFixtureCommand(TestCommand innerCommand)
: base(innerCommand)
{
Guard.ArgumentValid(base.Test is TestSuite, "ConstructFixtureCommand must reference a TestSuite", "innerCommand");
BeforeTest = delegate(TestExecutionContext context) {
ITypeInfo typeInfo = base.Test.TypeInfo;
if (typeInfo != null && !typeInfo.IsStaticClass) {
context.TestObject = (base.Test.Fixture ?? typeInfo.Construct(((TestSuite)base.Test).Arguments));
if (base.Test.Fixture == null)
base.Test.Fixture = context.TestObject;
}
};
}
}
}