/// <summary>
 /// Check that a managed object has the correct members set.
 /// </summary>
 /// <param name="info">
 /// The managed object to check.
 /// </param>
 private static void CheckManaged(JET_INSTANCE_INFO info)
 {
     Assert.AreEqual(new JET_INSTANCE {
         Value = FakeInstance
     }, info.hInstanceId);
     Assert.AreEqual(InstanceName, info.szInstanceName);
     Assert.AreEqual(2, info.cDatabases);
 }
        /// <summary>
        /// Create a native object, convert it to managed and assert the conversion was sucessful.
        /// </summary>
        /// <param name="stringConverter">
        /// Method used to marshal a managed string.
        /// </param>
        /// <param name="setter">
        /// Method used to convert a native object to a managed object.
        /// </param>
        private static unsafe void TestSetFromNative(Func <string, IntPtr> stringConverter, Action <JET_INSTANCE_INFO, NATIVE_INSTANCE_INFO> setter)
        {
            JET_INSTANCE_INFO managed   = new JET_INSTANCE_INFO();
            IntPtr *          databases = stackalloc IntPtr[2];

            databases[0] = stringConverter(Database0);
            databases[1] = stringConverter(Database1);

            NATIVE_INSTANCE_INFO native = new NATIVE_INSTANCE_INFO
            {
                hInstanceId        = FakeInstance,
                cDatabases         = new IntPtr(2),
                szInstanceName     = stringConverter(InstanceName),
                szDatabaseFileName = databases
            };

            setter(managed, native);
            EseInteropTestHelper.MarshalFreeHGlobal(native.szInstanceName);
            EseInteropTestHelper.MarshalFreeHGlobal(databases[0]);
            EseInteropTestHelper.MarshalFreeHGlobal(databases[1]);

            CheckManaged(managed);
        }
        public void VerifySzDatabasesIsReadOnly()
        {
            var info = new JET_INSTANCE_INFO(JET_INSTANCE.Nil, "instance", new[] { "foo.edb" });

            info.szDatabaseFileName[0] = "bar.edb";
        }
Example #4
0
 /// <summary>
 /// Retrieves the list of instances and databases that are part of the
 /// snapshot session at any given moment.
 /// </summary>
 /// <param name="snapshot">The identifier of the snapshot session.</param>
 /// <param name="numInstances">Returns the number of instances.</param>
 /// <param name="instances">Returns information about the instances.</param>
 /// <param name="grbit">Options for this call.</param>
 public static void JetOSSnapshotGetFreezeInfo(
     JET_OSSNAPID snapshot,
     out int numInstances,
     out JET_INSTANCE_INFO[] instances,
     SnapshotGetFreezeInfoGrbit grbit)
 {
     Api.Check(Api.Impl.JetOSSnapshotGetFreezeInfo(snapshot, out numInstances, out instances, grbit));
 }
Example #5
0
        public void JetInstanceInfoToString()
        {
            var instanceInfo = new JET_INSTANCE_INFO(JET_INSTANCE.Nil, "name", null);

            Assert.AreEqual("JET_INSTANCE_INFO(name)", instanceInfo.ToString());
        }