Inheritance: EsentException
Ejemplo n.º 1
0
        public void VerifyEsentErrorExceptionSerializationPreservesError()
        {
            var originalException = new EsentErrorException(JET_err.VersionStoreOutOfMemory);

            var stream = new MemoryStream();

            var formatter = new BinaryFormatter();
            formatter.Serialize(stream, originalException);

            stream.Position = 0; // rewind

            var deserializedException = (EsentErrorException)formatter.Deserialize(stream);
            Assert.AreEqual(originalException.Error, deserializedException.Error);
        }
Ejemplo n.º 2
0
 public void VerifyEsentErrorExceptionHasMessage()
 {
     var ex = new EsentErrorException(JET_err.AccessDenied);
     Assert.IsNotNull(ex.Message);
 }
Ejemplo n.º 3
0
        public void VerifyEsentErrorExceptionHasDefaultErrorDescription()
        {
            var mocks = new MockRepository();
            var mockApi = mocks.StrictMock<IJetApi>();
            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<int>.Ref(Is.Equal((int)JET_err.OutOfMemory), (int)JET_err.OutOfMemory).Dummy,
                        out Arg<string>.Out(null).Dummy,
                        Arg<int>.Is.Anything))
                    .Return((int)JET_err.InvalidParameter);
                mocks.ReplayAll();

                var ex = new EsentErrorException(JET_err.OutOfMemory);
                Assert.IsTrue(!String.IsNullOrEmpty(ex.ErrorDescription));
            }
        }
Ejemplo n.º 4
0
        public void VerifyEsentErrorExceptionConstructorSetsError()
        {
            var ex = new EsentErrorException(JET_err.AccessDenied);

            Assert.AreEqual(JET_err.AccessDenied, ex.Error);
        }
Ejemplo n.º 5
0
        public void VerifyEsentErrorExceptionGetsErrorDescriptionFromSystemParameter()
        {
            var mocks = new MockRepository();
            var mockApi = mocks.StrictMock<IJetApi>();
            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<int>.Ref(Is.Equal((int)JET_err.OutOfMemory), (int)JET_err.OutOfMemory).Dummy,
                        out Arg<string>.Out(ExpectedDescription).Dummy,
                        Arg<int>.Is.Anything))                
                    .Return((int)JET_err.Success);
                mocks.ReplayAll();

                var ex = new EsentErrorException(JET_err.OutOfMemory);
                Assert.AreEqual(ExpectedDescription, ex.ErrorDescription);
            }
        }