Ejemplo n.º 1
0
        public void JetSignatureToString()
        {
            var t         = new DateTime(2010, 5, 31, 4, 44, 17, 678, DateTimeKind.Utc);
            var signature = new JET_SIGNATURE(99, t, "COMPUTER");

            Assert.AreEqual("JET_SIGNATURE(99:2010-05-31T04:44:17.6780000Z:COMPUTER)", signature.ToString());
        }
Ejemplo n.º 2
0
        public void CreateNativeSignatureFromJetSignature()
        {
            var time = new DateTime(2037, 10, 29, 02, 00, 00, DateTimeKind.Utc);

            var expected = new JET_SIGNATURE(37, time, "retupmoc");

            var native = expected.GetNativeSignature();
            var actual = new JET_SIGNATURE(native);
            Assert.AreEqual(expected, actual);
            Assert.IsTrue(expected.Equals(actual));
        }
Ejemplo n.º 3
0
        public void CreateNativeSignatureFromJetSignature()
        {
            var time = new DateTime(2037, 10, 29, 02, 00, 00, DateTimeKind.Utc);

            var expected = new JET_SIGNATURE(37, time, "retupmoc");

            var native = expected.GetNativeSignature();
            var actual = new JET_SIGNATURE(native);

            Assert.AreEqual(expected, actual);
            Assert.IsTrue(expected.Equals(actual));
        }
        public void JetCommitIdToString()
        {
            DateTime      d         = DateTime.Now;
            JET_COMMIT_ID commitId  = DurableCommitTests.CreateJetCommitId(1, d, "computer", 2);
            var           signature = new JET_SIGNATURE(1, d, "computer");

            string sigString = signature.ToString();
            string expected  = string.Format(
                CultureInfo.InvariantCulture,
                string.Format("JET_COMMIT_ID({0}:2", sigString));

            Assert.AreEqual(expected, commitId.ToString());
        }
