Example #1
0
        public void HeaderPage_Collections()
        {
            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);
            ((int)header.GetCollectionPageID("my-col1")).Should().Be(1);
            ((int)header.GetCollectionPageID("my-col2")).Should().Be(2);
            header.GetAvaiableCollectionSpace().Should().Be(7981);

            header.UpdateBuffer();

            // read header
            var h2 = new HeaderPage(buffer);

            h2.GetCollections().Count().Should().Be(2);
            ((int)h2.GetCollectionPageID("my-col1")).Should().Be(1);
            ((int)h2.GetCollectionPageID("my-col2")).Should().Be(2);
            h2.GetAvaiableCollectionSpace().Should().Be(7981);

            buffer.ShareCounter = 0;
        }