public void TestRevertWithChanges()
 {
     using (TempFile temp = new TempFile())
     {
         byte[] sample = new byte[1024];
         new Random().NextBytes(sample);
         List <uint> handles = new List <uint>();
         using (TransactedCompoundFile file = new TransactedCompoundFile(temp.TempPath))
         {
             for (int i = 0; i < 1000; i++)
             {
                 var hid = file.Create();
                 handles.Add(hid);
                 file.Write(hid, sample, i, sample.Length - i);
                 CompareBytes(sample, i, sample.Length - i, IOStream.ReadAllBytes(file.Read(hid)));
             }
             file.Commit();
         }
         using (TransactedCompoundFile file = new TransactedCompoundFile(temp.TempPath))
         {
             byte[] dummy = new byte[1024];
             for (int i = 0; i < 1000; i++)
             {
                 file.Write(handles[i], dummy, 0, dummy.Length);
                 file.Delete(handles[i]);
             }
             file.Rollback();
             for (int i = 0; i < 1000; i++)
             {
                 CompareBytes(sample, i, sample.Length - i, IOStream.ReadAllBytes(file.Read(handles[i])));
             }
         }
     }
 }
 public void TestRevertChanges()
 {
     using (TempFile temp = new TempFile())
     {
         byte[] sample = new byte[1024];
         new Random().NextBytes(sample);
         List <uint> handles = new List <uint>();
         using (TransactedCompoundFile file = new TransactedCompoundFile(temp.TempPath))
         {
             for (int i = 0; i < 1000; i++)
             {
                 var hid = file.Create();
                 handles.Add(hid);
                 file.Write(hid, sample, i, sample.Length - i);
                 CompareBytes(sample, i, sample.Length - i, IOStream.ReadAllBytes(file.Read(hid)));
                 if (i == 500)
                 {
                     file.Commit();
                 }
             }
             file.Rollback();
             for (int i = 0; i < 1000; i++)
             {
                 if (i <= 500)
                 {
                     CompareBytes(sample, i, sample.Length - i, IOStream.ReadAllBytes(file.Read(handles[i])));
                 }
                 else
                 {
                     try
                     {
                         IOStream.ReadAllBytes(file.Read(handles[i]));
                         Assert.Fail();
                     }
                     catch (ArgumentOutOfRangeException) { }
                 }
             }
         }
     }
 }