1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
using System;
using NUnit.Framework;
using Mono.Debugger;
using Mono.Debugger.Languages;
using Mono.Debugger.Frontend;
namespace Mono.Debugger.Tests
{
[TestFixture]
public class TestException : TestSuite
{
public TestException ()
: base ("TestException")
{ }
const int LineException = 7;
const int LineMain = 12;
const int LineTry = 14;
const int LineMain2 = 19;
[Test]
[Category("ManagedTypes")]
public void Main ()
{
Process process = Start ();
Assert.IsTrue (process.IsManaged);
Assert.IsTrue (process.MainThread.IsStopped);
Thread thread = process.MainThread;
AssertStopped (thread, "X.Main()", LineMain);
AssertCatchpoint ("InvalidOperationException");
int bpt_main_2 = AssertBreakpoint (LineMain2);
AssertExecute ("continue");
AssertCaughtException (thread, "X.Test()", LineException);
AssertNoTargetOutput ();
Backtrace bt = thread.GetBacktrace (-1);
if (bt.Count != 2)
Assert.Fail ("Backtrace has {0} frames, but expected {1}.",
bt.Count, 2);
AssertFrame (bt [0], 0, "X.Test()", LineException);
AssertFrame (bt [1], 1, "X.Main()", LineTry);
AssertExecute ("continue");
AssertTargetOutput ("EXCEPTION: System.InvalidOperationException");
AssertNoTargetOutput ();
AssertHitBreakpoint (thread, bpt_main_2, "X.Main()", LineMain2);
AssertPrintException (thread, "x.Test()",
"Invocation of `x.Test ()' raised an exception: " +
"System.InvalidOperationException: Operation is not " +
"valid due to the current state of the object\n" +
" at X.Test () [0x00000] in " + FileName + ":" +
LineException + " ");
AssertExecute ("continue");
AssertTargetOutput ("Done");
AssertTargetExited (thread.Process);
}
}
}
|