public void ReopenTest() { const string arrayName = "ReopenPCSMWithSpaceManagerTest"; const int elementSize = 16; const int userHeaderSize = 8; IPersistentCollectionSpaceManager pafs = InitPAFS(arrayName, elementSize, userHeaderSize); try { byte[] userHeader = new byte[userHeaderSize] { 1, 2, 3, 4, 5, 6, 7, 8 }; pafs.PutUserHeader(userHeader); int index = 0; byte[] expectedBytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }; pafs.Put(index, expectedBytes); pafs.Close(); pafs = new PersistentCollectionSpaceManager(arrayName); Assert.AreEqual(elementSize, pafs.GetElementSize()); Assert.AreEqual(userHeaderSize, pafs.GetUserHeaderSize()); TestHelper.AssertByteArraysAreSame(userHeader, pafs.GetUserHeader()); TestHelper.AssertByteArraysAreSame(expectedBytes, pafs.Get(index)); } finally { pafs.Close(); } }
public void GetHeaderTest() { IPersistentCollectionSpaceManager pafs = InitPAFS("GetPCSMHeader", 16, 20); try { byte[] userheader = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 100, 110, 120, 130, 140, 150, 210, 220, 230, 240, 255 }; pafs.PutUserHeader(userheader); TestHelper.AssertByteArraysAreSame(userheader, pafs.GetUserHeader()); try { pafs.PutUserHeader(new byte[21]); Assert.Fail("Should throw an exception"); } catch (InvalidUserHeaderException) {} } finally { pafs.Close(); } }
public void GetUserHeaderTest() { int uHeaderSize = 8; IPersistentCollectionSpaceManager pafs = InitPAFS("GetPCSMUserHeader", 16, uHeaderSize); try { byte[] uHeader = pafs.GetUserHeader(); Assert.AreEqual(uHeaderSize, uHeader.Length); TestHelper.AssertByteArraysAreSame(new byte[0], uHeader); byte[] newUserHeader = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 }; pafs.PutUserHeader(newUserHeader); byte[] actual = pafs.GetUserHeader(); TestHelper.AssertByteArraysAreSame(newUserHeader, actual); } finally { pafs.Close(); } }
public void PutUserHeader(byte[] userHeader) { _persistentSimpleCollection.PutUserHeader(GetSize().ToBytes().Append(userHeader)); }