public void CreateTest()
 {
     //prime the pump
     string arrayName = "arrayName";
     PersistentCollectionSpaceManager pcsm = (PersistentCollectionSpaceManager) InitPAFS(arrayName, 16, 4);
     pcsm.Delete();
     pcsm = null;
     PersistentCollectionSpaceManager pcsm2 = new PersistentCollectionSpaceManager(arrayName, 16, 4);
     try
     {
         pcsm=new PersistentCollectionSpaceManager(arrayName, 16, 4);
         Assert.Fail("Should throw an exception");
     }catch (FileNameConflictException)
     {
         if(pcsm != null)
             pcsm.Delete();
     }
 }
 public void CreateTooSmallTest()
 {
     PersistentCollectionSpaceManager pcsm = null;
     try
     {
         pcsm = new PersistentCollectionSpaceManager("PCSMCreateTooSmall", 3, 3);
         Assert.Fail("Should throw an exception");
     } catch (InvalidElementSizeException)
     {
         if (pcsm != null)
             pcsm.Delete();
     }
 }
 private IPersistentCollectionSpaceManager InitPAFS(string arrayName, int elementSize, int uHeaderSize)
 {
     PersistentCollectionSpaceManager pcsm;
     try
     {
         pcsm = new PersistentCollectionSpaceManager(arrayName, elementSize, uHeaderSize);
     }
     catch (FileNameConflictException)
     {
         pcsm = new PersistentCollectionSpaceManager(arrayName);
         pcsm.Delete();
         pcsm = new PersistentCollectionSpaceManager(arrayName, elementSize, uHeaderSize);
     }
     return pcsm;
 }
        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();
            }
        }