static void RunSpecification(factory_application_service_spec specification) { Console.WriteLine(new string('=', 80)); var cases = specification.GetType() .GetMethods().Where(m => m.IsDefined(typeof(TestAttribute), true)); Print(ConsoleColor.DarkGreen, "Fixture: {0}", specification.GetType().Name.Replace('_', ' ')); foreach (var methodInfo in cases) { Console.WriteLine(new string('-', 80)); var name = methodInfo.Name; Console.WriteLine(); try { specification.GetSpecificationName = () => name; specification.SetUpSpecification(); methodInfo.Invoke(specification, null); Print(ConsoleColor.DarkGreen, "\r\nPASSED!"); } catch (TargetInvocationException ex) { Print(ConsoleColor.DarkRed, "\r\nFAIL! " + ex.InnerException.Message); } catch (Exception ex) { Print(ConsoleColor.DarkRed, "\r\nFAIL! " + ex.Message); } finally { specification.TeardownSpecification(); } } }
static void RunSpecification(factory_application_service_spec specification) { Console.WriteLine(new string('=', 80)); var cases = specification.GetType() .GetMethods().Where(m => m.IsDefined(typeof(TestAttribute), true)); Print(ConsoleColor.DarkGreen, "Fixture: {0}", specification.GetType().Name.Replace('_', ' ')); foreach (var methodInfo in cases) { Console.WriteLine(new string('-', 80)); var name = methodInfo.Name; Console.WriteLine(); try { specification.GetSpecificationName = () => name; specification.SetUpSpecification(); methodInfo.Invoke(specification, null); Print(ConsoleColor.DarkGreen, "\r\nPASSED!"); } catch(TargetInvocationException ex) { Print(ConsoleColor.DarkRed, "\r\nFAIL! " + ex.InnerException.Message); } catch (Exception ex) { Print(ConsoleColor.DarkRed, "\r\nFAIL! " + ex.Message); } finally { specification.TeardownSpecification(); } } }