diff --git a/Source/VersOne.Epub.Test/Unit/Comparers/Epub2NcxComparer.cs b/Source/VersOne.Epub.Test/Unit/Comparers/Epub2NcxComparer.cs index 592a385..65be093 100644 --- a/Source/VersOne.Epub.Test/Unit/Comparers/Epub2NcxComparer.cs +++ b/Source/VersOne.Epub.Test/Unit/Comparers/Epub2NcxComparer.cs @@ -26,7 +26,7 @@ public static void CompareEpub2Ncxes(Epub2Ncx expected, Epub2Ncx actual) private static void CompareEpub2NcxHeads(Epub2NcxHead expected, Epub2NcxHead actual) { Assert.NotNull(actual); - AssertUtils.CollectionsEqual(expected, actual, ComprareEpub2NcxHeadMetas); + AssertUtils.CollectionsEqual(expected.Items, actual.Items, ComprareEpub2NcxHeadMetas); } private static void ComprareEpub2NcxHeadMetas(Epub2NcxHeadMeta expected, Epub2NcxHeadMeta actual) @@ -39,7 +39,7 @@ private static void ComprareEpub2NcxHeadMetas(Epub2NcxHeadMeta expected, Epub2Nc private static void CompareEpub2NcxNavigationMaps(Epub2NcxNavigationMap expected, Epub2NcxNavigationMap actual) { Assert.NotNull(actual); - AssertUtils.CollectionsEqual(expected, actual, CompareEpub2NcxNavigationPoints); + AssertUtils.CollectionsEqual(expected.Items, actual.Items, CompareEpub2NcxNavigationPoints); } private static void CompareEpub2NcxNavigationPoints(Epub2NcxNavigationPoint expected, Epub2NcxNavigationPoint actual) @@ -82,7 +82,7 @@ private static void CompareEpub2NcxPageLists(Epub2NcxPageList expected, Epub2Ncx else { Assert.NotNull(actual); - AssertUtils.CollectionsEqual(expected, actual, CompareEpub2NcxPageTargets); + AssertUtils.CollectionsEqual(expected.Items, actual.Items, CompareEpub2NcxPageTargets); } } diff --git a/Source/VersOne.Epub.Test/Unit/Comparers/EpubPackageComparer.cs b/Source/VersOne.Epub.Test/Unit/Comparers/EpubPackageComparer.cs index c0331c3..d83fc27 100644 --- a/Source/VersOne.Epub.Test/Unit/Comparers/EpubPackageComparer.cs +++ b/Source/VersOne.Epub.Test/Unit/Comparers/EpubPackageComparer.cs @@ -95,7 +95,7 @@ private static void CompareEpubMetadataMetas(EpubMetadataMeta expected, EpubMeta private static void CompareEpubManifests(EpubManifest expected, EpubManifest actual) { Assert.NotNull(actual); - AssertUtils.CollectionsEqual(expected, actual, CompareEpubManifestItems); + AssertUtils.CollectionsEqual(expected.Items, actual.Items, CompareEpubManifestItems); } private static void CompareEpubManifestItems(EpubManifestItem expected, EpubManifestItem actual) @@ -118,7 +118,7 @@ private static void CompareEpubSpines(EpubSpine expected, EpubSpine actual) Assert.Equal(expected.Id, actual.Id); Assert.Equal(expected.PageProgressionDirection, actual.PageProgressionDirection); Assert.Equal(expected.Toc, actual.Toc); - AssertUtils.CollectionsEqual(expected, actual, CompareEpubSpineItemRefs); + AssertUtils.CollectionsEqual(expected.Items, actual.Items, CompareEpubSpineItemRefs); } private static void CompareEpubSpineItemRefs(EpubSpineItemRef expected, EpubSpineItemRef actual) @@ -139,7 +139,7 @@ private static void CompareEpubGuides(EpubGuide expected, EpubGuide actual) else { Assert.NotNull(actual); - AssertUtils.CollectionsEqual(expected, actual, CompareEpubGuideReferences); + AssertUtils.CollectionsEqual(expected.Items, actual.Items, CompareEpubGuideReferences); } } diff --git a/Source/VersOne.Epub.Test/Unit/Readers/BookCoverReaderTests.cs b/Source/VersOne.Epub.Test/Unit/Readers/BookCoverReaderTests.cs index 842eeb8..08b635e 100644 --- a/Source/VersOne.Epub.Test/Unit/Readers/BookCoverReaderTests.cs +++ b/Source/VersOne.Epub.Test/Unit/Readers/BookCoverReaderTests.cs @@ -29,7 +29,7 @@ public void ReadBookCoverForEpub2WithCoverInMetadataTest() Name = "cover", Content = "cover-image" }); - epubBookRef.Schema.Package.Manifest.Add(new EpubManifestItem() + epubBookRef.Schema.Package.Manifest.Items.Add(new EpubManifestItem() { Id = "cover-image", Href = "cover.jpg", @@ -45,10 +45,13 @@ public void ReadBookCoverForEpub2WithCoverInGuideTest() EpubBookRef epubBookRef = CreateEmptyEpubBookRef(EpubVersion.EPUB_2); epubBookRef.Schema.Package.Guide = new EpubGuide() { - new EpubGuideReference() + Items = new List() { - Type = "cover", - Href = "cover.jpg" + new EpubGuideReference() + { + Type = "cover", + Href = "cover.jpg" + } } }; EpubByteContentFileRef expectedCoverImageFileRef = CreateTestImageFileRef(epubBookRef); @@ -59,7 +62,7 @@ public void ReadBookCoverForEpub2WithCoverInGuideTest() public void ReadBookCoverForEpub3WithCoverInManifestTest() { EpubBookRef epubBookRef = CreateEmptyEpubBookRef(EpubVersion.EPUB_3); - epubBookRef.Schema.Package.Manifest.Add(new EpubManifestItem() + epubBookRef.Schema.Package.Manifest.Items.Add(new EpubManifestItem() { Id = "cover-image", Href = "cover.jpg", @@ -140,7 +143,7 @@ public void ReadBookCoverForEpub2WithNullHrefInCoverManifestItemTest() Name = "cover", Content = "cover-image" }); - epubBookRef.Schema.Package.Manifest.Add(new EpubManifestItem() + epubBookRef.Schema.Package.Manifest.Items.Add(new EpubManifestItem() { Id = "cover-image", Href = null, @@ -158,7 +161,7 @@ public void ReadBookCoverForEpub2WithMissingManifestItemImageTest() Name = "cover", Content = "cover-image" }); - epubBookRef.Schema.Package.Manifest.Add(new EpubManifestItem() + epubBookRef.Schema.Package.Manifest.Items.Add(new EpubManifestItem() { Id = "cover-image", Href = "cover.jpg", @@ -173,10 +176,13 @@ public void ReadBookCoverForEpub2WithNoCoverInMetadataAndGuideTest() EpubBookRef epubBookRef = CreateEmptyEpubBookRef(EpubVersion.EPUB_2); epubBookRef.Schema.Package.Guide = new EpubGuide() { - new EpubGuideReference() + Items = new List() { - Type = "test-type", - Href = "test.jpg" + new EpubGuideReference() + { + Type = "test-type", + Href = "test.jpg" + } } }; TestSuccessfulReadOperation(epubBookRef, null); @@ -188,20 +194,23 @@ public void ReadBookCoverForEpub3WithNoCoverInManifestTest() EpubBookRef epubBookRef = CreateEmptyEpubBookRef(EpubVersion.EPUB_3); epubBookRef.Schema.Package.Manifest = new EpubManifest() { - new EpubManifestItem() - { - Id = "test-image", - Href = "test.jpg", - MediaType = "image/jpeg" - }, - new EpubManifestItem() + Items = new List() { - Id = "test-item-with-property", - Href = "toc.html", - MediaType = "application/xhtml+xml", - Properties = new List() + new EpubManifestItem() { - EpubManifestProperty.NAV + Id = "test-image", + Href = "test.jpg", + MediaType = "image/jpeg" + }, + new EpubManifestItem() + { + Id = "test-item-with-property", + Href = "toc.html", + MediaType = "application/xhtml+xml", + Properties = new List() + { + EpubManifestProperty.NAV + } } } }; @@ -212,7 +221,7 @@ public void ReadBookCoverForEpub3WithNoCoverInManifestTest() public void ReadBookCoverForEpub3WithNullHrefInCoverManifestItemTest() { EpubBookRef epubBookRef = CreateEmptyEpubBookRef(EpubVersion.EPUB_3); - epubBookRef.Schema.Package.Manifest.Add(new EpubManifestItem() + epubBookRef.Schema.Package.Manifest.Items.Add(new EpubManifestItem() { Id = "cover-image", Href = null, @@ -229,7 +238,7 @@ public void ReadBookCoverForEpub3WithNullHrefInCoverManifestItemTest() public void ReadBookCoverForEpub3WithMissingManifestItemImageTest() { EpubBookRef epubBookRef = CreateEmptyEpubBookRef(EpubVersion.EPUB_3); - epubBookRef.Schema.Package.Manifest.Add(new EpubManifestItem() + epubBookRef.Schema.Package.Manifest.Items.Add(new EpubManifestItem() { Id = "cover-image", Href = "cover.jpg", @@ -283,7 +292,10 @@ private EpubBookRef CreateEmptyEpubBookRef(EpubVersion epubVersion) Links = new List(), MetaItems = new List() }, - Manifest = new EpubManifest(), + Manifest = new EpubManifest() + { + Items = new List() + }, Spine = new EpubSpine(), Guide = null } diff --git a/Source/VersOne.Epub.Test/Unit/Readers/ContentReaderTests.cs b/Source/VersOne.Epub.Test/Unit/Readers/ContentReaderTests.cs index 34e945b..1b991e9 100644 --- a/Source/VersOne.Epub.Test/Unit/Readers/ContentReaderTests.cs +++ b/Source/VersOne.Epub.Test/Unit/Readers/ContentReaderTests.cs @@ -32,120 +32,123 @@ public void ParseContentMapWithFullEpubBookRefTest() EpubBookRef epubBookRef = CreateEmptyEpubBookRef(); epubBookRef.Schema.Package.Manifest = new EpubManifest() { - new EpubManifestItem() + Items = new List() { - Id = "item-1", - Href = "text.html", - MediaType = "application/xhtml+xml" - }, - new EpubManifestItem() - { - Id = "item-2", - Href = "doc.dtb", - MediaType = "application/x-dtbook+xml" - }, - new EpubManifestItem() - { - Id = "item-3", - Href = "toc.ncx", - MediaType = "application/x-dtbncx+xml" - }, - new EpubManifestItem() - { - Id = "item-4", - Href = "oeb.html", - MediaType = "text/x-oeb1-document" - }, - new EpubManifestItem() - { - Id = "item-5", - Href = "file.xml", - MediaType = "application/xml" - }, - new EpubManifestItem() - { - Id = "item-6", - Href = "styles.css", - MediaType = "text/css" - }, - new EpubManifestItem() - { - Id = "item-7", - Href = "oeb.css", - MediaType = "text/x-oeb1-css" - }, - new EpubManifestItem() - { - Id = "item-8", - Href = "image1.gif", - MediaType = "image/gif" - }, - new EpubManifestItem() - { - Id = "item-9", - Href = "image2.jpg", - MediaType = "image/jpeg" - }, - new EpubManifestItem() - { - Id = "item-10", - Href = "image3.png", - MediaType = "image/png" - }, - new EpubManifestItem() - { - Id = "item-11", - Href = "image4.svg", - MediaType = "image/svg+xml" - }, - new EpubManifestItem() - { - Id = "item-12", - Href = "font1.ttf", - MediaType = "font/truetype" - }, - new EpubManifestItem() - { - Id = "item-13", - Href = "font2.ttf", - MediaType = "application/x-font-truetype" - }, - new EpubManifestItem() - { - Id = "item-14", - Href = "font3.otf", - MediaType = "font/opentype" - }, - new EpubManifestItem() - { - Id = "item-15", - Href = "font4.otf", - MediaType = "application/vnd.ms-opentype" - }, - new EpubManifestItem() - { - Id = "item-16", - Href = "video.mp4", - MediaType = "video/mp4" - }, - new EpubManifestItem() - { - Id = "item-17", - Href = "cover.jpg", - MediaType = "image/jpeg", - Properties = new List() + new EpubManifestItem() { - EpubManifestProperty.COVER_IMAGE - } - }, - new EpubManifestItem() - { - Id = "item-18", - Href = "toc.html", - MediaType = "application/xhtml+xml", - Properties = new List() + Id = "item-1", + Href = "text.html", + MediaType = "application/xhtml+xml" + }, + new EpubManifestItem() { - EpubManifestProperty.NAV + Id = "item-2", + Href = "doc.dtb", + MediaType = "application/x-dtbook+xml" + }, + new EpubManifestItem() + { + Id = "item-3", + Href = "toc.ncx", + MediaType = "application/x-dtbncx+xml" + }, + new EpubManifestItem() + { + Id = "item-4", + Href = "oeb.html", + MediaType = "text/x-oeb1-document" + }, + new EpubManifestItem() + { + Id = "item-5", + Href = "file.xml", + MediaType = "application/xml" + }, + new EpubManifestItem() + { + Id = "item-6", + Href = "styles.css", + MediaType = "text/css" + }, + new EpubManifestItem() + { + Id = "item-7", + Href = "oeb.css", + MediaType = "text/x-oeb1-css" + }, + new EpubManifestItem() + { + Id = "item-8", + Href = "image1.gif", + MediaType = "image/gif" + }, + new EpubManifestItem() + { + Id = "item-9", + Href = "image2.jpg", + MediaType = "image/jpeg" + }, + new EpubManifestItem() + { + Id = "item-10", + Href = "image3.png", + MediaType = "image/png" + }, + new EpubManifestItem() + { + Id = "item-11", + Href = "image4.svg", + MediaType = "image/svg+xml" + }, + new EpubManifestItem() + { + Id = "item-12", + Href = "font1.ttf", + MediaType = "font/truetype" + }, + new EpubManifestItem() + { + Id = "item-13", + Href = "font2.ttf", + MediaType = "application/x-font-truetype" + }, + new EpubManifestItem() + { + Id = "item-14", + Href = "font3.otf", + MediaType = "font/opentype" + }, + new EpubManifestItem() + { + Id = "item-15", + Href = "font4.otf", + MediaType = "application/vnd.ms-opentype" + }, + new EpubManifestItem() + { + Id = "item-16", + Href = "video.mp4", + MediaType = "video/mp4" + }, + new EpubManifestItem() + { + Id = "item-17", + Href = "cover.jpg", + MediaType = "image/jpeg", + Properties = new List() + { + EpubManifestProperty.COVER_IMAGE + } + }, + new EpubManifestItem() + { + Id = "item-18", + Href = "toc.html", + MediaType = "application/xhtml+xml", + Properties = new List() + { + EpubManifestProperty.NAV + } } } }; @@ -339,7 +342,10 @@ private EpubBookRef CreateEmptyEpubBookRef() Links = new List(), MetaItems = new List() }, - Manifest = new EpubManifest(), + Manifest = new EpubManifest() + { + Items = new List() + }, Spine = new EpubSpine() } } diff --git a/Source/VersOne.Epub.Test/Unit/Readers/Epub2NcxReaderTests.cs b/Source/VersOne.Epub.Test/Unit/Readers/Epub2NcxReaderTests.cs index 5160a86..a5db164 100644 --- a/Source/VersOne.Epub.Test/Unit/Readers/Epub2NcxReaderTests.cs +++ b/Source/VersOne.Epub.Test/Unit/Readers/Epub2NcxReaderTests.cs @@ -375,11 +375,14 @@ public class Epub2NcxReaderTests { Manifest = new EpubManifest() { - new EpubManifestItem() + Items = new List() { - Id = TOC_ID, - Href = NCX_FILE_NAME, - MediaType = "application/x-dtbncx+xml" + new EpubManifestItem() + { + Id = TOC_ID, + Href = NCX_FILE_NAME, + MediaType = "application/x-dtbncx+xml" + } } }, Spine = new EpubSpine() @@ -391,10 +394,16 @@ public class Epub2NcxReaderTests private Epub2Ncx MinimalEpub2Ncx => new() { - Head = new Epub2NcxHead(), + Head = new Epub2NcxHead() + { + Items = new List() + }, DocTitle = null, DocAuthors = new List(), - NavMap = new Epub2NcxNavigationMap(), + NavMap = new Epub2NcxNavigationMap() + { + Items = new List() + }, PageList = null, NavLists = new List() }; @@ -404,36 +413,39 @@ public class Epub2NcxReaderTests { Head = new Epub2NcxHead() { - new Epub2NcxHeadMeta() + Items = new List() { - Name = "dtb:uid", - Content = "9781234567890" - }, - new Epub2NcxHeadMeta() - { - Name = "dtb:depth", - Content = "1" - }, - new Epub2NcxHeadMeta() - { - Name = "dtb:generator", - Content = "EpubWriter" - }, - new Epub2NcxHeadMeta() - { - Name = "dtb:totalPageCount", - Content = "0" - }, - new Epub2NcxHeadMeta() - { - Name = "dtb:maxPageNumber", - Content = "0" - }, - new Epub2NcxHeadMeta() - { - Name = "location", - Content = "https://example.com/books/123/ncx", - Scheme = "URI" + new Epub2NcxHeadMeta() + { + Name = "dtb:uid", + Content = "9781234567890" + }, + new Epub2NcxHeadMeta() + { + Name = "dtb:depth", + Content = "1" + }, + new Epub2NcxHeadMeta() + { + Name = "dtb:generator", + Content = "EpubWriter" + }, + new Epub2NcxHeadMeta() + { + Name = "dtb:totalPageCount", + Content = "0" + }, + new Epub2NcxHeadMeta() + { + Name = "dtb:maxPageNumber", + Content = "0" + }, + new Epub2NcxHeadMeta() + { + Name = "location", + Content = "https://example.com/books/123/ncx", + Scheme = "URI" + } } }, DocTitle = "Test title", @@ -444,123 +456,129 @@ public class Epub2NcxReaderTests }, NavMap = new Epub2NcxNavigationMap() { - new Epub2NcxNavigationPoint() + Items = new List() { - Id = "navpoint-1", - Class = "chapter", - PlayOrder = "1", - NavigationLabels = new List() + new Epub2NcxNavigationPoint() { - new Epub2NcxNavigationLabel() - { - Text = "Chapter 1" - }, - new Epub2NcxNavigationLabel() + Id = "navpoint-1", + Class = "chapter", + PlayOrder = "1", + NavigationLabels = new List() { - Text = "Capitolo 1" - } - }, - Content = new Epub2NcxContent() - { - Id = "content-1", - Source = "chapter1.html" - }, - ChildNavigationPoints = new List() - { - new Epub2NcxNavigationPoint() - { - Id = "navpoint-1-1", - Class = "section", - NavigationLabels = new List() + new Epub2NcxNavigationLabel() { - new Epub2NcxNavigationLabel() - { - Text = "Chapter 1.1" - } + Text = "Chapter 1" }, - Content = new Epub2NcxContent() + new Epub2NcxNavigationLabel() { - Id = "content-1-1", - Source = "chapter1.html#section-1" - }, - ChildNavigationPoints = new List() + Text = "Capitolo 1" + } }, - new Epub2NcxNavigationPoint() + Content = new Epub2NcxContent() { - Id = "navpoint-1-2", - Class = "section", - NavigationLabels = new List() + Id = "content-1", + Source = "chapter1.html" + }, + ChildNavigationPoints = new List() + { + new Epub2NcxNavigationPoint() { - new Epub2NcxNavigationLabel() + Id = "navpoint-1-1", + Class = "section", + NavigationLabels = new List() { - Text = "Chapter 1.2" - } + new Epub2NcxNavigationLabel() + { + Text = "Chapter 1.1" + } + }, + Content = new Epub2NcxContent() + { + Id = "content-1-1", + Source = "chapter1.html#section-1" + }, + ChildNavigationPoints = new List() }, - Content = new Epub2NcxContent() + new Epub2NcxNavigationPoint() { - Id = "content-1-2", - Source = "chapter1.html#section-2" - }, - ChildNavigationPoints = new List() - } - } - }, - new Epub2NcxNavigationPoint() - { - Id = "navpoint-2", - NavigationLabels = new List() - { - new Epub2NcxNavigationLabel() - { - Text = "Chapter 2" + Id = "navpoint-1-2", + Class = "section", + NavigationLabels = new List() + { + new Epub2NcxNavigationLabel() + { + Text = "Chapter 1.2" + } + }, + Content = new Epub2NcxContent() + { + Id = "content-1-2", + Source = "chapter1.html#section-2" + }, + ChildNavigationPoints = new List() + } } }, - Content = new Epub2NcxContent() + new Epub2NcxNavigationPoint() { - Source = "chapter2.html" - }, - ChildNavigationPoints = new List() + Id = "navpoint-2", + NavigationLabels = new List() + { + new Epub2NcxNavigationLabel() + { + Text = "Chapter 2" + } + }, + Content = new Epub2NcxContent() + { + Source = "chapter2.html" + }, + ChildNavigationPoints = new List() + } } }, PageList = new Epub2NcxPageList() { - new Epub2NcxPageTarget() + Items = new List() { - Id = "page-target-1", - Value = "1", - Type = Epub2NcxPageTargetType.FRONT, - Class = "front-matter", - PlayOrder = "1", - NavigationLabels = new List() + new Epub2NcxPageTarget() { - new Epub2NcxNavigationLabel() + Id = "page-target-1", + Value = "1", + Type = Epub2NcxPageTargetType.FRONT, + Class = "front-matter", + PlayOrder = "1", + NavigationLabels = new List() { - Text = "1" + new Epub2NcxNavigationLabel() + { + Text = "1" + }, + new Epub2NcxNavigationLabel() + { + Text = "I" + } }, - new Epub2NcxNavigationLabel() + Content = new Epub2NcxContent() { - Text = "I" + Source = "front.html" } }, - Content = new Epub2NcxContent() + new Epub2NcxPageTarget() { - Source = "front.html" - } - }, - new Epub2NcxPageTarget() - { - Type = Epub2NcxPageTargetType.NORMAL, - NavigationLabels = new List() - { - new Epub2NcxNavigationLabel() + Type = Epub2NcxPageTargetType.NORMAL, + NavigationLabels = new List() + { + new Epub2NcxNavigationLabel() + { + Text = "2" + } + }, + Content = new Epub2NcxContent { - Text = "2" + Id = "content-2", + Source = "chapter1.html#page-2" } - }, - Content = new Epub2NcxContent - { - Id = "content-2", - Source = "chapter1.html#page-2" } } }, @@ -654,25 +672,34 @@ public class Epub2NcxReaderTests private Epub2Ncx MinimalEpub2NcxWithUnknownPageTargetType => new() { - Head = new Epub2NcxHead(), + Head = new Epub2NcxHead() + { + Items = new List() + }, DocTitle = null, DocAuthors = new List(), - NavMap = new Epub2NcxNavigationMap(), + NavMap = new Epub2NcxNavigationMap() + { + Items = new List() + }, PageList = new Epub2NcxPageList() { - new Epub2NcxPageTarget() + Items = new List() { - Type = Epub2NcxPageTargetType.UNKNOWN, - NavigationLabels = new List() + new Epub2NcxPageTarget() { - new Epub2NcxNavigationLabel() + Type = Epub2NcxPageTargetType.UNKNOWN, + NavigationLabels = new List() + { + new Epub2NcxNavigationLabel() + { + Text = "1" + } + }, + Content = new Epub2NcxContent() { - Text = "1" + Source = "chapter1.html#page-1" } - }, - Content = new Epub2NcxContent() - { - Source = "chapter1.html#page-1" } } }, @@ -710,7 +737,10 @@ public async void ReadEpub2NcxAsyncWithoutTocManifestItemTest() TestZipFile testZipFile = new(); EpubPackage epubPackage = new() { - Manifest = new EpubManifest(), + Manifest = new EpubManifest() + { + Items = new List() + }, Spine = new EpubSpine() { Toc = TOC_ID diff --git a/Source/VersOne.Epub.Test/Unit/Readers/Epub3NavDocumentReaderTests.cs b/Source/VersOne.Epub.Test/Unit/Readers/Epub3NavDocumentReaderTests.cs index 33963f8..b4af2d1 100644 --- a/Source/VersOne.Epub.Test/Unit/Readers/Epub3NavDocumentReaderTests.cs +++ b/Source/VersOne.Epub.Test/Unit/Readers/Epub3NavDocumentReaderTests.cs @@ -124,14 +124,17 @@ public class Epub3NavDocumentReaderTests { Manifest = new EpubManifest() { - new EpubManifestItem() + Items = new List() { - Id = "nav", - Href = NAV_FILE_NAME, - MediaType = "application/xhtml+xml", - Properties = new List() + new EpubManifestItem() { - EpubManifestProperty.NAV + Id = "nav", + Href = NAV_FILE_NAME, + MediaType = "application/xhtml+xml", + Properties = new List() + { + EpubManifestProperty.NAV + } } } } @@ -274,11 +277,14 @@ public async void ReadEpub3NavDocumentAsyncForEpub3WithoutNavManifestItemTest() EpubVersion = EpubVersion.EPUB_3, Manifest = new EpubManifest() { - new EpubManifestItem() + Items = new List() { - Id = "test", - Href = "test.html", - MediaType = "application/xhtml+xml" + new EpubManifestItem() + { + Id = "test", + Href = "test.html", + MediaType = "application/xhtml+xml" + } } } }; @@ -294,6 +300,9 @@ public async void ReadEpub3NavDocumentAsyncForEpub2WithoutNavManifestItemTest() { EpubVersion = EpubVersion.EPUB_2, Manifest = new EpubManifest() + { + Items = new List() + } }; Epub3NavDocument epub3NavDocument = await Epub3NavDocumentReader.ReadEpub3NavDocumentAsync(testZipFile, CONTENT_DIRECTORY_PATH, epubPackage, new EpubReaderOptions()); Assert.Null(epub3NavDocument); diff --git a/Source/VersOne.Epub.Test/Unit/Readers/NavigationReaderTests.cs b/Source/VersOne.Epub.Test/Unit/Readers/NavigationReaderTests.cs index ea3d637..3ef48c2 100644 --- a/Source/VersOne.Epub.Test/Unit/Readers/NavigationReaderTests.cs +++ b/Source/VersOne.Epub.Test/Unit/Readers/NavigationReaderTests.cs @@ -68,37 +68,40 @@ public void GetNavigationItemsForEpub2WithFullNcxTest() { NavMap = new Epub2NcxNavigationMap() { - new Epub2NcxNavigationPoint() + Items = new List() { - NavigationLabels = new List() + new Epub2NcxNavigationPoint() { - new Epub2NcxNavigationLabel() + NavigationLabels = new List() { - Text = "Test label 1" + new Epub2NcxNavigationLabel() + { + Text = "Test label 1" + }, + new Epub2NcxNavigationLabel() + { + Text = "Test label 2" + } }, - new Epub2NcxNavigationLabel() + Content = new Epub2NcxContent() { - Text = "Test label 2" - } - }, - Content = new Epub2NcxContent() - { - Source = "chapter1.html" - }, - ChildNavigationPoints = new List() - { - new Epub2NcxNavigationPoint() + Source = "chapter1.html" + }, + ChildNavigationPoints = new List() { - NavigationLabels = new List() + new Epub2NcxNavigationPoint() { - new Epub2NcxNavigationLabel() + NavigationLabels = new List() { - Text = "Test label 3" + new Epub2NcxNavigationLabel() + { + Text = "Test label 3" + } + }, + Content = new Epub2NcxContent() + { + Source = "chapter1.html#section-1" } - }, - Content = new Epub2NcxContent() - { - Source = "chapter1.html#section-1" } } } diff --git a/Source/VersOne.Epub.Test/Unit/Readers/PackageReaderTests.cs b/Source/VersOne.Epub.Test/Unit/Readers/PackageReaderTests.cs index a44e6ea..df2cdae 100644 --- a/Source/VersOne.Epub.Test/Unit/Readers/PackageReaderTests.cs +++ b/Source/VersOne.Epub.Test/Unit/Readers/PackageReaderTests.cs @@ -345,10 +345,14 @@ public class PackageReaderTests { EpubVersion = EpubVersion.EPUB_2, Metadata = EmptyMetadata, - Manifest = new EpubManifest(), + Manifest = new EpubManifest() + { + Items = new List() + }, Spine = new EpubSpine() { - Toc = "ncx" + Toc = "ncx", + Items = new List() } }; @@ -357,8 +361,14 @@ public class PackageReaderTests { EpubVersion = EpubVersion.EPUB_3, Metadata = EmptyMetadata, - Manifest = new EpubManifest(), + Manifest = new EpubManifest() + { + Items = new List() + }, Spine = new EpubSpine() + { + Items = new List() + } }; private static EpubPackage MinimalEpub31Package => @@ -366,15 +376,21 @@ public class PackageReaderTests { EpubVersion = EpubVersion.EPUB_3_1, Metadata = EmptyMetadata, - Manifest = new EpubManifest(), + Manifest = new EpubManifest() + { + Items = new List() + }, Spine = new EpubSpine() + { + Items = new List() + } }; private static EpubPackage FullPackage { get { - EpubPackage result = new() + return new() { EpubVersion = EpubVersion.EPUB_3, Metadata = new EpubMetadata() @@ -573,178 +589,186 @@ private static EpubPackage FullPackage }, Manifest = new EpubManifest() { - new EpubManifestItem() + Items = new List() { - Id = "item-front", - Href = "front.html", - MediaType = "application/xhtml+xml" - }, - new EpubManifestItem() - { - Id = "cover", - Href = "cover.html", - MediaType = "application/xhtml+xml" - }, - new EpubManifestItem() - { - Id = "cover-image", - Href = "cover.jpg", - MediaType = "image/jpeg", - Properties = new List() + new EpubManifestItem() { - EpubManifestProperty.COVER_IMAGE - } - }, - new EpubManifestItem() - { - Id = "item-css", - Href = "styles.css", - MediaType = "text/css" - }, - new EpubManifestItem() - { - Id = "item-font", - Href = "font.ttf", - MediaType = "application/x-font-truetype" - }, - new EpubManifestItem() - { - Id = "item-1", - Href = "chapter1.html", - MediaType = "application/xhtml+xml", - MediaOverlay = "item-1-audio" - }, - new EpubManifestItem() - { - Id = "item-1-audio", - Href = "chapter1-audio.smil", - MediaType = "application/smil+xml" - }, - new EpubManifestItem() - { - Id = "item-2", - Href = "chapter2.html", - MediaType = "application/xhtml+xml" - }, - new EpubManifestItem() - { - Id = "item-2-fall", - Href = "chapter2.xml", - MediaType = "text/example+xml", - RequiredNamespace = "http://example.com/ns/example/", - RequiredModules = "ruby, server-side-image-map", - Fallback = "item-2", - FallbackStyle = "item-css" - }, - new EpubManifestItem() - { - Id = "item-3", - Href = "chapter3.html", - MediaType = "application/xhtml+xml" - }, - new EpubManifestItem() - { - Id = "item-3-fall", - Href = "chapter3.xml", - MediaType = "application/z3998-auth+xml", - Fallback = "item-3" - }, - new EpubManifestItem() - { - Id = "item-3-remote-audio", - Href = "http://example.com/audio/123/chapter3.mp4", - MediaType = "audio/mp4" - }, - new EpubManifestItem() - { - Id = "item-image", - Href = "image.jpg", - MediaType = "image/jpeg" - }, - new EpubManifestItem() - { - Id = "item-title-audio", - Href = "title.mp3", - MediaType = "audio/mpeg" - }, - new EpubManifestItem() - { - Id = "item-atom", - Href = "book.atom", - MediaType = "application/atom+xml" - }, - new EpubManifestItem() - { - Id = "item-toc", - Href = "toc.html", - MediaType = "application/xhtml+xml", - Properties = new List() + Id = "item-front", + Href = "front.html", + MediaType = "application/xhtml+xml" + }, + new EpubManifestItem() { - EpubManifestProperty.NAV + Id = "cover", + Href = "cover.html", + MediaType = "application/xhtml+xml" + }, + new EpubManifestItem() + { + Id = "cover-image", + Href = "cover.jpg", + MediaType = "image/jpeg", + Properties = new List() + { + EpubManifestProperty.COVER_IMAGE + } + }, + new EpubManifestItem() + { + Id = "item-css", + Href = "styles.css", + MediaType = "text/css" + }, + new EpubManifestItem() + { + Id = "item-font", + Href = "font.ttf", + MediaType = "application/x-font-truetype" + }, + new EpubManifestItem() + { + Id = "item-1", + Href = "chapter1.html", + MediaType = "application/xhtml+xml", + MediaOverlay = "item-1-audio" + }, + new EpubManifestItem() + { + Id = "item-1-audio", + Href = "chapter1-audio.smil", + MediaType = "application/smil+xml" + }, + new EpubManifestItem() + { + Id = "item-2", + Href = "chapter2.html", + MediaType = "application/xhtml+xml" + }, + new EpubManifestItem() + { + Id = "item-2-fall", + Href = "chapter2.xml", + MediaType = "text/example+xml", + RequiredNamespace = "http://example.com/ns/example/", + RequiredModules = "ruby, server-side-image-map", + Fallback = "item-2", + FallbackStyle = "item-css" + }, + new EpubManifestItem() + { + Id = "item-3", + Href = "chapter3.html", + MediaType = "application/xhtml+xml" + }, + new EpubManifestItem() + { + Id = "item-3-fall", + Href = "chapter3.xml", + MediaType = "application/z3998-auth+xml", + Fallback = "item-3" + }, + new EpubManifestItem() + { + Id = "item-3-remote-audio", + Href = "http://example.com/audio/123/chapter3.mp4", + MediaType = "audio/mp4" + }, + new EpubManifestItem() + { + Id = "item-image", + Href = "image.jpg", + MediaType = "image/jpeg" + }, + new EpubManifestItem() + { + Id = "item-title-audio", + Href = "title.mp3", + MediaType = "audio/mpeg" + }, + new EpubManifestItem() + { + Id = "item-atom", + Href = "book.atom", + MediaType = "application/atom+xml" + }, + new EpubManifestItem() + { + Id = "item-toc", + Href = "toc.html", + MediaType = "application/xhtml+xml", + Properties = new List() + { + EpubManifestProperty.NAV + } + }, + new EpubManifestItem() + { + Id = "ncx", + Href = "toc.ncx", + MediaType = "application/x-dtbncx+xml" } - }, - new EpubManifestItem() - { - Id = "ncx", - Href = "toc.ncx", - MediaType = "application/x-dtbncx+xml" } }, Spine = new EpubSpine() { - new EpubSpineItemRef() - { - Id = "itemref-1", - IdRef = "item-front", - IsLinear = true - }, - new EpubSpineItemRef() - { - Id = "itemref-2", - IdRef = "item-toc", - IsLinear = false - }, - new EpubSpineItemRef() - { - Id = "itemref-3", - IdRef = "item-1", - IsLinear = true - }, - new EpubSpineItemRef() + Id = "spine", + PageProgressionDirection = EpubPageProgressionDirection.LEFT_TO_RIGHT, + Toc = "ncx", + Items = new List() { - Id = "itemref-4", - IdRef = "item-2", - IsLinear = true, - Properties = new List() + new EpubSpineItemRef() { - EpubSpineProperty.PAGE_SPREAD_LEFT - } - }, - new EpubSpineItemRef() - { - Id = "itemref-5", - IdRef = "item-3", - IsLinear = true, - Properties = new List() + Id = "itemref-1", + IdRef = "item-front", + IsLinear = true + }, + new EpubSpineItemRef() + { + Id = "itemref-2", + IdRef = "item-toc", + IsLinear = false + }, + new EpubSpineItemRef() { - EpubSpineProperty.PAGE_SPREAD_RIGHT + Id = "itemref-3", + IdRef = "item-1", + IsLinear = true + }, + new EpubSpineItemRef() + { + Id = "itemref-4", + IdRef = "item-2", + IsLinear = true, + Properties = new List() + { + EpubSpineProperty.PAGE_SPREAD_LEFT + } + }, + new EpubSpineItemRef() + { + Id = "itemref-5", + IdRef = "item-3", + IsLinear = true, + Properties = new List() + { + EpubSpineProperty.PAGE_SPREAD_RIGHT + } } } }, Guide = new EpubGuide() { - new EpubGuideReference() + Items = new List() { - Type = "toc", - Title = "Contents", - Href = "toc.html" + new EpubGuideReference() + { + Type = "toc", + Title = "Contents", + Href = "toc.html" + } } } }; - result.Spine.Id = "spine"; - result.Spine.PageProgressionDirection = EpubPageProgressionDirection.LEFT_TO_RIGHT; - result.Spine.Toc = "ncx"; - return result; } } @@ -753,8 +777,14 @@ private static EpubPackage FullPackage { EpubVersion = EpubVersion.EPUB_2, Metadata = EmptyMetadata, - Manifest = new EpubManifest(), + Manifest = new EpubManifest() + { + Items = new List() + }, Spine = new EpubSpine() + { + Items = new List() + } }; diff --git a/Source/VersOne.Epub.Test/Unit/Readers/SchemaReaderTests.cs b/Source/VersOne.Epub.Test/Unit/Readers/SchemaReaderTests.cs index 76629b6..38a7f1e 100644 --- a/Source/VersOne.Epub.Test/Unit/Readers/SchemaReaderTests.cs +++ b/Source/VersOne.Epub.Test/Unit/Readers/SchemaReaderTests.cs @@ -135,48 +135,55 @@ public async void ReadSchemaAsyncTest() }, Manifest = new EpubManifest() { - new EpubManifestItem() + Items = new List() { - Id = "item-1", - Href = "chapter1.html", - MediaType = "application/xhtml+xml" - }, - new EpubManifestItem() - { - Id = "item-2", - Href = "chapter2.html", - MediaType = "application/xhtml+xml" - }, - new EpubManifestItem() - { - Id = "item-toc", - Href = NAV_FILE_NAME, - MediaType = "application/xhtml+xml", - Properties = new List() + new EpubManifestItem() + { + Id = "item-1", + Href = "chapter1.html", + MediaType = "application/xhtml+xml" + }, + new EpubManifestItem() + { + Id = "item-2", + Href = "chapter2.html", + MediaType = "application/xhtml+xml" + }, + new EpubManifestItem() { - EpubManifestProperty.NAV + Id = "item-toc", + Href = NAV_FILE_NAME, + MediaType = "application/xhtml+xml", + Properties = new List() + { + EpubManifestProperty.NAV + } + }, + new EpubManifestItem() + { + Id = "ncx", + Href = NCX_FILE_NAME, + MediaType = "application/x-dtbncx+xml" } - }, - new EpubManifestItem() - { - Id = "ncx", - Href = NCX_FILE_NAME, - MediaType = "application/x-dtbncx+xml" } }, Spine = new EpubSpine() { - new EpubSpineItemRef() + Toc = "ncx", + Items = new List() { - Id = "itemref-1", - IdRef = "item-1", - IsLinear = true - }, - new EpubSpineItemRef() - { - Id = "itemref-2", - IdRef = "item-2", - IsLinear = true + new EpubSpineItemRef() + { + Id = "itemref-1", + IdRef = "item-1", + IsLinear = true + }, + new EpubSpineItemRef() + { + Id = "itemref-2", + IdRef = "item-2", + IsLinear = true + } } } }, @@ -184,10 +191,13 @@ public async void ReadSchemaAsyncTest() { Head = new Epub2NcxHead() { - new Epub2NcxHeadMeta() + Items = new List() { - Name = "dtb:uid", - Content = "9781234567890" + new Epub2NcxHeadMeta() + { + Name = "dtb:uid", + Content = "9781234567890" + } } }, DocTitle = "Test title", @@ -197,37 +207,40 @@ public async void ReadSchemaAsyncTest() }, NavMap = new Epub2NcxNavigationMap() { - new Epub2NcxNavigationPoint() + Items = new List() { - Id = "navpoint-1", - NavigationLabels = new List() + new Epub2NcxNavigationPoint() { - new Epub2NcxNavigationLabel() + Id = "navpoint-1", + NavigationLabels = new List() { - Text = "Chapter 1" - } - }, - Content = new Epub2NcxContent() - { - Source = "chapter1.html" - }, - ChildNavigationPoints = new List() - }, - new Epub2NcxNavigationPoint() - { - Id = "navpoint-2", - NavigationLabels = new List() - { - new Epub2NcxNavigationLabel() + new Epub2NcxNavigationLabel() + { + Text = "Chapter 1" + } + }, + Content = new Epub2NcxContent() { - Text = "Chapter 2" - } + Source = "chapter1.html" + }, + ChildNavigationPoints = new List() }, - Content = new Epub2NcxContent() + new Epub2NcxNavigationPoint() { - Source = "chapter2.html" - }, - ChildNavigationPoints = new List() + Id = "navpoint-2", + NavigationLabels = new List() + { + new Epub2NcxNavigationLabel() + { + Text = "Chapter 2" + } + }, + Content = new Epub2NcxContent() + { + Source = "chapter2.html" + }, + ChildNavigationPoints = new List() + } } }, NavLists = new List() @@ -265,7 +278,6 @@ public async void ReadSchemaAsyncTest() } } }; - expectedEpubSchema.Package.Spine.Toc = "ncx"; EpubSchema actualEpubSchema = await SchemaReader.ReadSchemaAsync(testZipFile, new EpubReaderOptions()); EpubSchemaComparer.CompareEpubSchemas(expectedEpubSchema, actualEpubSchema); } diff --git a/Source/VersOne.Epub.Test/Unit/Readers/SpineReaderTests.cs b/Source/VersOne.Epub.Test/Unit/Readers/SpineReaderTests.cs index 02194a7..9fd2a4e 100644 --- a/Source/VersOne.Epub.Test/Unit/Readers/SpineReaderTests.cs +++ b/Source/VersOne.Epub.Test/Unit/Readers/SpineReaderTests.cs @@ -21,28 +21,34 @@ public void GetReadingOrderForTypicalSpineTest() EpubBookRef epubBookRef = CreateEmptyEpubBookRef(); epubBookRef.Schema.Package.Spine = new EpubSpine() { - new EpubSpineItemRef() + Items = new List() { - IdRef = "item-1" - }, - new EpubSpineItemRef() - { - IdRef = "item-2" + new EpubSpineItemRef() + { + IdRef = "item-1" + }, + new EpubSpineItemRef() + { + IdRef = "item-2" + } } }; epubBookRef.Schema.Package.Manifest = new EpubManifest() { - new EpubManifestItem() + Items = new List() { - Id = "item-1", - Href = "chapter1.html", - MediaType = "application/xhtml+xml" - }, - new EpubManifestItem() - { - Id = "item-2", - Href = "chapter2.html", - MediaType = "application/xhtml+xml" + new EpubManifestItem() + { + Id = "item-1", + Href = "chapter1.html", + MediaType = "application/xhtml+xml" + }, + new EpubManifestItem() + { + Id = "item-2", + Href = "chapter2.html", + MediaType = "application/xhtml+xml" + } } }; EpubTextContentFileRef expectedHtmlFileRef1 = CreateTestHtmlFileRef(epubBookRef, "chapter1.html"); @@ -73,18 +79,24 @@ public void GetReadingOrderWithMissingManifestItemTest() EpubBookRef epubBookRef = CreateEmptyEpubBookRef(); epubBookRef.Schema.Package.Spine = new EpubSpine() { - new EpubSpineItemRef() + Items = new List() { - IdRef = "item-1" + new EpubSpineItemRef() + { + IdRef = "item-1" + } } }; epubBookRef.Schema.Package.Manifest = new EpubManifest() { - new EpubManifestItem() + Items = new List() { - Id = "item-2", - Href = "chapter2.html", - MediaType = "application/xhtml+xml" + new EpubManifestItem() + { + Id = "item-2", + Href = "chapter2.html", + MediaType = "application/xhtml+xml" + } } }; Assert.Throws(() => SpineReader.GetReadingOrder(epubBookRef)); @@ -96,18 +108,24 @@ public void GetReadingOrderWithMissingHtmlContentFileTest() EpubBookRef epubBookRef = CreateEmptyEpubBookRef(); epubBookRef.Schema.Package.Spine = new EpubSpine() { - new EpubSpineItemRef() + Items = new List() { - IdRef = "item-1" + new EpubSpineItemRef() + { + IdRef = "item-1" + } } }; epubBookRef.Schema.Package.Manifest = new EpubManifest() { - new EpubManifestItem() + Items = new List() { - Id = "item-1", - Href = "chapter1.html", - MediaType = "application/xhtml+xml" + new EpubManifestItem() + { + Id = "item-1", + Href = "chapter1.html", + MediaType = "application/xhtml+xml" + } } }; epubBookRef.Content.Html = new Dictionary(); @@ -142,8 +160,14 @@ private EpubBookRef CreateEmptyEpubBookRef() Links = new List(), MetaItems = new List() }, - Manifest = new EpubManifest(), + Manifest = new EpubManifest() + { + Items = new List() + }, Spine = new EpubSpine() + { + Items = new List() + } } }, Content = new EpubContentRef() diff --git a/Source/VersOne.Epub.Test/Unit/RefEntities/EpubBookRefTests.cs b/Source/VersOne.Epub.Test/Unit/RefEntities/EpubBookRefTests.cs index 44c88ba..5ee71fe 100644 --- a/Source/VersOne.Epub.Test/Unit/RefEntities/EpubBookRefTests.cs +++ b/Source/VersOne.Epub.Test/Unit/RefEntities/EpubBookRefTests.cs @@ -125,18 +125,24 @@ private EpubBookRef CreateEpubBookRefWithReadingOrder(string htmlFileName) EpubBookRef epubBookRef = CreateEpubBookRef(new TestZipFile()); epubBookRef.Schema.Package.Spine = new EpubSpine() { - new EpubSpineItemRef() + Items = new List() { - IdRef = "item-1" + new EpubSpineItemRef() + { + IdRef = "item-1" + } } }; epubBookRef.Schema.Package.Manifest = new EpubManifest() { - new EpubManifestItem() + Items = new List() { - Id = "item-1", - Href = htmlFileName, - MediaType = "application/xhtml+xml" + new EpubManifestItem() + { + Id = "item-1", + Href = htmlFileName, + MediaType = "application/xhtml+xml" + } } }; EpubTextContentFileRef htmlFileRef = CreateTestHtmlFileRef(epubBookRef, htmlFileName); diff --git a/Source/VersOne.Epub.Test/Unit/Root/EpubReaderTests.cs b/Source/VersOne.Epub.Test/Unit/Root/EpubReaderTests.cs index db14349..e5139c2 100644 --- a/Source/VersOne.Epub.Test/Unit/Root/EpubReaderTests.cs +++ b/Source/VersOne.Epub.Test/Unit/Root/EpubReaderTests.cs @@ -488,18 +488,24 @@ private EpubSchema CreateMinimalExpectedEpubSchema() }, Manifest = new EpubManifest() { - new EpubManifestItem() + Items = new List() { - Id = "item-toc", - Href = NAV_FILE_NAME, - MediaType = HTML_CONTENT_MIME_TYPE, - Properties = new List() + new EpubManifestItem() { - EpubManifestProperty.NAV + Id = "item-toc", + Href = NAV_FILE_NAME, + MediaType = HTML_CONTENT_MIME_TYPE, + Properties = new List() + { + EpubManifestProperty.NAV + } } } }, - Spine = new EpubSpine(), + Spine = new EpubSpine() + { + Items = new List() + }, Guide = null }, Epub2Ncx = null, @@ -887,7 +893,7 @@ private EpubBook CreateFullExpectedEpubBook(string epubFilePath) private EpubSchema CreateFullExpectedEpubSchema() { - EpubSchema result = new() + return new() { Package = new EpubPackage() { @@ -923,100 +929,107 @@ private EpubSchema CreateFullExpectedEpubSchema() }, Manifest = new EpubManifest() { - new EpubManifestItem() - { - Id = "item-1", - Href = CHAPTER1_FILE_NAME, - MediaType = HTML_CONTENT_MIME_TYPE - }, - new EpubManifestItem() - { - Id = "item-2", - Href = CHAPTER2_FILE_NAME, - MediaType = HTML_CONTENT_MIME_TYPE - }, - new EpubManifestItem() - { - Id = "item-3", - Href = STYLES1_FILE_NAME, - MediaType = CSS_CONTENT_MIME_TYPE - }, - new EpubManifestItem() - { - Id = "item-4", - Href = STYLES2_FILE_NAME, - MediaType = CSS_CONTENT_MIME_TYPE - }, - new EpubManifestItem() - { - Id = "item-5", - Href = IMAGE1_FILE_NAME, - MediaType = IMAGE_CONTENT_MIME_TYPE - }, - new EpubManifestItem() - { - Id = "item-6", - Href = IMAGE2_FILE_NAME, - MediaType = IMAGE_CONTENT_MIME_TYPE - }, - new EpubManifestItem() - { - Id = "item-7", - Href = FONT1_FILE_NAME, - MediaType = FONT_CONTENT_MIME_TYPE - }, - new EpubManifestItem() + Items = new List() { - Id = "item-8", - Href = FONT2_FILE_NAME, - MediaType = FONT_CONTENT_MIME_TYPE - }, - new EpubManifestItem() - { - Id = "item-9", - Href = AUDIO_FILE_NAME, - MediaType = AUDIO_MPEG_CONTENT_MIME_TYPE - }, - new EpubManifestItem() - { - Id = "item-toc", - Href = NAV_FILE_NAME, - MediaType = HTML_CONTENT_MIME_TYPE, - Properties = new List() + new EpubManifestItem() { - EpubManifestProperty.NAV - } - }, - new EpubManifestItem() - { - Id = "item-cover", - Href = COVER_FILE_NAME, - MediaType = IMAGE_CONTENT_MIME_TYPE, - Properties = new List() + Id = "item-1", + Href = CHAPTER1_FILE_NAME, + MediaType = HTML_CONTENT_MIME_TYPE + }, + new EpubManifestItem() + { + Id = "item-2", + Href = CHAPTER2_FILE_NAME, + MediaType = HTML_CONTENT_MIME_TYPE + }, + new EpubManifestItem() + { + Id = "item-3", + Href = STYLES1_FILE_NAME, + MediaType = CSS_CONTENT_MIME_TYPE + }, + new EpubManifestItem() + { + Id = "item-4", + Href = STYLES2_FILE_NAME, + MediaType = CSS_CONTENT_MIME_TYPE + }, + new EpubManifestItem() + { + Id = "item-5", + Href = IMAGE1_FILE_NAME, + MediaType = IMAGE_CONTENT_MIME_TYPE + }, + new EpubManifestItem() + { + Id = "item-6", + Href = IMAGE2_FILE_NAME, + MediaType = IMAGE_CONTENT_MIME_TYPE + }, + new EpubManifestItem() + { + Id = "item-7", + Href = FONT1_FILE_NAME, + MediaType = FONT_CONTENT_MIME_TYPE + }, + new EpubManifestItem() { - EpubManifestProperty.COVER_IMAGE + Id = "item-8", + Href = FONT2_FILE_NAME, + MediaType = FONT_CONTENT_MIME_TYPE + }, + new EpubManifestItem() + { + Id = "item-9", + Href = AUDIO_FILE_NAME, + MediaType = AUDIO_MPEG_CONTENT_MIME_TYPE + }, + new EpubManifestItem() + { + Id = "item-toc", + Href = NAV_FILE_NAME, + MediaType = HTML_CONTENT_MIME_TYPE, + Properties = new List() + { + EpubManifestProperty.NAV + } + }, + new EpubManifestItem() + { + Id = "item-cover", + Href = COVER_FILE_NAME, + MediaType = IMAGE_CONTENT_MIME_TYPE, + Properties = new List() + { + EpubManifestProperty.COVER_IMAGE + } + }, + new EpubManifestItem() + { + Id = "ncx", + Href = NCX_FILE_NAME, + MediaType = NCX_CONTENT_MIME_TYPE } - }, - new EpubManifestItem() - { - Id = "ncx", - Href = NCX_FILE_NAME, - MediaType = NCX_CONTENT_MIME_TYPE } }, Spine = new EpubSpine() { - new EpubSpineItemRef() - { - Id = "itemref-1", - IdRef = "item-1", - IsLinear = true - }, - new EpubSpineItemRef() + Toc = "ncx", + Items = new List() { - Id = "itemref-2", - IdRef = "item-2", - IsLinear = true + new EpubSpineItemRef() + { + Id = "itemref-1", + IdRef = "item-1", + IsLinear = true + }, + new EpubSpineItemRef() + { + Id = "itemref-2", + IdRef = "item-2", + IsLinear = true + } } }, Guide = null @@ -1025,10 +1038,13 @@ private EpubSchema CreateFullExpectedEpubSchema() { Head = new Epub2NcxHead() { - new Epub2NcxHeadMeta() + Items = new List() { - Name = "dtb:uid", - Content = BOOK_UID + new Epub2NcxHeadMeta() + { + Name = "dtb:uid", + Content = BOOK_UID + } } }, DocTitle = BOOK_TITLE, @@ -1038,37 +1054,40 @@ private EpubSchema CreateFullExpectedEpubSchema() }, NavMap = new Epub2NcxNavigationMap() { - new Epub2NcxNavigationPoint() + Items = new List() { - Id = "navpoint-1", - NavigationLabels = new List() + new Epub2NcxNavigationPoint() { - new Epub2NcxNavigationLabel() + Id = "navpoint-1", + NavigationLabels = new List() { - Text = "Chapter 1" - } - }, - Content = new Epub2NcxContent() - { - Source = CHAPTER1_FILE_NAME - }, - ChildNavigationPoints = new List() - }, - new Epub2NcxNavigationPoint() - { - Id = "navpoint-2", - NavigationLabels = new List() - { - new Epub2NcxNavigationLabel() + new Epub2NcxNavigationLabel() + { + Text = "Chapter 1" + } + }, + Content = new Epub2NcxContent() { - Text = "Chapter 2" - } + Source = CHAPTER1_FILE_NAME + }, + ChildNavigationPoints = new List() }, - Content = new Epub2NcxContent() + new Epub2NcxNavigationPoint() { - Source = CHAPTER2_FILE_NAME - }, - ChildNavigationPoints = new List() + Id = "navpoint-2", + NavigationLabels = new List() + { + new Epub2NcxNavigationLabel() + { + Text = "Chapter 2" + } + }, + Content = new Epub2NcxContent() + { + Source = CHAPTER2_FILE_NAME + }, + ChildNavigationPoints = new List() + } } }, NavLists = new List() @@ -1107,8 +1126,6 @@ private EpubSchema CreateFullExpectedEpubSchema() }, ContentDirectoryPath = CONTENT_DIRECTORY_PATH }; - result.Package.Spine.Toc = "ncx"; - return result; } } } diff --git a/Source/VersOne.Epub/Readers/BookCoverReader.cs b/Source/VersOne.Epub/Readers/BookCoverReader.cs index fa91223..dedd6ce 100644 --- a/Source/VersOne.Epub/Readers/BookCoverReader.cs +++ b/Source/VersOne.Epub/Readers/BookCoverReader.cs @@ -52,7 +52,8 @@ private static EpubByteContentFileRef ReadEpub2CoverFromMetadata(EpubSchema epub { throw new EpubPackageException("Incorrect EPUB metadata: cover item content is missing."); } - EpubManifestItem coverManifestItem = epubSchema.Package.Manifest.FirstOrDefault(manifestItem => manifestItem.Id.CompareOrdinalIgnoreCase(coverMetaItem.Content)); + EpubManifestItem coverManifestItem = + epubSchema.Package.Manifest.Items.FirstOrDefault(manifestItem => manifestItem.Id.CompareOrdinalIgnoreCase(coverMetaItem.Content)); if (coverManifestItem == null) { throw new EpubPackageException($"Incorrect EPUB manifest: item with ID = \"{coverMetaItem.Content}\" is missing."); @@ -72,7 +73,7 @@ private static EpubByteContentFileRef ReadEpub2CoverFromGuide(EpubSchema epubSch { if (epubSchema.Package.Guide != null) { - foreach (EpubGuideReference guideReference in epubSchema.Package.Guide) + foreach (EpubGuideReference guideReference in epubSchema.Package.Guide.Items) { if (guideReference.Type.ToLowerInvariant() == "cover" && imageContentRefs.TryGetValue(guideReference.Href, out EpubByteContentFileRef coverImageContentFileRef)) { @@ -85,8 +86,8 @@ private static EpubByteContentFileRef ReadEpub2CoverFromGuide(EpubSchema epubSch private static EpubByteContentFileRef ReadEpub3Cover(EpubSchema epubSchema, Dictionary imageContentRefs) { - EpubManifestItem coverManifestItem = - epubSchema.Package.Manifest.FirstOrDefault(manifestItem => manifestItem.Properties != null && manifestItem.Properties.Contains(EpubManifestProperty.COVER_IMAGE)); + EpubManifestItem coverManifestItem = epubSchema.Package.Manifest.Items.FirstOrDefault(manifestItem => manifestItem.Properties != null && + manifestItem.Properties.Contains(EpubManifestProperty.COVER_IMAGE)); if (coverManifestItem == null || coverManifestItem.Href == null) { return null; diff --git a/Source/VersOne.Epub/Readers/ContentReader.cs b/Source/VersOne.Epub/Readers/ContentReader.cs index 71ea387..df3b10b 100644 --- a/Source/VersOne.Epub/Readers/ContentReader.cs +++ b/Source/VersOne.Epub/Readers/ContentReader.cs @@ -16,7 +16,7 @@ public static EpubContentRef ParseContentMap(EpubBookRef bookRef, ContentReaderO Fonts = new Dictionary(), AllFiles = new Dictionary() }; - foreach (EpubManifestItem manifestItem in bookRef.Schema.Package.Manifest) + foreach (EpubManifestItem manifestItem in bookRef.Schema.Package.Manifest.Items) { string fileName = manifestItem.Href; string contentMimeType = manifestItem.MediaType; diff --git a/Source/VersOne.Epub/Readers/Epub2NcxReader.cs b/Source/VersOne.Epub/Readers/Epub2NcxReader.cs index af18f4d..72a0b49 100644 --- a/Source/VersOne.Epub/Readers/Epub2NcxReader.cs +++ b/Source/VersOne.Epub/Readers/Epub2NcxReader.cs @@ -21,7 +21,7 @@ public static async Task ReadEpub2NcxAsync(IZipFile epubFile, string c { return null; } - EpubManifestItem tocManifestItem = package.Manifest.FirstOrDefault(item => item.Id.CompareOrdinalIgnoreCase(tocId)); + EpubManifestItem tocManifestItem = package.Manifest.Items.FirstOrDefault(item => item.Id.CompareOrdinalIgnoreCase(tocId)); if (tocManifestItem == null) { throw new Epub2NcxException($"EPUB parsing error: TOC item {tocId} not found in EPUB manifest."); @@ -93,7 +93,10 @@ public static async Task ReadEpub2NcxAsync(IZipFile epubFile, string c private static Epub2NcxHead ReadNavigationHead(XElement headNode) { - Epub2NcxHead result = new Epub2NcxHead(); + Epub2NcxHead result = new Epub2NcxHead() + { + Items = new List() + }; foreach (XElement metaNode in headNode.Elements()) { if (metaNode.CompareNameTo("meta")) @@ -123,7 +126,7 @@ private static Epub2NcxHead ReadNavigationHead(XElement headNode) { throw new Epub2NcxException("Incorrect EPUB navigation meta: meta content is missing."); } - result.Add(meta); + result.Items.Add(meta); } } return result; @@ -155,7 +158,10 @@ private static string ReadNavigationDocAuthor(XElement docAuthorNode) private static Epub2NcxNavigationMap ReadNavigationMap(XElement navigationMapNode, Epub2NcxReaderOptions epub2NcxReaderOptions) { - Epub2NcxNavigationMap result = new Epub2NcxNavigationMap(); + Epub2NcxNavigationMap result = new Epub2NcxNavigationMap() + { + Items = new List() + }; foreach (XElement navigationPointNode in navigationMapNode.Elements()) { if (navigationPointNode.CompareNameTo("navPoint")) @@ -163,7 +169,7 @@ private static Epub2NcxNavigationMap ReadNavigationMap(XElement navigationMapNod Epub2NcxNavigationPoint navigationPoint = ReadNavigationPoint(navigationPointNode, epub2NcxReaderOptions); if (navigationPoint != null) { - result.Add(navigationPoint); + result.Items.Add(navigationPoint); } } } @@ -271,13 +277,16 @@ private static Epub2NcxContent ReadNavigationContent(XElement navigationContentN private static Epub2NcxPageList ReadNavigationPageList(XElement navigationPageListNode) { - Epub2NcxPageList result = new Epub2NcxPageList(); + Epub2NcxPageList result = new Epub2NcxPageList() + { + Items = new List() + }; foreach (XElement pageTargetNode in navigationPageListNode.Elements()) { if (pageTargetNode.CompareNameTo("pageTarget")) { Epub2NcxPageTarget pageTarget = ReadNavigationPageTarget(pageTargetNode); - result.Add(pageTarget); + result.Items.Add(pageTarget); } } return result; diff --git a/Source/VersOne.Epub/Readers/Epub3NavDocumentReader.cs b/Source/VersOne.Epub/Readers/Epub3NavDocumentReader.cs index 596e597..e670c75 100644 --- a/Source/VersOne.Epub/Readers/Epub3NavDocumentReader.cs +++ b/Source/VersOne.Epub/Readers/Epub3NavDocumentReader.cs @@ -17,7 +17,7 @@ public static async Task ReadEpub3NavDocumentAsync(IZipFile ep { Epub3NavDocument result = new Epub3NavDocument(); EpubManifestItem navManifestItem = - package.Manifest.FirstOrDefault(item => item.Properties != null && item.Properties.Contains(EpubManifestProperty.NAV)); + package.Manifest.Items.FirstOrDefault(item => item.Properties != null && item.Properties.Contains(EpubManifestProperty.NAV)); if (navManifestItem == null) { if (package.EpubVersion == EpubVersion.EPUB_2) diff --git a/Source/VersOne.Epub/Readers/NavigationReader.cs b/Source/VersOne.Epub/Readers/NavigationReader.cs index e666baf..2eba6b2 100644 --- a/Source/VersOne.Epub/Readers/NavigationReader.cs +++ b/Source/VersOne.Epub/Readers/NavigationReader.cs @@ -21,7 +21,7 @@ public static List GetNavigationItems(EpubBookRef bookRef public static List GetNavigationItems(EpubBookRef bookRef, Epub2Ncx epub2Ncx) { - return GetNavigationItems(bookRef, epub2Ncx.NavMap); + return GetNavigationItems(bookRef, epub2Ncx.NavMap.Items); } public static List GetNavigationItems(EpubBookRef bookRef, Epub3NavDocument epub3NavDocument) diff --git a/Source/VersOne.Epub/Readers/PackageReader.cs b/Source/VersOne.Epub/Readers/PackageReader.cs index b74c28a..42b2051 100644 --- a/Source/VersOne.Epub/Readers/PackageReader.cs +++ b/Source/VersOne.Epub/Readers/PackageReader.cs @@ -312,7 +312,10 @@ private static EpubMetadataMeta ReadMetadataMeta(XElement metadataMetaNode) private static EpubManifest ReadManifest(XElement manifestNode, PackageReaderOptions packageReaderOptions) { - EpubManifest result = new EpubManifest(); + EpubManifest result = new EpubManifest() + { + Items = new List() + }; foreach (XElement manifestItemNode in manifestNode.Elements()) { if (manifestItemNode.CompareNameTo("item")) @@ -376,7 +379,7 @@ private static EpubManifest ReadManifest(XElement manifestNode, PackageReaderOpt } throw new EpubPackageException("Incorrect EPUB manifest: item media type is missing"); } - result.Add(manifestItem); + result.Items.Add(manifestItem); } } return result; @@ -384,7 +387,10 @@ private static EpubManifest ReadManifest(XElement manifestNode, PackageReaderOpt private static EpubSpine ReadSpine(XElement spineNode, EpubVersion epubVersion, PackageReaderOptions packageReaderOptions) { - EpubSpine result = new EpubSpine(); + EpubSpine result = new EpubSpine() + { + Items = new List() + }; foreach (XAttribute spineNodeAttribute in spineNode.Attributes()) { string attributeValue = spineNodeAttribute.Value; @@ -432,7 +438,7 @@ private static EpubSpine ReadSpine(XElement spineNode, EpubVersion epubVersion, } XAttribute linearAttribute = spineItemNode.Attribute("linear"); spineItemRef.IsLinear = linearAttribute == null || !linearAttribute.CompareValueTo("no"); - result.Add(spineItemRef); + result.Items.Add(spineItemRef); } } return result; @@ -440,7 +446,10 @@ private static EpubSpine ReadSpine(XElement spineNode, EpubVersion epubVersion, private static EpubGuide ReadGuide(XElement guideNode) { - EpubGuide result = new EpubGuide(); + EpubGuide result = new EpubGuide() + { + Items = new List() + }; foreach (XElement guideReferenceNode in guideNode.Elements()) { if (guideReferenceNode.CompareNameTo("reference")) @@ -470,7 +479,7 @@ private static EpubGuide ReadGuide(XElement guideNode) { throw new EpubPackageException("Incorrect EPUB guide: item href is missing"); } - result.Add(guideReference); + result.Items.Add(guideReference); } } return result; diff --git a/Source/VersOne.Epub/Readers/SpineReader.cs b/Source/VersOne.Epub/Readers/SpineReader.cs index 0b789e8..4bb3157 100644 --- a/Source/VersOne.Epub/Readers/SpineReader.cs +++ b/Source/VersOne.Epub/Readers/SpineReader.cs @@ -9,9 +9,9 @@ internal static class SpineReader public static List GetReadingOrder(EpubBookRef bookRef) { List result = new List(); - foreach (EpubSpineItemRef spineItemRef in bookRef.Schema.Package.Spine) + foreach (EpubSpineItemRef spineItemRef in bookRef.Schema.Package.Spine.Items) { - EpubManifestItem manifestItem = bookRef.Schema.Package.Manifest.FirstOrDefault(item => item.Id == spineItemRef.IdRef); + EpubManifestItem manifestItem = bookRef.Schema.Package.Manifest.Items.FirstOrDefault(item => item.Id == spineItemRef.IdRef); if (manifestItem == null) { throw new EpubPackageException($"Incorrect EPUB spine: item with IdRef = \"{spineItemRef.IdRef}\" is missing in the manifest."); diff --git a/Source/VersOne.Epub/Schema/Ncx/Epub2NcxHead.cs b/Source/VersOne.Epub/Schema/Ncx/Epub2NcxHead.cs index 86db429..a26a37a 100644 --- a/Source/VersOne.Epub/Schema/Ncx/Epub2NcxHead.cs +++ b/Source/VersOne.Epub/Schema/Ncx/Epub2NcxHead.cs @@ -10,7 +10,16 @@ namespace VersOne.Epub.Schema /// and for more information. /// /// - public class Epub2NcxHead : List + public class Epub2NcxHead { + /// + /// Gets a list of NCX metadata items. + /// + /// See , + /// , + /// and for more information. + /// + /// + public List Items { get; internal set; } } } diff --git a/Source/VersOne.Epub/Schema/Ncx/Epub2NcxNavigationMap.cs b/Source/VersOne.Epub/Schema/Ncx/Epub2NcxNavigationMap.cs index 33ba2f4..43a1112 100644 --- a/Source/VersOne.Epub/Schema/Ncx/Epub2NcxNavigationMap.cs +++ b/Source/VersOne.Epub/Schema/Ncx/Epub2NcxNavigationMap.cs @@ -10,7 +10,16 @@ namespace VersOne.Epub.Schema /// and for more information. /// /// - public class Epub2NcxNavigationMap : List + public class Epub2NcxNavigationMap { + /// + /// Gets a list of NCX navigation points for the primary navigation within the book (e.g., table of contents). + /// + /// See , + /// , + /// and for more information. + /// + /// + public List Items { get; internal set; } } } diff --git a/Source/VersOne.Epub/Schema/Ncx/Epub2NcxPageList.cs b/Source/VersOne.Epub/Schema/Ncx/Epub2NcxPageList.cs index 4eedd6a..8a47f01 100644 --- a/Source/VersOne.Epub/Schema/Ncx/Epub2NcxPageList.cs +++ b/Source/VersOne.Epub/Schema/Ncx/Epub2NcxPageList.cs @@ -10,7 +10,16 @@ namespace VersOne.Epub.Schema /// and for more information. /// /// - public class Epub2NcxPageList : List + public class Epub2NcxPageList { + /// + /// Gets a list of NCX page targets which provide pagination information. + /// + /// See , + /// , + /// and for more information. + /// + /// + public List Items { get; internal set; } } } diff --git a/Source/VersOne.Epub/Schema/Opf/EpubGuide.cs b/Source/VersOne.Epub/Schema/Opf/EpubGuide.cs index 9ae9666..e3aaa77 100644 --- a/Source/VersOne.Epub/Schema/Opf/EpubGuide.cs +++ b/Source/VersOne.Epub/Schema/Opf/EpubGuide.cs @@ -9,7 +9,15 @@ namespace VersOne.Epub.Schema /// and for more information. /// /// - public class EpubGuide : List + public class EpubGuide { + /// + /// Gets a list of EPUB 2 guide references to the key structural components of the EPUB book (e.g., cover page, table of contents, etc.). + /// + /// See + /// and for more information. + /// + /// + public List Items { get; internal set; } } } diff --git a/Source/VersOne.Epub/Schema/Opf/EpubManifest.cs b/Source/VersOne.Epub/Schema/Opf/EpubManifest.cs index 3cdf762..7b12cc2 100644 --- a/Source/VersOne.Epub/Schema/Opf/EpubManifest.cs +++ b/Source/VersOne.Epub/Schema/Opf/EpubManifest.cs @@ -9,7 +9,15 @@ namespace VersOne.Epub.Schema /// and for more information. /// /// - public class EpubManifest : List + public class EpubManifest { + /// + /// Gets a list of the content items that constitute the EPUB book. + /// + /// See + /// and for more information. + /// + /// + public List Items { get; internal set; } } } diff --git a/Source/VersOne.Epub/Schema/Opf/EpubSpine.cs b/Source/VersOne.Epub/Schema/Opf/EpubSpine.cs index b645664..43a3375 100644 --- a/Source/VersOne.Epub/Schema/Opf/EpubSpine.cs +++ b/Source/VersOne.Epub/Schema/Opf/EpubSpine.cs @@ -9,7 +9,7 @@ namespace VersOne.Epub.Schema /// and for more information. /// /// - public class EpubSpine : List + public class EpubSpine { /// /// Gets the unique ID of this EPUB spine. @@ -28,5 +28,14 @@ public class EpubSpine : List /// See for more information. /// public string Toc { get; internal set; } + + /// + /// Gets an ordered list of items that represent the default reading order of the EPUB book. + /// + /// See + /// and for more information. + /// + /// + public List Items { get; internal set; } } }