예제 #1
0
        public void CanReadSetDateRecord()
        {
            var block = new Block(RandomFilename, 0);
            var rec   = new SetDateRecord(_logManager, _bufferManager, 5, block, 0, new DateTime(2020, 1, 1));
            var lsn   = rec.WriteToLog();

            _logManager.Flush(lsn);


            _enumerator = new LogRecordEnumerator(_logManager, _bufferManager);
            var record = _enumerator.Current as SetDateRecord;

            Assert.AreEqual(LogRecordType.SetDate, record.Type);
            Assert.AreEqual(5, record.TransactionNumber);
            Assert.AreEqual(block, record.Block);
            Assert.AreEqual(0, record.Offset);
            Assert.AreEqual(new DateTime(2020, 1, 1), record.Value);
        }
예제 #2
0
        public void CanWriteSetDateRecordMultipleTimesToLog()
        {
            _logRecord = new SetDateRecord(
                _logManager,
                _bufferManager,
                1,
                _putToBlock,
                0,
                new DateTime(2020, 1, 1));
            var logRecord2 = new SetDateRecord(
                _logManager,
                _bufferManager,
                1,
                _putToBlock,
                0,
                new DateTime(2020, 1, 2));

            _ = _logRecord.WriteToLog();
            var lsn2 = logRecord2.WriteToLog();

            _logManager.Flush(lsn2);

            var enumerator     = _logManager.GetEnumerator();
            var record         = enumerator.Current;
            var currentRecord2 = new SetDateRecord(_logManager, _bufferManager, record);

            enumerator.MoveNext();
            record = enumerator.Current;
            var currentRecord1 = new SetDateRecord(_logManager, _bufferManager, record);

            Assert.IsNotNull(currentRecord2);
            Assert.AreEqual(LogRecordType.SetDate, currentRecord2.Type);
            Assert.AreEqual(1, currentRecord1.TransactionNumber);
            Assert.AreEqual(new DateTime(2020, 1, 2), currentRecord2.Value);
            Assert.AreEqual(_putToBlock, currentRecord2.Block);
            Assert.AreEqual(0, currentRecord2.Offset);

            Assert.IsNotNull(currentRecord1);
            Assert.AreEqual(LogRecordType.SetDate, currentRecord1.Type);
            Assert.AreEqual(1, currentRecord1.TransactionNumber);
            Assert.AreEqual(new DateTime(2020, 1, 1), currentRecord1.Value);
            Assert.AreEqual(_putToBlock, currentRecord1.Block);
            Assert.AreEqual(0, currentRecord1.Offset);
        }