Ejemplo n.º 1
0
        public unsafe void Dispose_Exceptions()
        {
            var t = new JniType("java/lang/Object");

            t.Dispose();
            Assert.Throws <ObjectDisposedException> (() => t.AllocObject());
            Assert.Throws <ObjectDisposedException> (() => t.NewObject(null, null));
            Assert.Throws <ObjectDisposedException> (() => t.GetConstructor(null));
            Assert.Throws <ObjectDisposedException> (() => t.GetInstanceField(null, null));
            Assert.Throws <ObjectDisposedException> (() => t.GetInstanceMethod(null, null));
            Assert.Throws <ObjectDisposedException> (() => t.GetStaticField(null, null));
            Assert.Throws <ObjectDisposedException> (() => t.GetStaticMethod(null, null));
            Assert.Throws <ObjectDisposedException> (() => t.GetSuperclass());
            Assert.Throws <ObjectDisposedException> (() => t.IsAssignableFrom(null));
            Assert.Throws <ObjectDisposedException> (() => t.IsInstanceOfType(new JniObjectReference()));
            Assert.Throws <ObjectDisposedException> (() => t.RegisterWithRuntime());
            Assert.Throws <ObjectDisposedException> (() => t.RegisterNativeMethods(null));
            Assert.Throws <ObjectDisposedException> (() => t.UnregisterNativeMethods());

            JniFieldInfo jif = null;

            Assert.Throws <ObjectDisposedException> (() => t.GetCachedInstanceField(ref jif, null, null));
            JniMethodInfo jim = null;

            Assert.Throws <ObjectDisposedException> (() => t.GetCachedConstructor(ref jim, null));
            Assert.Throws <ObjectDisposedException> (() => t.GetCachedInstanceMethod(ref jim, null, null));
            JniFieldInfo jsf = null;

            Assert.Throws <ObjectDisposedException> (() => t.GetCachedStaticField(ref jsf, null, null));
            JniMethodInfo jsm = null;

            Assert.Throws <ObjectDisposedException> (() => t.GetCachedStaticMethod(ref jsm, null, null));
        }
Ejemplo n.º 2
0
 public void GetSuperclass()
 {
     using (var t = new JniType("java/lang/Object")) {
         var b = t.GetSuperclass();
         Assert.IsNull(b);
         using (var s = new JniType("java/lang/String")) {
             using (var st = s.GetSuperclass()) {
                 Assert.IsFalse(object.ReferenceEquals(t, st));
                 Assert.IsTrue(JniEnvironment.Types.IsSameObject(t.PeerReference, st.PeerReference));
             }
         }
     }
 }