public void PackRoundTripTest() { // TODO: Create new package based on a directory (See the Load test) var packageRoot = WriteTestPackage("RoundTripPackage"); Package target = new Package(packageRoot, true); Package unpackedTarget = null; using (System.IO.MemoryStream packedStream = new System.IO.MemoryStream()) { target.Pack(packedStream); packedStream.Seek(0, System.IO.SeekOrigin.Begin); System.IO.Directory.Delete(System.IO.Path.Combine(PackageTestRoot, "RoundTripPackage"), true); unpackedTarget = new Package(packedStream); unpackedTarget.Unpack(PackageTestRoot); } Assert.IsNotNull(unpackedTarget); Assert.AreEqual(target.ID, unpackedTarget.ID); Assert.AreEqual(target.Name, unpackedTarget.Name); Assert.AreEqual(target.Files.Count(), unpackedTarget.Files.Count()); Assert.AreEqual(target.References.Count(), unpackedTarget.References.Count()); Assert.AreEqual(target.ComponentLocations.Count(), unpackedTarget.ComponentLocations.Count()); Assert.AreEqual(target.TypeLocations.Count(), unpackedTarget.TypeLocations.Count()); for (int i = 0; i < target.Files.Count(); ++i) { var targetFile = target.Files.ElementAt(i); var unpackedFile = unpackedTarget.Files.ElementAt(i); Assert.AreEqual(targetFile.ID, unpackedFile.ID); } for (int i = 0; i < target.References.Count(); ++i) { Assert.AreEqual(target.References.ElementAt(i), unpackedTarget.References.ElementAt(i)); } for (int i = 0; i < target.ComponentLocations.Count(); ++i) { Assert.AreEqual(target.ComponentLocations.ElementAt(i), unpackedTarget.ComponentLocations.ElementAt(i)); } for (int i = 0; i < target.TypeLocations.Count(); ++i) { Assert.AreEqual(target.TypeLocations.ElementAt(i), unpackedTarget.TypeLocations.ElementAt(i)); } // and lets make sure the files came through too. Assert.IsTrue(System.IO.File.Exists(System.IO.Path.Combine(packageRoot, "RoundTripPackage.manifest"))); Assert.IsTrue(System.IO.File.Exists(System.IO.Path.Combine(packageRoot, "Data", "coest.xml"))); Assert.IsTrue(System.IO.File.Exists(System.IO.Path.Combine(packageRoot, "Data", "coest1.xml"))); Assert.IsTrue(System.IO.File.Exists(System.IO.Path.Combine(packageRoot, "Data", "randomfile.something"))); Assert.IsTrue(System.IO.File.Exists(System.IO.Path.Combine(packageRoot, "Components", "Importer.dll"))); Assert.IsTrue(System.IO.File.Exists(System.IO.Path.Combine(packageRoot, "Types", "DictionaryTermWeights.dll"))); Assert.IsTrue(System.IO.File.Exists(System.IO.Path.Combine(packageRoot, "somerandomfile.xml"))); }