public void AddRemove() { PackFile file1 = new PackFile("test.pck"); Assert.IsTrue(file1.AddFile("test1", TestData1), "AddFile returned false"); Assert.IsTrue(file1.AddFile("test2", TestData2), "AddFile returned false"); VerifyFile(file1, "test1", TestData1, "before file1 save"); VerifyFile(file1, "test2", TestData2, "before file1 save"); Assert.AreEqual(2, file1.FileCount, "FileCount mismatch before save"); try { file1.Save(); } catch (Exception ex) { Assert.Fail("Exception when saving file1: " + ex.Message); return; } file1 = null; PackFile file2 = new PackFile("test.pck"); try { file2.Load(); } catch (Exception ex) { Assert.Fail("Exception when loading file2: " + ex.Message); return; } Assert.AreEqual(2, file2.FileCount, "FileCount mismatch after load back"); VerifyFile(file2, "test1", TestData1, "after file2 load"); VerifyFile(file2, "test2", TestData2, "after file2 load"); file2.RemoveFile("test1"); Assert.AreEqual(1, file2.FileCount, "FileCount mismatch after remove"); Assert.IsFalse(file2.FileExists("test1"), "test1 still exists"); file2.AddFile("test3", TestData3); VerifyFile(file2, "test3", TestData3, "after file2 load"); Assert.AreEqual(2, file2.FileCount, "FileCount mismatch after add"); try { file2.Save(); } catch (Exception ex) { Assert.Fail("Exception when saving file2): " + ex.Message); return; } file2 = null; PackFile file3 = new PackFile("test.pck"); try { file3.Load(); } catch (Exception ex) { Assert.Fail("Exception when loading file3 back: " + ex.Message); return; } Assert.AreEqual(2, file3.FileCount, "FileCount mismatch after load back"); Assert.IsFalse(file3.FileExists("test1"), "test1 still exists after load back"); VerifyFile(file3, "test2", TestData2, "after file3 load"); VerifyFile(file3, "test3", TestData3, "after file3 load"); }