예제 #1
0
        public void HeaderPage_Savepoint()
        {
            var data   = new byte[Constants.PAGE_SIZE];
            var buffer = new PageBuffer(data, 0, 1);

            // mark buffer as writable (debug propose)
            buffer.ShareCounter = Constants.BUFFER_WRITABLE;

            // create new header page
            var header = new HeaderPage(buffer, 0);

            header.InsertCollection("my-col1", 1);
            header.InsertCollection("my-col2", 2);

            header.GetCollections().Count().Should().Be(2);

            // savepoint alse execute UpdateBuffer
            var sp = header.Savepoint();

            header.DeleteCollection("my-col1");
            header.DeleteCollection("my-col2");

            header.UpdateBuffer();

            header.GetCollections().Count().Should().Be(0);

            // now, restore header
            header.Restore(sp);

            header.GetCollections().Count().Should().Be(2);

            buffer.ShareCounter = 0;
        }