-
Notifications
You must be signed in to change notification settings - Fork 538
/
Copy pathExceptionTests.cs
54 lines (44 loc) · 1.13 KB
/
ExceptionTests.cs
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
using System;
using NUnit.Framework;
using Android.Graphics;
using Android.Runtime;
using Com.Xamarin.Android;
namespace Xamarin.Android.JcwGenTests {
[TestFixture]
public class ExceptionTests {
[Test]
public void ManagedJavaManaged_FinallyExecuted ()
{
using (var t = new Bxc7634 ()) {
using (var r = new MyGenericRunnable<int> ()) {
Assert.IsFalse (t.FinallyBlockRun);
bool ioeThrown = false;
try {
t.RunFinallyBlock (r);
} catch (InvalidOperationException) {
ioeThrown = true;
}
Assert.IsTrue (ioeThrown);
}
Assert.IsTrue (t.FinallyBlockRun);
}
}
[Test]
public void ManagedJavaManaged_JavaCatches ()
{
using (var t = new Bxc7634 ()) {
using (var r = new Java.Lang.Runnable (() => {throw new InvalidOperationException ();})) {
t.RunCatchBlock (r);
}
Assert.IsNotNull (t.ThrowableCaught);
Assert.AreEqual ("Android.Runtime.JavaProxyThrowable", t.ThrowableCaught.GetType ().FullName);
}
}
class MyGenericRunnable<T> : Java.Lang.Object, Java.Lang.IRunnable {
public void Run ()
{
throw new InvalidOperationException ();
}
}
}
}