public void TestFileReading() { var file = TestBacking.WriteBytesToDisk(Resources.SampleGEDX); var fi = new FileInfo(file); using (GedcomxFile test = new GedcomxFile(fi)) { Assert.AreEqual(4, test.Entries.Count()); var gedxEntry = test.Entries.Where(x => x.ZipEntry.FullName == "tree.xml").Single(); var imageEntry1 = test.Entries.Where(x => x.ZipEntry.FullName == "person1.png").Single(); var imageEntry2 = test.Entries.Where(x => x.ZipEntry.FullName == "person2.png").Single(); Assert.AreEqual("application/x-gedcomx-v1+xml", gedxEntry.GetAttribute("Content-Type")); Assert.AreEqual("image/png", imageEntry1.GetAttribute("Content-Type")); Assert.AreEqual("image/png", imageEntry2.GetAttribute("Content-Type")); var gedx = test.ReadResource <Gx.Gedcomx>(gedxEntry); var image1 = test.GetResourceStream(imageEntry1); var image2 = test.GetResourceStream(imageEntry2); Assert.AreEqual(4, gedx.Persons.Count); Assert.AreEqual(4, gedx.Relationships.Count); Assert.DoesNotThrow(() => new Bitmap(image1)); Assert.DoesNotThrow(() => new Bitmap(image2)); } }
public void TestReadingJarFile() { var file = TestBacking.WriteBytesToDisk(Resources.SampleGEDX); var fi = new FileInfo(file); using (GedcomxFile test = new GedcomxFile(fi)) { Assert.IsNotNull(test); Assert.IsNotNull(test.Attributes); Assert.AreEqual(2, test.Attributes.Count); Assert.IsNotNull(test.GetAttribute("Manifest-Version")); Assert.IsNotNull(test.Entries); Assert.Greater(test.Entries.Count(), 0); foreach (var entry in test.Entries) { using (var stream = test.GetResourceStream(entry)) { Assert.IsNotNull(stream); Assert.IsTrue(stream.CanRead); } } } }
public void TestFileReading() { var file = TestBacking.WriteBytesToDisk(Resources.SampleGEDX); var fi = new FileInfo(file); using (GedcomxFile test = new GedcomxFile(fi)) { Assert.AreEqual(4, test.Entries.Count()); var gedxEntry = test.Entries.Where(x => x.ZipEntry.FullName == "tree.xml").Single(); var imageEntry1 = test.Entries.Where(x => x.ZipEntry.FullName == "person1.png").Single(); var imageEntry2 = test.Entries.Where(x => x.ZipEntry.FullName == "person2.png").Single(); Assert.AreEqual("application/x-gedcomx-v1+xml", gedxEntry.GetAttribute("Content-Type")); Assert.AreEqual("image/png", imageEntry1.GetAttribute("Content-Type")); Assert.AreEqual("image/png", imageEntry2.GetAttribute("Content-Type")); var gedx = test.ReadResource<Gx.Gedcomx>(gedxEntry); var image1 = test.GetResourceStream(imageEntry1); var image2 = test.GetResourceStream(imageEntry2); Assert.AreEqual(4, gedx.Persons.Count); Assert.AreEqual(4, gedx.Relationships.Count); Assert.DoesNotThrow(() => new Bitmap(image1)); Assert.DoesNotThrow(() => new Bitmap(image2)); } }