public void TestExecute ( ) { Console.WriteLine ( "测试方法 Execute(object, Type, string, FunctionType, Type[], string, string, string, object[][], bool)" ); try { Student jack = new Student ( "jack", 10 ); Student tom = new Student ( "tom", 9 ); Tracer tracer = new Tracer ( ); tracer.Execute ( jack, null, "GoToSchool", FunctionType.Method, null, null, null, null, new object[][] { new object[] { } }, true ); Console.WriteLine ( "成功: Execute(jack, null, \"GoToSchool\", FunctionType.Method, null, null, null, null, new object[][] { new object[] { } }, true)" ); foreach ( object result in tracer.Execute ( jack, null, "SetName", FunctionType.Method, null, "姓名: {0}", "返回: {0}", "是否测试 SetName ?", new object[][] { new object[] { "jack2" }, new object[] { "jack3" } }, false ) ) Console.WriteLine ( result ); Console.WriteLine ( "成功: Execute(jack, null, \"SetName\", FunctionType.Method, null, \"姓名: <0>\", \"返回: <0>\", \"是否测试 SetName ?\", new object[][] { new object[] { \"jack2\" }, new object[] { \"jack3\" } }, false)" ); foreach ( object result in tracer.Execute ( jack, null, "GetName", FunctionType.Method, new Type[] { }, null, "返回: {0}", null, new object[][] { new object[] { }, new object[] { } }, true ) ) Console.WriteLine ( result ); Console.WriteLine ( "成功: Execute(jack, null, \"GetName\", FunctionType.Method, new Type[] { }, null, \"返回: <0>\", null, new object[][] { new object[] { }, new object[] { } }, true)" ); foreach ( object result in tracer.Execute ( jack, null, "GetName", FunctionType.Method, new Type[] { typeof ( int ) }, null, "返回: {0}", null, new object[][] { new object[] { 1 }, new object[] { 2 } }, true ) ) Console.WriteLine ( result ); Console.WriteLine ( "成功: Execute(jack, null, \"GetName\", FunctionType.Method, new Type[] { typeof(int) }, null, \"返回: <0>\", null, new object[][] { new object[] { 1 }, new object[] { 2 } }, true)" ); foreach ( object result in tracer.Execute ( null, typeof ( Student ), null, FunctionType.Constructor, null, "姓名: {0}, 年龄: {1}", "返回: {0}", null, new object[][] { new object[] { "lili", 11 }, new object[] { string.Empty, 12 } }, true ) ) Console.WriteLine ( result ); Console.WriteLine ( "成功: Execute(null, typeof(Student), null, FunctionType.Constructor, null, \"姓名: <0>, 年龄: <1>\", \"返回: <0>\", null, new object[][] { new object[] { \"lili\", 11 }, new object[] { \"lucy\", 11 } }, true)" ); tracer.Execute ( null, typeof ( Student ), "Print", FunctionType.Method, null, null, null, null, new object[][] { new object[] { jack }, new object[] { tom } }, false ); Console.WriteLine ( "成功: Execute(null, typeof(Student), \"Print\", FunctionType.Method, null, null, null, null, new object[][] { new object[] { jack }, new object[] { tom } }, false)" ); } catch ( Exception err ) { Console.WriteLine ( string.Format ( "异常: {0}", err.Message ) ); } Console.WriteLine ( "请按回车键继续..." ); Console.ReadLine ( ); }
public void TestWaitPressEnter ( ) { Console.WriteLine ( "测试方法 WaitPressEnter()" ); try { Tracer tracer = new Tracer ( ); tracer.WaitPressEnter ( ); Console.WriteLine ( "成功: WaitPressEnter()" ); } catch ( Exception err ) { Console.WriteLine ( string.Format ( "异常: {0}", err.Message ) ); } Console.WriteLine ( "测试方法 WaitPressEnter(bool)" ); try { Tracer tracer = new Tracer ( ); tracer.WaitPressEnter ( isDisplay: true ); Console.WriteLine ( "成功: WaitPressEnter(true)" ); tracer.WaitPressEnter ( isDisplay: false ); Console.WriteLine ( "成功: WaitPressEnter(false)" ); } catch ( Exception err ) { Console.WriteLine ( string.Format ( "异常: {0}", err.Message ) ); } Console.WriteLine ( "测试方法 WaitPressEnter(string)" ); try { Tracer tracer = new Tracer ( ); tracer.WaitPressEnter ( "请按下您的 Enter !!!" ); Console.WriteLine ( "成功: WaitPressEnter(\"请按下您的 Enter !!!\")" ); tracer.WaitPressEnter ( null ); Console.WriteLine ( "成功: WaitPressEnter(null)" ); } catch ( Exception err ) { Console.WriteLine ( string.Format ( "异常: {0}", err.Message ) ); } Console.WriteLine ( "测试方法 WaitPressEnter(string, bool)" ); try { Tracer tracer = new Tracer ( ); tracer.WaitPressEnter ( "请按下您的 Enter !!!", true ); Console.WriteLine ( "成功: WaitPressEnter(\"请按下您的 Enter !!!\", true)" ); tracer.WaitPressEnter ( "请按下您的 Enter !!!", false ); Console.WriteLine ( "成功: WaitPressEnter(\"请按下您的 Enter !!!\", false)" ); tracer.WaitPressEnter ( null, true ); Console.WriteLine ( "成功: WaitPressEnter(null, true)" ); tracer.WaitPressEnter ( null, false ); Console.WriteLine ( "成功: WaitPressEnter(null, false)" ); } catch ( Exception err ) { Console.WriteLine ( string.Format ( "异常: {0}", err.Message ) ); } Console.WriteLine ( "请按回车键继续..." ); Console.ReadLine ( ); }
public void TestWaitInputAChar ( ) { Console.WriteLine ( "测试方法 WaitInputAChar()" ); try { Tracer tracer = new Tracer ( ); Console.WriteLine ( string.Format ( "成功: WaitInputAChar(), 返回: {0}", tracer.WaitInputAChar ( ) ) ); } catch ( Exception err ) { Console.WriteLine ( string.Format ( "异常: {0}", err.Message ) ); } Console.WriteLine ( "测试方法 WaitInputAChar(string)" ); try { Tracer tracer = new Tracer ( ); Console.WriteLine ( string.Format ( "成功: WaitInputAChar(\"请您敲一下\"), 返回: {0}", tracer.WaitInputAChar ( "请您敲一下" ) ) ); Console.WriteLine ( string.Format ( "成功: WaitInputAChar(null), 返回: {0}", tracer.WaitInputAChar ( null ) ) ); } catch ( Exception err ) { Console.WriteLine ( string.Format ( "异常: {0}", err.Message ) ); } Console.WriteLine ( "测试方法 WaitInputAChar(string, bool)" ); try { Tracer tracer = new Tracer ( ); Console.WriteLine ( string.Format ( "成功: WaitInputAChar(\"请您敲一下\", true), 返回: {0}", tracer.WaitInputAChar ( "请您敲一下", isDisplay: true ) ) ); Console.WriteLine ( string.Format ( "成功: WaitInputAChar(\"请您敲一下\", false), 返回: {0}", tracer.WaitInputAChar ( "请您敲一下", isDisplay: false ) ) ); Console.WriteLine ( string.Format ( "成功: WaitInputAChar(null, true), 返回: {0}", tracer.WaitInputAChar ( null, isDisplay: true ) ) ); } catch ( Exception err ) { Console.WriteLine ( string.Format ( "异常: {0}", err.Message ) ); } Console.WriteLine ( "测试方法 WaitInputAChar(string, string)" ); try { Tracer tracer = new Tracer ( ); Console.WriteLine ( string.Format ( "成功: WaitInputAChar(\"请您敲一下\", \"a/b\"), 返回: {0}", tracer.WaitInputAChar ( "请您敲一下", "a/b" ) ) ); Console.WriteLine ( string.Format ( "成功: WaitInputAChar(\"请您敲一下\", null), 返回: {0}", tracer.WaitInputAChar ( "请您敲一下", null ) ) ); Console.WriteLine ( string.Format ( "成功: WaitInputAChar(null, \"a/b\"), 返回: {0}", tracer.WaitInputAChar ( null, "a/b" ) ) ); Console.WriteLine ( string.Format ( "成功: WaitInputAChar(null, null), 返回: {0}", tracer.WaitInputAChar ( null, null ) ) ); } catch ( Exception err ) { Console.WriteLine ( string.Format ( "异常: {0}", err.Message ) ); } Console.WriteLine ( "测试方法 WaitInputAChar(string, string, bool)" ); try { Tracer tracer = new Tracer ( ); Console.WriteLine ( string.Format ( "成功: WaitInputAChar(\"请您敲一下\", \"a/b\", false), 返回: {0}", tracer.WaitInputAChar ( "请您敲一下", "a/b", false ) ) ); Console.WriteLine ( string.Format ( "成功: WaitInputAChar(\"请您敲一下\", null, true), 返回: {0}", tracer.WaitInputAChar ( "请您敲一下", null, true ) ) ); Console.WriteLine ( string.Format ( "成功: WaitInputAChar(null, \"a/b\", false), 返回: {0}", tracer.WaitInputAChar ( null, "a/b", false ) ) ); Console.WriteLine ( string.Format ( "成功: WaitInputAChar(null, null, true), 返回: {0}", tracer.WaitInputAChar ( null, null, true ) ) ); } catch ( Exception err ) { Console.WriteLine ( string.Format ( "异常: {0}", err.Message ) ); } Console.WriteLine ( "请按回车键继续..." ); Console.ReadLine ( ); }
public void TestWriteLine ( ) { Console.WriteLine ( "测试方法 WriteLine()" ); try { Tracer tracer = new Tracer ( ); tracer.WriteLine ( ); } catch ( Exception err ) { Console.WriteLine ( string.Format ( "异常: {0}", err.Message ) ); } Console.WriteLine ( "测试方法 WriteLine(bool)" ); try { Tracer tracer = new Tracer ( ); tracer.WriteLine ( isDisplay: false ); Console.WriteLine ( "成功: WriteLine(false)" ); tracer.WriteLine ( isDisplay: true ); Console.WriteLine ( "成功: WriteLine(true)" ); } catch ( Exception err ) { Console.WriteLine ( string.Format ( "异常: {0}", err.Message ) ); } Console.WriteLine ( "测试方法 WriteLine(int)" ); try { Tracer tracer = new Tracer ( ); tracer.WriteLine ( blankLineCount: 2 ); Console.WriteLine ( "成功: WriteLine(2)" ); tracer.WriteLine ( blankLineCount: 1 ); Console.WriteLine ( "成功: WriteLine(1)" ); tracer.WriteLine ( blankLineCount: 0 ); Console.WriteLine ( "成功: WriteLine(0)" ); } catch ( Exception err ) { Console.WriteLine ( string.Format ( "异常: {0}", err.Message ) ); } Console.WriteLine ( "测试方法 WriteLine(int, bool)" ); try { Tracer tracer = new Tracer ( ); tracer.WriteLine ( blankLineCount: 2, isDisplay: false ); Console.WriteLine ( "成功: WriteLine(2, false)" ); tracer.WriteLine ( blankLineCount: 1, isDisplay: true ); Console.WriteLine ( "成功: WriteLine(1, true)" ); tracer.WriteLine ( blankLineCount: 0, isDisplay: true ); Console.WriteLine ( "成功: WriteLine(0, true)" ); } catch ( Exception err ) { Console.WriteLine ( string.Format ( "异常: {0}", err.Message ) ); } Console.WriteLine ( "测试方法 WriteLine(string)" ); try { Tracer tracer = new Tracer ( ); tracer.WriteLine ( "一行文字" ); Console.WriteLine ( "成功: WriteLine(\"一行文字\")" ); tracer.WriteLine ( null ); Console.WriteLine ( "成功: WriteLine(null)" ); } catch ( Exception err ) { Console.WriteLine ( string.Format ( "异常: {0}", err.Message ) ); } Console.WriteLine ( "测试方法 WriteLine(string, bool)" ); try { Tracer tracer = new Tracer ( ); tracer.WriteLine ( "一行文字", isDisplay: false ); Console.WriteLine ( "成功: WriteLine(\"一行文字\", false)" ); tracer.WriteLine ( "一行文字", isDisplay: true ); Console.WriteLine ( "成功: WriteLine(\"一行文字\", true)" ); tracer.WriteLine ( null, isDisplay: true ); Console.WriteLine ( "成功: WriteLine(null, true)" ); } catch ( Exception err ) { Console.WriteLine ( string.Format ( "异常: {0}", err.Message ) ); } Console.WriteLine ( "测试方法 WriteLine(string, int)" ); try { Tracer tracer = new Tracer ( ); tracer.WriteLine ( "一行文字", 3 ); Console.WriteLine ( "成功: WriteLine(\"一行文字\", 3)" ); tracer.WriteLine ( "一行文字", -1 ); Console.WriteLine ( "成功: WriteLine(\"一行文字\", -1)" ); tracer.WriteLine ( null, 2 ); Console.WriteLine ( "成功: WriteLine(null, 2)" ); } catch ( Exception err ) { Console.WriteLine ( string.Format ( "异常: {0}", err.Message ) ); } Console.WriteLine ( "测试方法 WriteLine(string, int, bool)" ); try { Tracer tracer = new Tracer ( ); tracer.WriteLine ( "一行文字", 5, true ); Console.WriteLine ( "成功: WriteLine(\"一行文字\", 5, true)" ); tracer.WriteLine ( "一行文字", -1, true ); Console.WriteLine ( "成功: WriteLine(\"一行文字\", -1, true)" ); tracer.WriteLine ( "一行文字", 3, false ); Console.WriteLine ( "成功: WriteLine(\"一行文字\", 3, false)" ); tracer.WriteLine ( null, 2, true ); Console.WriteLine ( "成功: WriteLine(null, 2, true)" ); } catch ( Exception err ) { Console.WriteLine ( string.Format ( "异常: {0}", err.Message ) ); } Console.WriteLine ( "请按回车键继续..." ); Console.ReadLine ( ); }