Esempio n. 1
0
        public void VerifyWrapperCallsCallback()
        {
            bool callbackWasCalled = false;
            var wrapper = new JetCallbackWrapper(
                (sesid, dbid, tableid, cbtyp, arg1, arg2, context, unused) =>
                {
                    callbackWasCalled = true;
                    return JET_err.Success;
                });

            wrapper.NativeCallback(IntPtr.Zero, 0, IntPtr.Zero, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
            Assert.IsTrue(callbackWasCalled);
        }
Esempio n. 2
0
        public void VerifyWrapperReturnsReturnCode()
        {
            var wrapper = new JetCallbackWrapper(
                (sesid, dbid, tableid, cbtyp, arg1, arg2, context, unused) => JET_err.WriteConflict);

            Assert.AreEqual(
                JET_err.WriteConflict,
                wrapper.NativeCallback(IntPtr.Zero, 0, IntPtr.Zero, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero));
        }
Esempio n. 3
0
        public void VerifyWrapperPassesArguments()
        {
            JET_SESID expectedSesid = new JET_SESID { Value = (IntPtr)1 };
            JET_DBID expectedDbid = new JET_DBID { Value = 2 };
            JET_TABLEID expectedTableid = new JET_TABLEID { Value = (IntPtr)3 };
            JET_cbtyp expectedCbtyp = JET_cbtyp.AfterReplace;
            object expectedArg1 = null;
            object expectedArg2 = null;
            IntPtr expectedContext = (IntPtr)4;

            JET_SESID actualSesid = new JET_SESID();
            JET_DBID actualDbid = new JET_DBID();
            JET_TABLEID actualTableid = new JET_TABLEID();
            JET_cbtyp actualCbtyp = JET_cbtyp.Null;
            object actualArg1 = null;
            object actualArg2 = null;
            IntPtr actualContext = new IntPtr();

            var wrapper = new JetCallbackWrapper(
                (sesid, dbid, tableid, cbtyp, arg1, arg2, context, unused) =>
                {
                    actualSesid = sesid;
                    actualDbid = dbid;
                    actualTableid = tableid;
                    actualCbtyp = cbtyp;
                    actualArg1 = arg1;
                    actualArg2 = arg2;
                    actualContext = context;
                    return JET_err.Success;
                });

            wrapper.NativeCallback(
                expectedSesid.Value,
                expectedDbid.Value,
                expectedTableid.Value,
                (uint)expectedCbtyp,
                IntPtr.Zero,
                IntPtr.Zero,
                expectedContext,
                IntPtr.Zero);

            Assert.AreEqual(expectedSesid, actualSesid);
            Assert.AreEqual(expectedDbid, actualDbid);
            Assert.AreEqual(expectedTableid, actualTableid);
            Assert.AreEqual(expectedCbtyp, actualCbtyp);
            Assert.AreEqual(expectedArg1, actualArg1);
            Assert.AreEqual(expectedArg2, actualArg2);
            Assert.AreEqual(expectedContext, actualContext);
        }
Esempio n. 4
0
        public void VerifyExceptionInCallbackIsCaught()
        {
            var wrapper = new JetCallbackWrapper(
                (sesid, dbid, tableid, cbtyp, arg1, arg2, context, unused) =>
                {
                    throw new ArgumentNullException();
                });

            Assert.AreEqual(
                JET_err.CallbackFailed,
                wrapper.NativeCallback(IntPtr.Zero, 0, IntPtr.Zero, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero));
        }