// // You can use the following additional attributes as you write your tests: // // Use ClassInitialize to run code before running the first test in the class // [ClassInitialize()] // public static void MyClassInitialize(TestContext testContext) { } // // Use ClassCleanup to run code after all tests in a class have run // [ClassCleanup()] // public static void MyClassCleanup() { } // // Use TestInitialize to run code before running each test // [TestInitialize()] // public void MyTestInitialize() { } // // Use TestCleanup to run code after each test has run // [TestCleanup()] // public void MyTestCleanup() { } // #endregion //[ClassInitialize()] //public static void MyClassInitialize(TestContext testContext) //{ // TestConstants.CreateTestDir(); //} //[ClassCleanup()] //public static void MyClassCleanup() //{ // TestConstants.DeleteTestDir(); //} private IPersistentArrayNextSpace InitPA(String name, int eleSize, int uHeaderSize) { PersistentNextSpaceArray array; try { array = new PersistentNextSpaceArray(name, eleSize, uHeaderSize); } catch (FileNameConflictException) { array = new PersistentNextSpaceArray(name); array.Delete(); array = new PersistentNextSpaceArray(name, eleSize, uHeaderSize); } return(array); }
public void EmptyNameTest() { PersistentNextSpaceArray pnsa = null; try { pnsa = new PersistentNextSpaceArray("", 6, 6); Assert.Fail("Should throw exception"); } catch (FileNotFoundException) { if (pnsa != null) { pnsa.Close(); } } }
public void NoArrayTest() { PersistentNextSpaceArray pnsa = null; try { pnsa = new PersistentNextSpaceArray("PADoesntExsist"); Assert.Fail("Should throw exception"); } catch (FileNotFoundException) { if (pnsa != null) { pnsa.Close(); } } }
public void ReopenTest() { string arrayName = "ReopenPersistentArrayTest"; int eleSize = 5; int uHSize = 9; var data = new List <Tuple <int, byte[]> >(); var record1 = new Tuple <int, byte[]>(0, new byte[] { 1, 2, 3, 4, 5 }); data.Add(record1); var record2 = new Tuple <int, byte[]>(1, new byte[] { 255, 255, 255, 255, 255 }); data.Add(record2); var record3 = new Tuple <int, byte[]>(2, new byte[] { 12, 34, 56, 78, 90 }); data.Add(record3); var record4 = new Tuple <int, byte[]>(3, new byte[] { 7, 7, 7 }); data.Add(record4); var pa = InitPA(arrayName, eleSize, uHSize); foreach (var tuple in data) { pa.Put(tuple.Item1, tuple.Item2); } pa.Close(); var reopening = new PersistentNextSpaceArray(arrayName); Assert.AreEqual(eleSize, reopening.GetElementSize()); Assert.AreEqual(uHSize, reopening.GetUserHeaderSize()); foreach (var tuple in data) { TestHelper.AssertByteArraysAreSame(tuple.Item2, reopening.Get(tuple.Item1)); } }