예제 #1
0
        public virtual void TestExceptionHandling()
        {
            InvocationHandler rtExcHandler = new _InvocationHandler_69();
            DBIterator        dbiter       = (DBIterator)Proxy.NewProxyInstance(typeof(DBIterator).GetClassLoader
                                                                                    (), new Type[] { typeof(DBIterator) }, rtExcHandler);
            LeveldbIterator iter = new LeveldbIterator(dbiter);

            foreach (TestLeveldbIterator.CallInfo ci in RtexcMethods)
            {
                MethodInfo method = iter.GetType().GetMethod(ci.methodName, ci.argTypes);
                NUnit.Framework.Assert.IsNotNull("unable to locate method " + ci.methodName, method
                                                 );
                try
                {
                    method.Invoke(iter, ci.args);
                    NUnit.Framework.Assert.Fail("operation should have thrown");
                }
                catch (TargetInvocationException ite)
                {
                    Exception exc = ite.InnerException;
                    NUnit.Framework.Assert.IsTrue("Method " + ci.methodName + " threw non-DBException: "
                                                  + exc, exc is DBException);
                    NUnit.Framework.Assert.IsFalse("Method " + ci.methodName + " double-wrapped DBException"
                                                   , exc.InnerException is DBException);
                }
            }
            // check close() throws IOException
            try
            {
                iter.Close();
                NUnit.Framework.Assert.Fail("operation shoul have thrown");
            }
            catch (IOException)
            {
            }
        }
예제 #2
0
 /// <summary>Create an iterator for the specified database</summary>
 public LeveldbIterator(DB db, ReadOptions options)
 {
     iter = db.Iterator(options);
 }
예제 #3
0
 /// <summary>Create an iterator using the specified underlying DBIterator</summary>
 public LeveldbIterator(DBIterator iter)
 {
     this.iter = iter;
 }
예제 #4
0
 /// <summary>Create an iterator for the specified database</summary>
 public LeveldbIterator(DB db)
 {
     iter = db.GetEnumerator();
 }