Skip to content

Commit

Permalink
Remove List<T> inheritance for 6 schema classes
Browse files Browse the repository at this point in the history
  • Loading branch information
vers-one committed Sep 17, 2022
1 parent 76a1492 commit d8e4946
Show file tree
Hide file tree
Showing 27 changed files with 977 additions and 717 deletions.
6 changes: 3 additions & 3 deletions Source/VersOne.Epub.Test/Unit/Comparers/Epub2NcxComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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);
}
}

Expand Down
62 changes: 37 additions & 25 deletions Source/VersOne.Epub.Test/Unit/Readers/BookCoverReaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -45,10 +45,13 @@ public void ReadBookCoverForEpub2WithCoverInGuideTest()
EpubBookRef epubBookRef = CreateEmptyEpubBookRef(EpubVersion.EPUB_2);
epubBookRef.Schema.Package.Guide = new EpubGuide()
{
new EpubGuideReference()
Items = new List<EpubGuideReference>()
{
Type = "cover",
Href = "cover.jpg"
new EpubGuideReference()
{
Type = "cover",
Href = "cover.jpg"
}
}
};
EpubByteContentFileRef expectedCoverImageFileRef = CreateTestImageFileRef(epubBookRef);
Expand All @@ -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",
Expand Down Expand Up @@ -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,
Expand All @@ -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",
Expand All @@ -173,10 +176,13 @@ public void ReadBookCoverForEpub2WithNoCoverInMetadataAndGuideTest()
EpubBookRef epubBookRef = CreateEmptyEpubBookRef(EpubVersion.EPUB_2);
epubBookRef.Schema.Package.Guide = new EpubGuide()
{
new EpubGuideReference()
Items = new List<EpubGuideReference>()
{
Type = "test-type",
Href = "test.jpg"
new EpubGuideReference()
{
Type = "test-type",
Href = "test.jpg"
}
}
};
TestSuccessfulReadOperation(epubBookRef, null);
Expand All @@ -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<EpubManifestItem>()
{
Id = "test-item-with-property",
Href = "toc.html",
MediaType = "application/xhtml+xml",
Properties = new List<EpubManifestProperty>()
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>()
{
EpubManifestProperty.NAV
}
}
}
};
Expand All @@ -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,
Expand All @@ -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",
Expand Down Expand Up @@ -283,7 +292,10 @@ private EpubBookRef CreateEmptyEpubBookRef(EpubVersion epubVersion)
Links = new List<EpubMetadataLink>(),
MetaItems = new List<EpubMetadataMeta>()
},
Manifest = new EpubManifest(),
Manifest = new EpubManifest()
{
Items = new List<EpubManifestItem>()
},
Spine = new EpubSpine(),
Guide = null
}
Expand Down
Loading

0 comments on commit d8e4946

Please sign in to comment.