コード例 #1
0
        private void GetPutUserHeaderTest(byte[] uHeader)
        {
            FileWithHeader target = InitFWH("GetPutUserHeaderTest", 16);

            try
            {
                target.PutUserHeader(uHeader);
                byte[] actual = target.GetUserHeader();
                TestHelper.AssertByteArraysAreSame(uHeader, actual);
            }
            finally
            {
                target.Close();
            }
        }
コード例 #2
0
        public void ReopenTest()
        {
            string         fileName = "ReopenFileWithHeaderTest";
            FileWithHeader fwh      = InitFWH(fileName, 5);

            try
            {
                //write values
                int  expectedIndex1 = 0;
                byte expectedValue1 = 6;
                fwh.Put(expectedIndex1, expectedValue1);

                int  expectedIndex2 = 55;
                byte expectedValue2 = 200;
                fwh.Put(expectedIndex2, expectedValue2);

                //get next index
                int expectedNextIndex = fwh.GetNextIndex();

                byte[] expectedUserHeader = new byte[5] {
                    1, 2, 3, 4, 5
                };
                fwh.PutUserHeader(expectedUserHeader);

                fwh.Close();

                fwh = new FileWithHeader(fileName);

                Assert.AreEqual(expectedValue1, fwh.Get(expectedIndex1));
                Assert.AreEqual(expectedValue2, fwh.Get(expectedIndex2));

                Assert.AreEqual(expectedNextIndex, fwh.GetNextIndex());

                TestHelper.AssertByteArraysAreSame(expectedUserHeader, fwh.GetUserHeader());
            }
            finally
            {
                fwh.Close();
            }
        }
コード例 #3
0
 public int GetElementSize()
 {
     byte[] fullUserHeader   = _fileWithHeader.GetUserHeader();
     byte[] elementSizeBytes = fullUserHeader.SubArray(0, GetElementSizeSize());
     return(elementSizeBytes.ToInt());
 }
コード例 #4
0
 public PersistentNextSpaceArray(String arrayName)
 {
     _fileWithHeader = new FileWithHeader(arrayName);
     byte[] userHeaderBytes = _fileWithHeader.GetUserHeader();
 }
コード例 #5
0
 public byte[] GetUserHeader()
 {
     byte[] fullHeader = _file.GetUserHeader();
     byte[] userHeader = fullHeader.SubArray(GetFreeSpaceHeadSize(), fullHeader.Length);
     return(userHeader);
 }