Exemplo n.º 1
0
        public void CreateAllErrorExceptions()
        {
            int i = 0;

            foreach (JET_err err in Enum.GetValues(typeof(JET_err)))
            {
                if (JET_err.Success != err)
                {
                    EsentErrorException ex = EsentExceptionHelper.JetErrToException(err);
                    Assert.IsNotNull(ex);
                    Assert.AreEqual(err, ex.Error);
                    Assert.IsNotNull(ex.Message);
                    Assert.AreNotEqual(string.Empty, ex.Message);

#if MANAGEDESENT_ON_CORECLR
#else
                    EsentErrorException deserialized = SerializeDeserialize(ex);
                    Assert.AreEqual(err, deserialized.Error);
                    Assert.AreEqual(ex.Message, deserialized.Message);
#endif
                    i++;
                }
            }

            EseInteropTestHelper.ConsoleWriteLine("Created {0} different error exceptions", i);
        }
Exemplo n.º 2
0
        public void CreateAllErrorExceptions()
        {
            int i = 0;

            foreach (JET_err err in Enum.GetValues(typeof(JET_err)))
            {
                if (JET_err.Success != err)
                {
                    EsentErrorException ex = EsentExceptionHelper.JetErrToException(err);
                    Assert.IsNotNull(ex);
                    Assert.AreEqual(err, ex.Error);
                    Assert.IsNotNull(ex.Message);
                    Assert.AreNotEqual(String.Empty, ex.Message);

                    EsentErrorException deserialized = SerializeDeserialize(ex);
                    Assert.AreEqual(err, deserialized.Error);
                    Assert.AreEqual(ex.Message, deserialized.Message);
                    i++;
                }
            }

            Console.WriteLine("Created {0} different error exceptions", i);
        }
Exemplo n.º 3
0
        public void VerifyEsentErrorExceptionHasDefaultErrorDescription()
        {
            var mocks         = new MockRepository();
            var mockApi       = mocks.StrictMock <IJetApi>();
            var rawErrorValue = new IntPtr(-9999);

            using (new ApiTestHook(mockApi))
            {
                Expect.Call(
                    mockApi.JetGetSystemParameter(
                        Arg <JET_INSTANCE> .Is.Anything,
                        Arg <JET_SESID> .Is.Anything,
                        Arg <JET_param> .Is.Equal(JET_param.ErrorToString),
                        ref Arg <IntPtr> .Ref(Is.Equal(rawErrorValue), rawErrorValue).Dummy,
                        out Arg <string> .Out(null).Dummy,
                        Arg <int> .Is.Anything))
                .Return((int)JET_err.InvalidParameter);
                mocks.ReplayAll();

                var ex = EsentExceptionHelper.JetErrToException((JET_err)(-9999));
                Assert.IsTrue(!String.IsNullOrEmpty(ex.Message));
            }
        }
Exemplo n.º 4
0
        public void VerifyUnknownEsentErrorExceptionGetsErrorDescriptionFromSystemParameter()
        {
            var mocks         = new MockRepository();
            var mockApi       = mocks.StrictMock <IJetApi>();
            var rawErrorValue = new IntPtr(-9999);

            using (new ApiTestHook(mockApi))
            {
                const string ExpectedDescription = "Error Description";
                Expect.Call(
                    mockApi.JetGetSystemParameter(
                        Arg <JET_INSTANCE> .Is.Anything,
                        Arg <JET_SESID> .Is.Anything,
                        Arg <JET_param> .Is.Equal(JET_param.ErrorToString),
                        ref Arg <IntPtr> .Ref(Is.Equal(rawErrorValue), rawErrorValue).Dummy,
                        out Arg <string> .Out(ExpectedDescription).Dummy,
                        Arg <int> .Is.Anything))
                .Return((int)JET_err.Success);
                mocks.ReplayAll();

                var ex = EsentExceptionHelper.JetErrToException((JET_err)(-9999));
                Assert.AreEqual(ExpectedDescription, ex.Message);
            }
        }