protected static void Initialize(string[] args) { InitLogger(); ArgsParsedError += delegate(ParsedArguments a) { throw new ArgumentException(a.Message); }; ArgsParsed += new ConsoleArgsParsedDelegate(ArgumentParsingComplete); interactive = false; AddValidArgument("i", true); ParseArgs(args); TestFailed += (o, t) => { Out("Test Failed: " + t.ConsoleInvokeableMethod.Information + "\r\n", ConsoleTextColor.Red); Out(t.Exception.Message, ConsoleTextColor.Magenta); Out(); Out(t.Exception.StackTrace, ConsoleTextColor.Red); Out("---", ConsoleTextColor.Red); Out(); }; if (!Arguments.Contains("i")) { if (DefaultMethod != null) { Expect.IsTrue(DefaultMethod.IsStatic, "DefaultMethod must be static."); Expect.AreEqual(0, DefaultMethod.GetParameters().Length, "The DefaultMethod must take no parameters."); DefaultMethod.Invoke(null, null); return; } else { RunAllTests(Assembly.GetEntryAssembly()); return; } } Interactive(); }
public static void Initialize(string[] args, ConsoleArgsParsedDelegate parseErrorHandler = null) { AssemblyResolve.Monitor(() => { ILogger logger = Logger; if (logger == null) { logger = new ConsoleLogger { AddDetails = false }; logger.StartLoggingThread(); } return(logger); }); if (parseErrorHandler == null) { parseErrorHandler = (a) => { throw new ArgumentException(a.Message); }; } ArgsParsedError += parseErrorHandler; AddValidArgument("i", true, description: "Run interactively"); AddValidArgument("?", true, description: "Show usage"); AddValidArgument("t", true, description: "Run all unit tests"); AddValidArgument("it", true, description: "Run all integration tests"); ParseArgs(args); if (Arguments.Contains("?")) { Usage(Assembly.GetEntryAssembly()); Exit(); } else if (Arguments.Contains("i")) { Interactive(); return; } else if (Arguments.Contains("t")) { RunAllUnitTests(Assembly.GetEntryAssembly()); return; } else if (Arguments.Contains("it")) { IntegrationTestRunner.RunIntegrationTests(Assembly.GetEntryAssembly()); return; } else { if (DefaultMethod != null) { Expect.IsTrue(DefaultMethod.IsStatic, "DefaultMethod must be static."); if (DefaultMethod.GetParameters().Length > 0) { DefaultMethod.Invoke(null, new object[] { Arguments }); } else { DefaultMethod.Invoke(null, null); } return; } } }
protected static void Initialize(string[] args) { InitLogger(); ArgsParsedError += delegate(ParsedArguments a) { throw new ArgumentException(a.Message); }; ArgsParsed += new ConsoleArgsParsedDelegate(ArgumentParsingComplete); interactive = false; AddValidArgument("i", true); ParseArgs(args); TestFailed += (o, t) => { Out("Test Failed: " + t.ConsoleInvokeableMethod.Information + "\r\n", ConsoleTextColor.Red); Out(t.Exception.Message, ConsoleTextColor.Magenta); Out(); Out(t.Exception.StackTrace, ConsoleTextColor.Red); Out("---", ConsoleTextColor.Red); Out(); }; if (!Arguments.Contains("i")) { if (DefaultMethod != null) { Expect.IsTrue(DefaultMethod.IsStatic, "DefaultMethod must be static."); Expect.AreEqual(0, DefaultMethod.GetParameters().Length, "The DefaultMethod must take no parameters."); DefaultMethod.Invoke(null, null); return; } else { RunAllTests(Assembly.GetEntryAssembly()); return; } } Interactive(); }