using UnitTestSharp; using System.Collections.Generic; using System.Reflection; namespace TestsForUnitTestSharp { public class TestFinderTests : TestFixture { public void FindTestsToRun_Test() { System.Type[] types = { this.GetType(), typeof(UnitTestSharp.Assert) }; types = TestFinder.FindFixturesToTest(types); CheckEqual(1, types.Length); CheckEqual(this.GetType(), types[0]); } public void FindTestsToRun_TestZeroLength() { System.Type[] types = { }; types = TestFinder.FindFixturesToTest(types); CheckEqual(0, types.Length); } public void FindTestsToRun_TestNull() { CheckEqual(0, TestFinder.FindFixturesToTest(null).Length); } [IgnoreFixture] class FauxFixture : TestFixture { } public void FindTestsToRun_IgnoreFixture() { System.Type[] types = { typeof(FauxFixture) }; types = TestFinder.FindFixturesToTest(types); CheckEqual(0, types.Length); } class OverrideFixture : TestFixture { public override void FixtureSetup() { } public override void FixtureTeardown() { } public override void TestSetup() { } public override void TestTeardown() { } public override bool Equals(object obj) { return base.Equals(obj); } public override int GetHashCode() { return base.GetHashCode(); } public override string ToString() { return base.ToString(); } public void Test() { } } public void DoesNotFindOverrides() { System.Type[] types = { typeof(OverrideFixture) }; List missingIgnoreAttr = new List(); int ignored; var methods = TestFinder.FindTestableMethodsInFixture(types[0], ref missingIgnoreAttr, out ignored); CheckEqual(1, methods.Count); CheckEqual("Test", methods[0].Name); } } }