Exemplo n.º 1
0
        internal static void WriteForcedTransactionIntroduction(ITransaction transaction)
        {
            // Output the change log to the proposed transaction to commit,
            IDataFile transactionLog = transaction.GetFile(TransactionLogKey, FileAccess.ReadWrite);

            transactionLog.Delete();

            StringData logFile = new StringData(transactionLog);

            // Record that there is no base root for this transaction,
            logFile.Append("no base root");
            logFile.Append("\n");
        }
Exemplo n.º 2
0
        internal void RefreshTransactionLog()
        {
            // Output the change log to the proposed transaction to commit,
            IDataFile transactionLog = transaction.GetFile(TransactionLogKey, FileAccess.ReadWrite);

            transactionLog.Delete();

            StringData logFile = new StringData(transactionLog);

            // Record the base root in the log,
            logFile.Append(baseRoot.ToString());
            logFile.Append("\n");

            // Write out every log entry,
            foreach (string entry in log)
            {
                logFile.Append(entry);
                logFile.Append("\n");
            }
        }
Exemplo n.º 3
0
        public void SimpleAppend()
        {
            IDataFile file = Transaction.GetFile(new Key(0, 0, 1), FileAccess.ReadWrite);

            Assert.IsNotNull(file);

            StringData data = new StringData(file);

            data.Append("test");
            Assert.AreNotEqual(0, file.Position);

            file.Position = 0;
            string s = data.Substring(0, 4);

            Assert.AreEqual("test", s);

            Commit();
        }
Exemplo n.º 4
0
        public void IncrementalAppend()
        {
            IDataFile file = Transaction.GetFile(new Key(0, 0, 1), FileAccess.ReadWrite);

            Assert.IsNotNull(file);

            StringData data = new StringData(file);

            for (int i = 0; i < 500; i++)
            {
                StringBuilder sb = new StringBuilder();
                for (int j = 0; j < i; j++)
                {
                    sb.Append(" ");
                }

                data.Append(sb.ToString());
            }

            file.Position = 0;

            int offset = 0;

            for (int i = 0; i < 500; i++)
            {
                StringBuilder sb = new StringBuilder();
                for (int j = 0; j < i; j++)
                {
                    sb.Append(" ");
                }

                string s = data.Substring(offset, i);
                Assert.AreEqual(sb.ToString(), s);

                offset += i;
            }
        }