public void PackageLoadTest() { string packageName = "TestPackage"; string packageDirectory = System.IO.Path.Combine(PackageTestRoot, packageName); Package target = new Package(packageDirectory, true); Assert.AreEqual("A939607B-7159-4466-88C4-A869044F81C6", target.ID); Assert.AreEqual("TestPackage", target.Name); Assert.AreEqual(2, target.References.Count()); Assert.AreEqual("1886E5F6-27CA-4D42-AB51-7B7BBD9E97C1", target.References.ElementAt(0).ID); Assert.AreEqual("E6D01E22-7C9E-4B75-B7C3-6FC8B33A9593", target.References.ElementAt(1).ID); Assert.AreEqual(1, target.ComponentLocations.Count()); Assert.AreEqual("./Components", target.ComponentLocations.ElementAt(0)); Assert.AreEqual(1, target.TypeLocations.Count()); Assert.AreEqual("./Types", target.TypeLocations.ElementAt(0)); Assert.AreEqual(6, target.Files.Count()); foreach (PackageFile file in target.Files) { Assert.AreEqual(target, file.Owner); string filePath = target.GetAbsolutePath(file); using (System.IO.FileStream reader = System.IO.File.OpenRead(filePath)) { Assert.AreEqual(reader.Length, file.UncompressedSize, "File does not match expected uncompressed size: " + file.Path); Assert.AreEqual(Package.ComputeHash(reader), file.UncompressedHash, "File does not match expected uncompressed hash: " + file.Path); reader.Seek(0, System.IO.SeekOrigin.Begin); // We can't validate the specific size of the compressed data or the hash of the compressed data // because the compression algorithm can change based on the runtime. And we don't need to validate the round-trip since // PackageFile already tests that. } } }