using System.Collections.Generic;
public string Name { get; set; }
public class Dog : Animal
public static void Main()
var dog = new Dog{ Name = "Snoop" };
Console.WriteLine(dog.Name);
var testRunner = new TestRunner();
var res = testRunner.GetResults();
Console.WriteLine("Tests passed: "+(res.Count==0));
Console.WriteLine("Test error: "+ex.InnerException.Message);
public void ClassAnimalExists()
var animal = Type.GetType("Animal");
if(animal==null) throw new Exception("Type Animal not found");
public void ClassDogExists()
var animal = Type.GetType("Dog");
if(animal==null) throw new Exception("Type Dog not found");
public void OutputIsSnoop()
if(output!="Snoop") throw new Exception("Type output is not Snoop: "+output);
public List<Exception> GetResults()
var types = Assembly.GetExecutingAssembly().GetTypes();
var results = new List<Exception>();
foreach(var type in types)
if(type.GetCustomAttribute(typeof(TestFixtureAttribute))!=null)
var instance = Activator.CreateInstance(type);
var methods = type.GetMethods();
foreach(var method in methods)
if(method.GetCustomAttribute(typeof(TestAttribute))!=null)
method.Invoke(instance, null);
public class TestFixtureAttribute: Attribute
public class TestAttribute: Attribute