public static void TestExamples() { CallTracer.Start(System.Reflection.MethodBase.GetCurrentMethod()); CallTracer.Output("You should not get any output other than method names in this method context"); BetterExamples(); BadExamples(); CallTracer.End(); }
public static void BetterExamples() { CallTracer.Start(System.Reflection.MethodBase.GetCurrentMethod()); int[] arr = BetterExampleErrorHandling.GetArrayValues(); for (int c1 = 0; c1 < arr.Length; c1++) { CallTracer.Output("Value is " + arr[c1]); } if (BetterExampleErrorHandling.GetStringValue().Length > 0) { CallTracer.Output("Not an empty String"); } CallTracer.End(); }
public static void Assertions() { CallTracer.Start(System.Reflection.MethodBase.GetCurrentMethod()); int param1 = 10; Assert.IsTrue(param1 > 0, new InstantiateException(AssertionFailure.Instantiate)); param1 = -1; CallTracer.Output("No exception at this point"); Assert.IsTrue(param1 > 0, new InstantiateException(AssertionFailure.Instantiate)); CallTracer.End(); }
public static void RunExceptions() { CallTracer.Start(System.Reflection.MethodBase.GetCurrentMethod()); ExceptionExamples obj = new ExceptionExamples(); try { obj.ThrowException(); } catch (Exception ex) { CallTracer.Output("----\n" + ex.TargetSite.ToString() + "\n-----"); CallTracer.Output("----\n" + ex.Source + "\n-----"); CallTracer.Output("----\n" + ex.StackTrace + "\n----"); } CallTracer.End(); }
public static void RunProgramState() { CallTracer.Start(System.Reflection.MethodBase.GetCurrentMethod()); try { ProgramState obj = new ProgramState(); CallTracer.Output("*****************************************"); obj.DoSomething(10, 10); CallTracer.Output("*****************************************"); obj.DoSomething2(0, 0); } catch (Exception ex) { CallTracer.Output("RunProgramState: Caught an exception"); } CallTracer.End(); }
public static void DoSomething() { CallTracer.Start(System.Reflection.MethodBase.GetCurrentMethod()); MyObject obj = new MyObject(); obj.DoSomething(-1); try { obj.DoSomethingAssert(-1); } catch (Exception except) { CallTracer.Output(except.Message); ; } CallTracer.End(); }
public static void ExampleMethod() { CallTracer.Start(System.Reflection.MethodBase.GetCurrentMethod()); int[] args = new int[10]; try { for (int c1 = 0; ; c1++) { try { CallTracer.Output("Counter " + c1); } catch (Exception ex) { ; } args[c1] = 1; } } catch (IndexOutOfRangeException excep) { CallTracer.Output("Yupe hit the end of the array"); } CallTracer.End(); }
public static void BadExamples() { CallTracer.Start(System.Reflection.MethodBase.GetCurrentMethod()); int[] arr = BadExampleErrorHandling.GetArrayValues(); if (arr != null) { for (int c1 = 0; c1 < arr.Length; c1++) { CallTracer.Output("Value is " + arr[c1]); } } string value = BadExampleErrorHandling.GetStringValue(); if (value != null) { if (value.Length > 0) { CallTracer.Output("Not an empty String"); } } CallTracer.End(); }
public static void DifferenceErrorAndException() { CallTracer.Start(System.Reflection.MethodBase.GetCurrentMethod()); Chap02SectImplError.BadExceptionUsage.ExampleMethod(); CallTracer.End(); }