private static void MergeBeforeTestAssert(int sizeIndex1, int endIndex1, int sizeIndex2, int endIndex2)
        {
            PersistentHeapFreeSpace freeSpace1 = new PersistentHeapFreeSpace(sizeIndex1, endIndex1, 5);
            PersistentHeapFreeSpace freeSpace2 = new PersistentHeapFreeSpace(sizeIndex2, endIndex2, 6);

            freeSpace1.MergeBefore(freeSpace2);

            Assert.AreEqual(endIndex1, freeSpace1.EndIndex);
            Assert.AreEqual(endIndex1 - sizeIndex2+1, freeSpace1.SizeInBytes);
            Assert.AreEqual(endIndex1 - sizeIndex2+1 - PersistentHeapSpace.GetUserSizeSize(), freeSpace1.UserSize);
        }
 private void LinkBefore(PersistentHeapFreeSpace freedSpace, PersistentHeapFreeSpace before)
 {
     if (before == null) // there is no free space before the freed space
     {
         PutFreeSpaceHead(freedSpace.StartIndex);
     }
     else // there is at least one free space before the freed space
     {
         if (freedSpace.IsDirectlyAfter(before)) // the before space is next to freed space
         {
             freedSpace.MergeBefore(before);
         }
         else // the before space is not next to freed space
         {
             before.NextFreeSpace = freedSpace.StartIndex;
             PutFullSpace(before);
         }
     }
 }