Ejemplo n.º 5
0
        public void CreateJetSignatureFromNativeSignature()
        {
            var t = new DateTime(1999, 12, 31, 23, 59, 59, DateTimeKind.Utc);

            var native = new NATIVE_SIGNATURE
            {
                ulRandom = 9,
                logtimeCreate = new JET_LOGTIME(t),
            };

            native.szComputerName = "COMPUTER";

            var expected = new JET_SIGNATURE(9, t, "COMPUTER");
            var actual = new JET_SIGNATURE(native);
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 6
0
 public StorageGroupBackup(string serverName, Guid guidReplica, JET_SIGNATURE logfileSignature, long lowestGenerationRequired, long highestGenerationRequired, string destinationLogPath, string logFilePrefix, string logExtension, [MarshalAs(UnmanagedType.U1)] bool fIsPassive)
 {
     this.m_serverName                = serverName;
     this.m_guidSGIdentityGuid        = guidReplica;
     this.m_fComponentBackup          = true;
     this.m_logfileSignature          = logfileSignature;
     this.m_lowestGenerationRequired  = lowestGenerationRequired;
     this.m_highestGenerationRequired = highestGenerationRequired;
     this.m_fFrozen = false;
     this.m_fSurrogateBackupBegun = false;
     this.m_hccx = null;
     this.m_destinationLogPath = destinationLogPath;
     this.m_logFilePrefix      = logFilePrefix;
     this.m_logExtension       = logExtension;
     this.m_fIsPassive         = fIsPassive;
 }
Ejemplo n.º 7
0
        public void CreateJetSignatureFromNativeSignature()
        {
            var t = new DateTime(1999, 12, 31, 23, 59, 59, DateTimeKind.Utc);

            var native = new NATIVE_SIGNATURE
            {
                ulRandom      = 9,
                logtimeCreate = new JET_LOGTIME(t),
            };

            native.szComputerName = "COMPUTER";

            var expected = new JET_SIGNATURE(9, t, "COMPUTER");
            var actual   = new JET_SIGNATURE(native);

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Helper method to create a JET_COMMIT_ID using reflection.
        /// </summary>
        /// <param name="random">Random number.</param>
        /// <param name="time">Time to use.</param>
        /// <param name="computer">Computer name.</param>
        /// <param name="commitId">Commit id to use.</param>
        /// <returns>Jet-commit-id created.</returns>
        internal static JET_COMMIT_ID CreateJetCommitId(int random, DateTime?time, string computer, long commitId)
        {
            var sign = new JET_SIGNATURE(random, time, computer);

#if MANAGEDESENT_ON_CORECLR
            // Use a special test-only constructor.
            return(new JET_COMMIT_ID(sign, commitId));
#else
            object nativeSign = sign.GetType().GetMethod("GetNativeSignature", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(sign, null);

            string assemblyName   = sign.GetType().Assembly.FullName;
            object nativeCommitId = Activator.CreateInstance(assemblyName, "Microsoft.Isam.Esent.Interop.Windows8.NATIVE_COMMIT_ID").Unwrap();
            nativeCommitId.GetType().GetField("signLog").SetValue(nativeCommitId, nativeSign);
            nativeCommitId.GetType().GetField("commitId").SetValue(nativeCommitId, commitId);
            object[] args = { nativeCommitId };
            return((JET_COMMIT_ID)Activator.CreateInstance(assemblyName, "Microsoft.Isam.Esent.Interop.Windows8.JET_COMMIT_ID", false, BindingFlags.Instance | BindingFlags.NonPublic, null, args, null, null).Unwrap());
#endif
        }
Ejemplo n.º 9
0
        public void JetSignatureSerialization()
        {
            var time = new DateTime(2037, 10, 29, 02, 00, 00, DateTimeKind.Utc);

            var expected = new JET_SIGNATURE(37, time, "MaxStringLength");

            var bytes  = expected.ToBytes();
            var actual = new JET_SIGNATURE(bytes);

            Assert.IsTrue(expected == actual);
            Assert.IsTrue(bytes.Length == 28);
            Assert.IsTrue(bytes[bytes.Length - 1] == 0);

            for (int i = 0; i < bytes.Length * 8; i++)
            {
                bytes[i / 8] ^= (byte)(1 << (i % 8));

                Assert.IsTrue(expected != new JET_SIGNATURE(bytes) || i >= (bytes.Length - 1) * 8);

                bytes[i / 8] ^= (byte)(1 << (i % 8));
            }

            for (int i = bytes.Length; i >= 0; i--)
            {
                Array.Resize(ref bytes, i);
                try
                {
                    Assert.IsTrue(expected == new JET_SIGNATURE(bytes));
                    Assert.IsTrue(i >= 28);
                }
                catch (System.ArgumentOutOfRangeException)
                {
                    Assert.IsTrue(i < 28);
                }
            }
        }
Ejemplo n.º 10
0
        public void VerifySignLog()
        {
            var expected = new JET_SIGNATURE(this.native.dbinfo.signLog);

            Assert.AreEqual(expected, this.managed.signLog);
        }
Ejemplo n.º 11
0
        public void VerifySignatureCanBeSerialized()
        {
            var expected = new JET_SIGNATURE(1, DateTime.Now, "BROWNVM");

            SerializeAndCompare(expected);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JET_COMMIT_ID"/> class. This
 /// is for testing purposes only.
 /// </summary>
 /// <remarks>This is being implemented in new Windows UI only because the Desktop test
 /// code uses reflection to create the object, and the new Windows UI reflection does not
 /// appear to work in this scenario -- Activator.CreateInstance() reflection seems to only
 /// work with exising public constructors.</remarks>
 /// <param name="signature">The log signature for this sequence.</param>
 /// <param name="commitId">The commit identifier for this commit transaction.</param>
 internal JET_COMMIT_ID(JET_SIGNATURE signature, long commitId)
 {
     this.signLog  = signature;
     this.commitId = commitId;
 }
Ejemplo n.º 13
0
 public void JetSignatureToString()
 {
     var t = new DateTime(2010, 5, 31, 4, 44, 17, DateTimeKind.Utc);
     var signature = new JET_SIGNATURE(99, t, "COMPUTER");
     Assert.AreEqual("JET_SIGNATURE(99:05/31/2010 04:44:17:COMPUTER)", signature.ToString());
 }
Ejemplo n.º 14
0
 public void VerifySignLog()
 {
     var expected = new JET_SIGNATURE(this.native.dbinfo.signLog);
     Assert.AreEqual(expected, this.managed.signLog);
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Retrieves information about an instance.
 /// </summary>
 /// <param name="instance">The instance to get information about.</param>
 /// <param name="signature">Retrieved information.</param>
 /// <param name="infoLevel">The type of information to retrieve.</param>
 public static void JetGetInstanceMiscInfo(JET_INSTANCE instance, out JET_SIGNATURE signature, JET_InstanceMiscInfo infoLevel)
 {
     Api.Check(Api.Impl.JetGetInstanceMiscInfo(instance, out signature, infoLevel));
 }
Ejemplo n.º 16
0
        public string GetXmlDescription(JET_SIGNATURE logfileSignature)
        {
            string text = this.IdentityGuid.ToString();
            string name = this.Name;
            string destinationSystemPath = this.DestinationSystemPath;
            string logFilePrefix         = this.LogFilePrefix;

            string.Format("{0}*.{1}", this.LogFilePrefix, this.LogExtension);
            string       destinationLogPath     = this.DestinationLogPath;
            string       destinationEdbPath     = this.DestinationEdbPath;
            string       databaseName           = this.DatabaseName;
            bool         databaseIsPrivate      = this.DatabaseIsPrivate;
            bool         circularLoggingEnabled = this.CircularLoggingEnabled;
            StringWriter stringWriter           = new StringWriter();
            XmlWriter    xmlWriter = XmlWriter.Create(stringWriter);

            xmlWriter.WriteStartDocument(true);
            xmlWriter.WriteStartElement("EXWRITER_METADATA");
            xmlWriter.WriteStartElement("VERSION_STAMP");
            xmlWriter.WriteString("15.00.1497.012");
            xmlWriter.WriteEndElement();
            string fileName      = Path.GetFileName(destinationEdbPath);
            string directoryName = Path.GetDirectoryName(destinationEdbPath);

            xmlWriter.WriteStartElement("DATABASE_NAME");
            xmlWriter.WriteString(databaseName);
            xmlWriter.WriteEndElement();
            xmlWriter.WriteStartElement("DATABASE_GUID");
            xmlWriter.WriteString(text);
            xmlWriter.WriteEndElement();
            xmlWriter.WriteStartElement("DATABASE_GUID_ORIGINAL");
            xmlWriter.WriteString(text);
            xmlWriter.WriteEndElement();
            xmlWriter.WriteStartElement("EDB_LOCATION_ORIGINAL");
            xmlWriter.WriteString(directoryName);
            xmlWriter.WriteEndElement();
            xmlWriter.WriteStartElement("EDB_FILENAME_ORIGINAL");
            xmlWriter.WriteString(fileName);
            xmlWriter.WriteEndElement();
            xmlWriter.WriteStartElement("PRIVATE_MDB");
            xmlWriter.WriteString(databaseIsPrivate ? "yes" : "no");
            xmlWriter.WriteEndElement();
            string text2 = logfileSignature.ulRandom.ToString();

            xmlWriter.WriteStartElement("LOG_SIGNATURE_ID");
            xmlWriter.WriteString(text2);
            xmlWriter.WriteEndElement();
            string text3 = InteropShim.Uint64FromLogTime(new JET_LOGTIME?(logfileSignature.logtimeCreate)).ToString();

            xmlWriter.WriteStartElement("LOG_SIGNATURE_TIMESTAMP");
            xmlWriter.WriteString(text3);
            xmlWriter.WriteEndElement();
            xmlWriter.WriteStartElement("LOG_BASE_NAME");
            xmlWriter.WriteString(logFilePrefix);
            xmlWriter.WriteEndElement();
            xmlWriter.WriteStartElement("LOG_PATH_ORIGINAL");
            xmlWriter.WriteString(destinationLogPath);
            xmlWriter.WriteEndElement();
            xmlWriter.WriteStartElement("SYSTEM_PATH_ORIGINAL");
            xmlWriter.WriteString(destinationSystemPath);
            xmlWriter.WriteEndElement();
            xmlWriter.WriteStartElement("CIRCULAR_LOGGING");
            xmlWriter.WriteString(circularLoggingEnabled ? "yes" : "no");
            xmlWriter.WriteEndElement();
            xmlWriter.WriteStartElement("REPLICA");
            xmlWriter.WriteString("yes");
            xmlWriter.WriteEndElement();
            xmlWriter.WriteEndElement();
            xmlWriter.WriteEndDocument();
            xmlWriter.Close();
            string result = stringWriter.ToString();

            stringWriter.Dispose();
            return(result);
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Retrieves information about an instance.
 /// </summary>
 /// <param name="instance">The instance to get information about.</param>
 /// <param name="signature">Retrieved information.</param>
 /// <param name="infoLevel">The type of information to retrieve.</param>
 public static void JetGetInstanceMiscInfo(JET_INSTANCE instance, out JET_SIGNATURE signature, JET_InstanceMiscInfo infoLevel)
 {
     Api.Check(Api.Impl.JetGetInstanceMiscInfo(instance, out signature, infoLevel));
 }
Ejemplo n.º 18
0
        public void JetSignatureWithNullDateTimeToString()
        {
            var signature = new JET_SIGNATURE(399, null, "COMPUTER");

            Assert.AreEqual("JET_SIGNATURE(399::COMPUTER)", signature.ToString());
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JET_COMMIT_ID"/> class.
 /// </summary>
 /// <param name="native">The native version of the structure.
 /// to use as the data source.</param>
 internal JET_COMMIT_ID(NATIVE_COMMIT_ID native)
 {
     this.signLog  = new JET_SIGNATURE(native.signLog);
     this.commitId = native.commitId;
 }