public override void SelfRegister(TestFixture tf) { tf.AddTestFixtureAttribute(this); }
public abstract void SelfRegister(TestFixture tf);
public override void SelfRegister(TestFixture tf) { mi.ExpectedException=(Attribute)attr; }
public override void SelfRegister(TestFixture tf) { mi.Ignore=true; }
public void ParseAssemblies() { numTests=0; foreach (AssemblyItem ai in assemblyCollection.Values) { foreach (NamespaceItem ni in ai.NamespaceCollection.Values) { foreach (ClassItem ci in ni.ClassCollection.Values) { TestFixture tf=new TestFixture(); foreach (Attribute attr in ci.Attributes) { // verify that attribute class is "UnitTest" string attrStr=attr.ToString(); attrStr=StringHelpers.RightOfRightmostOf(attrStr, '.'); Trace.WriteLine("Class: "+ci.ToString()+", Attribute: "+attrStr); try { if (attr.GetType() == typeof(TestClassAttribute)) { TestUnitAttribute tua = new TestFixtureAttribute(); tua.Initialize(ci, null, attr); tua.SelfRegister(tf); } } catch(Exception e) { Trace.WriteLine("Exception adding attribute: "+e.Message); Trace.WriteLine("Attribute "+attrStr+" is unknown"); } } if (tf.HasTestFixture) { foreach(MethodItem mi in ci.MethodCollection.Values) { foreach (object attr in mi.Attributes) { // verify that attribute class is "UnitTest" string attrStr=attr.ToString(); attrStr=StringHelpers.RightOfRightmostOf(attrStr, '.'); Trace.WriteLine("Method: "+mi.ToString()+", Attribute: "+attrStr); try { if (attr.GetType() == typeof(TestMethodAttribute)) { TestUnitAttribute tua = new TestAttribute(); tua.Initialize(ci, mi, attr); tua.SelfRegister(tf); } else if (attr.GetType() == typeof(PexRaisedExceptionAttribute)) { PexRaisedExceptionAttribute excAttr = (PexRaisedExceptionAttribute)attr; TestUnitAttribute tua = new ExpectedExceptionAttribute(); tua.Initialize(ci, mi, attr); tua.SelfRegister(tf); } } catch(TypeLoadException) { Trace.WriteLine("Attribute "+attrStr+"is unknown"); } } } testFixtureList.Add(tf); numTests+=tf.NumTests; } } } } }