StackTraceTest.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //
  2. // MonoTests.System.Diagnostics.StackTraceTest.cs
  3. //
  4. // Author:
  5. // Alexander Klyubin ([email protected])
  6. //
  7. // (C) 2001
  8. //
  9. using System;
  10. using System.Diagnostics;
  11. using System.Reflection;
  12. using NUnit.Framework;
  13. namespace MonoTests.System.Diagnostics {
  14. /// <summary>
  15. /// Tests the case where StackTrace is created for specified
  16. /// stack frame.
  17. /// </summary>
  18. [TestFixture]
  19. public class StackTraceTest1 : TestCase {
  20. private StackTrace trace;
  21. private StackFrame frame;
  22. protected override void SetUp() {
  23. frame = new StackFrame("dir/someFile",
  24. 13,
  25. 45);
  26. trace = new StackTrace(frame);
  27. }
  28. protected override void TearDown() {
  29. trace = null;
  30. }
  31. /// <summary>
  32. /// Tests whether getting number of frames works.
  33. /// </summary>
  34. public void TestFrameCount() {
  35. AssertEquals("Frame count",
  36. 1,
  37. trace.FrameCount);
  38. }
  39. /// <summary>
  40. /// Tests whether getting frames by index which is out of
  41. /// range works.
  42. /// </summary>
  43. public void TestGetFrameOutOfRange() {
  44. Assert("Frame with index -1 == null",
  45. (trace.GetFrame(-1) == null));
  46. Assert("Frame with index -129 = null",
  47. (trace.GetFrame(-129) == null));
  48. Assert("Frame with index 1 = null",
  49. (trace.GetFrame(1) == null));
  50. Assert("Frame with index 145 = null",
  51. (trace.GetFrame(145) == null));
  52. }
  53. /// <summary>
  54. /// Tests whether getting frames by index works.
  55. /// </summary>
  56. public void TestGetFrame() {
  57. AssertEquals("Frame with index 0",
  58. frame,
  59. trace.GetFrame(0));
  60. }
  61. }
  62. }