Exemplo n.º 1
0
 public void DoTestMarkReserve()
 {
     using (var xMSStore = new MemoryStream(new byte[32768]))
     {
         using (var xMSBitmap = new MemoryStream(new byte[8]))
         {
             using (var xBlockStore = new SimpleStreamBlockStore(xMSStore, 512))
             {
                 using (var xBitmapBlockManager = new BitmapBlockManager(xMSBitmap, 1, 8))
                 {
                     Assert.IsFalse(xBitmapBlockManager.IsReserved(0));
                     var xBit = xBitmapBlockManager.Reserve();
                     Assert.IsTrue(xBitmapBlockManager.IsReserved(xBit));
                     xBitmapBlockManager.Free(xBit);
                     Assert.IsFalse(xBitmapBlockManager.IsReserved(xBit));
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
 public void Test_MarkReservedAfterFullFillAndSomeFree()
 {
     using (var xMSBitmap = new MemoryStream(new byte[8]))
     {
         using (var xBitmap = new BitmapBlockManager(xMSBitmap, 1, 8))
         {
             var xReservations = xBitmap.Reserve(64);
             Assert.AreEqual(64, xReservations.Length);
             ulong xReservation;
             Assert.IsFalse(xBitmap.TryReserve(out xReservation));
             xBitmap.Free(xReservations[0]);
             Assert.IsTrue(xBitmap.TryReserve(out xReservation));
             Assert.IsFalse(xBitmap.TryReserve(out xReservation));
         }
     }
 }