public static void TransactionCommit()
        {
            var itself = _constants.Itself;

            var tempDatabaseFilename       = Path.GetTempFileName();
            var tempTransactionLogFilename = Path.GetTempFileName();

            // Commit
            using (var memoryAdapter = new UInt64LinksTransactionsLayer(new UInt64UnitedMemoryLinks(tempDatabaseFilename), tempTransactionLogFilename))
                using (var links = new UInt64Links(memoryAdapter))
                {
                    using (var transaction = memoryAdapter.BeginTransaction())
                    {
                        var l1 = links.CreateAndUpdate(itself, itself);
                        var l2 = links.CreateAndUpdate(itself, itself);

                        Global.Trash = links.Update(l2, l2, l1, l2);

                        links.Delete(l1);

                        transaction.Commit();
                    }

                    Global.Trash = links.Count();
                }

            Global.Trash = FileHelpers.ReadAll <UInt64LinksTransactionsLayer.Transition>(tempTransactionLogFilename);
        }
        public static void Bug1Test()
        {
            var tempDatabaseFilename       = Path.GetTempFileName();
            var tempTransactionLogFilename = Path.GetTempFileName();

            var itself = _constants.Itself;

            // User Code Error (Autoreverted), some data saved
            try
            {
                ulong l1;
                ulong l2;

                using (var memory = new UInt64UnitedMemoryLinks(tempDatabaseFilename))
                    using (var memoryAdapter = new UInt64LinksTransactionsLayer(memory, tempTransactionLogFilename))
                        using (var links = new UInt64Links(memoryAdapter))
                        {
                            l1 = links.CreateAndUpdate(itself, itself);
                            l2 = links.CreateAndUpdate(itself, itself);

                            l2 = links.Update(l2, l2, l1, l2);

                            links.CreateAndUpdate(l2, itself);
                            links.CreateAndUpdate(l2, itself);
                        }

                Global.Trash = FileHelpers.ReadAll <UInt64LinksTransactionsLayer.Transition>(tempTransactionLogFilename);

                using (var memory = new UInt64UnitedMemoryLinks(tempDatabaseFilename))
                    using (var memoryAdapter = new UInt64LinksTransactionsLayer(memory, tempTransactionLogFilename))
                        using (var links = new UInt64Links(memoryAdapter))
                        {
                            using (var transaction = memoryAdapter.BeginTransaction())
                            {
                                l2 = links.Update(l2, l1);

                                links.Delete(l2);

                                ExceptionThrower();

                                transaction.Commit();
                            }

                            Global.Trash = links.Count();
                        }
            }
            catch
            {
                Global.Trash = FileHelpers.ReadAll <UInt64LinksTransactionsLayer.Transition>(tempTransactionLogFilename);
            }

            File.Delete(tempDatabaseFilename);
            File.Delete(tempTransactionLogFilename);
        }
        public static void TransactionDamage()
        {
            var itself = _constants.Itself;

            var tempDatabaseFilename       = Path.GetTempFileName();
            var tempTransactionLogFilename = Path.GetTempFileName();

            // Commit
            using (var memoryAdapter = new UInt64LinksTransactionsLayer(new UInt64UnitedMemoryLinks(tempDatabaseFilename), tempTransactionLogFilename))
                using (var links = new UInt64Links(memoryAdapter))
                {
                    using (var transaction = memoryAdapter.BeginTransaction())
                    {
                        var l1 = links.CreateAndUpdate(itself, itself);
                        var l2 = links.CreateAndUpdate(itself, itself);

                        Global.Trash = links.Update(l2, l2, l1, l2);

                        links.Delete(l1);

                        transaction.Commit();
                    }

                    Global.Trash = links.Count();
                }

            Global.Trash = FileHelpers.ReadAll <UInt64LinksTransactionsLayer.Transition>(tempTransactionLogFilename);

            // Damage database

            FileHelpers.WriteFirst(tempTransactionLogFilename, new UInt64LinksTransactionsLayer.Transition(new UniqueTimestampFactory(), 555));

            // Try load damaged database
            try
            {
                // TODO: Fix
                using (var memoryAdapter = new UInt64LinksTransactionsLayer(new UInt64UnitedMemoryLinks(tempDatabaseFilename), tempTransactionLogFilename))
                    using (var links = new UInt64Links(memoryAdapter))
                    {
                        Global.Trash = links.Count();
                    }
            }
            catch (NotSupportedException ex)
            {
                Assert.True(ex.Message == "Database is damaged, autorecovery is not supported yet.");
            }

            Global.Trash = FileHelpers.ReadAll <UInt64LinksTransactionsLayer.Transition>(tempTransactionLogFilename);

            File.Delete(tempDatabaseFilename);
            File.Delete(tempTransactionLogFilename);
        }