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(); } }
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(); } }
public int GetElementSize() { byte[] fullUserHeader = _fileWithHeader.GetUserHeader(); byte[] elementSizeBytes = fullUserHeader.SubArray(0, GetElementSizeSize()); return(elementSizeBytes.ToInt()); }
public PersistentNextSpaceArray(String arrayName) { _fileWithHeader = new FileWithHeader(arrayName); byte[] userHeaderBytes = _fileWithHeader.GetUserHeader(); }
public byte[] GetUserHeader() { byte[] fullHeader = _file.GetUserHeader(); byte[] userHeader = fullHeader.SubArray(GetFreeSpaceHeadSize(), fullHeader.Length); return(userHeader); }