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 RegisterWithRuntime()
 {
     using (var Object_class = new JniType("java/lang/Object")) {
         Assert.AreEqual(JniObjectReferenceType.Global, Object_class.PeerReference.Type);
         var cur = Object_class.PeerReference;
         Object_class.RegisterWithRuntime();
         Assert.AreEqual(JniObjectReferenceType.Global, Object_class.PeerReference.Type);
         Assert.IsTrue(Object_class.PeerReference.IsValid);
     }
 }