コード例 #1
0
        public void ExpireOfExpiredRecordProduceWriteConflict()
        {
            var memoryManager = new MemoryManager();

            var content = new byte[] { 0, 1 };

            var recordReference = VersionedRecord.CreateNew(content, 0, memoryManager);

            var snapshotData = new SnapshotData(new int[] { });

            var record = new VersionedRecord(memoryManager.Get(recordReference).RawData, memoryManager, snapshotData);

            record.Expire(0);                                                                        // zero transaction expires the record
            Assert.That(() => record.Expire(1), Throws.Exception.TypeOf <WriteConflictException>()); // first transaction trying to expire it
        }
コード例 #2
0
        public void ExpiredVersionIsInvisible()
        {
            var memoryManager = new MemoryManager();

            var content = new byte[] { 0, 1 };

            var recordReference = VersionedRecord.CreateNew(content, 0, memoryManager);

            var snapshotData = new SnapshotData(new int[] { });

            var record = new VersionedRecord(memoryManager.Get(recordReference).RawData, memoryManager, snapshotData);

            record.Expire(0);

            Assert.IsFalse(record.HasVisibleVersionTo(0));
        }
コード例 #3
0
        public void UpdateRecordExpiredByRolledBackTransaction()
        {
            var memoryManager = new MemoryManager();

            var content    = new byte[] { 0, 1 };
            var newContent = new byte[] { 2, 3 };

            var recordReference = VersionedRecord.CreateNew(content, 0, memoryManager);

            var snapshotData = new SnapshotData(new[] { 0 });

            var record = new VersionedRecord(memoryManager.Get(recordReference).RawData, memoryManager, snapshotData);

            var newReference = record.Expire(1);

            snapshotData = new SnapshotData(new[] { 0 }, new[] { 1 });

            record = new VersionedRecord(memoryManager.Get(newReference).RawData, memoryManager, snapshotData);

            record.Update(newContent, 2);
            Assert.IsTrue(newContent.SequenceEqual(record.GetMatchingVersion(2).RawData));
        }
コード例 #4
0
        public void ResurrectRecordExpiredByCommitedTransaction()
        {
            var memoryManager = new MemoryManager();

            var content    = new byte[] { 0, 1 };
            var newContent = new byte[] { 2, 3 };

            var recordReference = VersionedRecord.CreateNew(content, 0, memoryManager);

            var snapshotData = new SnapshotData(new int[] { });

            var record = new VersionedRecord(memoryManager.Get(recordReference).RawData, memoryManager, snapshotData);

            var newReference = record.Expire(0);

            snapshotData = new SnapshotData(new[] { 0 });

            record = new VersionedRecord(memoryManager.Get(newReference).RawData, memoryManager, snapshotData);

            record.Insert(newContent, 1);
            Assert.IsTrue(newContent.SequenceEqual(record.GetMatchingVersion(1).RawData));
        }