﻿using System;
using System.Linq;
using System.Reflection;

namespace TDDUnit {
  class Runner {
    public Runner(Type exceptType) {
      Suite suite = new Suite();
      m_result = new Result();

      foreach (Type t in Assembly.GetEntryAssembly().GetTypes()) {
        if (t.Name.StartsWith("Test") && t.Name != exceptType.Name)
          suite.Add(t);
      }

      foreach (string test in suite.FailedTests(m_result)) {
        Console.WriteLine("Failed: " + test);
      }
      Console.WriteLine(m_result.Summary);
    }

    public string Summary {
      get {
        return m_result.Summary;
      }
    }

    private Result m_result;
  }
}

﻿using System;
using System.Linq;
using System.Reflection;

namespace TDDUnit {
  class Runner {
    public Runner(Type callingType) {
      Suite suite = new Suite();
      m_result = new Result();
      Type[] forbiddenTypes = new Type[] {
        callingType
      , typeof (TDDUnit.WasRunObj)
      , typeof (TDDUnit.WasRunSetUpFailed)
      };

      foreach (Type t in Assembly.GetEntryAssembly().GetTypes()) {
        if (t.IsSubclassOf(typeof (TDDUnit.Case)) && !forbiddenTypes.Contains(t))
          suite.Add(t);
      }

      foreach (string test in suite.FailedTests(m_result)) {
        Console.WriteLine("Failed: " + test);
      }
      Console.WriteLine(m_result.Summary);
    }

    public string Summary {
      get {
        return m_result.Summary;
      }
    }

    private Result m_result;
  }
}

Add test cases based on inheritance from Case
Add test cases based on inheritance from Case

Make the Runner object add test cases based on their inheritance from
   the base Case class. With this method, we have to forbid the object
   from adding the tests of its calling type (since they're already
   being run), and of a couple of helper types that we use to test the
   TDDUnit library itself.
