Skip to content

Commit

Permalink
Add missing EPUB 3 attributes for all schema types (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
vers-one authored May 10, 2023
1 parent 02305b8 commit 148e71a
Show file tree
Hide file tree
Showing 125 changed files with 4,015 additions and 1,291 deletions.
194 changes: 194 additions & 0 deletions Source/VersOne.Epub.Test/Comparers/EpubMetadataComparer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
using VersOne.Epub.Schema;

namespace VersOne.Epub.Test.Comparers
{
internal static class EpubMetadataComparer
{
public static void CompareEpubMetadatas(EpubMetadata? expected, EpubMetadata? actual)
{
if (expected == null)
{
Assert.Null(actual);
}
else
{
Assert.NotNull(actual);
CollectionComparer.CompareCollections(expected.Titles, actual.Titles, CompareEpubMetadataTitles);
CollectionComparer.CompareCollections(expected.Creators, actual.Creators, CompareEpubMetadataCreators);
CollectionComparer.CompareCollections(expected.Subjects, actual.Subjects, CompareEpubMetadataSubjects);
CollectionComparer.CompareCollections(expected.Descriptions, actual.Descriptions, CompareEpubMetadataDescriptions);
CollectionComparer.CompareCollections(expected.Publishers, actual.Publishers, CompareEpubMetadataPublishers);
CollectionComparer.CompareCollections(expected.Contributors, actual.Contributors, CompareEpubMetadataContributors);
CollectionComparer.CompareCollections(expected.Dates, actual.Dates, CompareEpubMetadataDates);
CollectionComparer.CompareCollections(expected.Types, actual.Types, CompareEpubMetadataTypes);
CollectionComparer.CompareCollections(expected.Formats, actual.Formats, CompareEpubMetadataFormats);
CollectionComparer.CompareCollections(expected.Identifiers, actual.Identifiers, CompareEpubMetadataIdentifiers);
CollectionComparer.CompareCollections(expected.Sources, actual.Sources, CompareEpubMetadataSources);
CollectionComparer.CompareCollections(expected.Languages, actual.Languages, CompareEpubMetadataLanguages);
CollectionComparer.CompareCollections(expected.Relations, actual.Relations, CompareEpubMetadataRelations);
CollectionComparer.CompareCollections(expected.Coverages, actual.Coverages, CompareEpubMetadataCoverages);
CollectionComparer.CompareCollections(expected.Rights, actual.Rights, CompareEpubMetadataRights);
CompareEpubMetadataLinkLists(expected.Links, actual.Links);
CollectionComparer.CompareCollections(expected.MetaItems, actual.MetaItems, CompareEpubMetadataMetas);
}
}

public static void CompareEpubMetadataTitles(EpubMetadataTitle expected, EpubMetadataTitle actual)
{
Assert.NotNull(actual);
Assert.Equal(expected.Title, actual.Title);
Assert.Equal(expected.Id, actual.Id);
Assert.Equal(expected.TextDirection, actual.TextDirection);
Assert.Equal(expected.Language, actual.Language);
}

public static void CompareEpubMetadataCreators(EpubMetadataCreator expected, EpubMetadataCreator actual)
{
Assert.NotNull(actual);
Assert.Equal(expected.Creator, actual.Creator);
Assert.Equal(expected.Id, actual.Id);
Assert.Equal(expected.FileAs, actual.FileAs);
Assert.Equal(expected.Role, actual.Role);
Assert.Equal(expected.TextDirection, actual.TextDirection);
Assert.Equal(expected.Language, actual.Language);
}

public static void CompareEpubMetadataSubjects(EpubMetadataSubject expected, EpubMetadataSubject actual)
{
Assert.NotNull(actual);
Assert.Equal(expected.Subject, actual.Subject);
Assert.Equal(expected.Id, actual.Id);
Assert.Equal(expected.TextDirection, actual.TextDirection);
Assert.Equal(expected.Language, actual.Language);
}

public static void CompareEpubMetadataDescriptions(EpubMetadataDescription expected, EpubMetadataDescription actual)
{
Assert.NotNull(actual);
Assert.Equal(expected.Description, actual.Description);
Assert.Equal(expected.Id, actual.Id);
Assert.Equal(expected.TextDirection, actual.TextDirection);
Assert.Equal(expected.Language, actual.Language);
}

public static void CompareEpubMetadataPublishers(EpubMetadataPublisher expected, EpubMetadataPublisher actual)
{
Assert.NotNull(actual);
Assert.Equal(expected.Publisher, actual.Publisher);
Assert.Equal(expected.Id, actual.Id);
Assert.Equal(expected.TextDirection, actual.TextDirection);
Assert.Equal(expected.Language, actual.Language);
}

public static void CompareEpubMetadataContributors(EpubMetadataContributor expected, EpubMetadataContributor actual)
{
Assert.NotNull(actual);
Assert.Equal(expected.Contributor, actual.Contributor);
Assert.Equal(expected.Id, actual.Id);
Assert.Equal(expected.FileAs, actual.FileAs);
Assert.Equal(expected.Role, actual.Role);
Assert.Equal(expected.TextDirection, actual.TextDirection);
Assert.Equal(expected.Language, actual.Language);
}

public static void CompareEpubMetadataDates(EpubMetadataDate expected, EpubMetadataDate actual)
{
Assert.NotNull(actual);
Assert.Equal(expected.Date, actual.Date);
Assert.Equal(expected.Id, actual.Id);
Assert.Equal(expected.Event, actual.Event);
}

public static void CompareEpubMetadataTypes(EpubMetadataType expected, EpubMetadataType actual)
{
Assert.NotNull(actual);
Assert.Equal(expected.Type, actual.Type);
Assert.Equal(expected.Id, actual.Id);
}

public static void CompareEpubMetadataFormats(EpubMetadataFormat expected, EpubMetadataFormat actual)
{
Assert.NotNull(actual);
Assert.Equal(expected.Format, actual.Format);
Assert.Equal(expected.Id, actual.Id);
}

public static void CompareEpubMetadataIdentifiers(EpubMetadataIdentifier expected, EpubMetadataIdentifier actual)
{
Assert.NotNull(actual);
Assert.Equal(expected.Identifier, actual.Identifier);
Assert.Equal(expected.Id, actual.Id);
Assert.Equal(expected.Scheme, actual.Scheme);
}

public static void CompareEpubMetadataSources(EpubMetadataSource expected, EpubMetadataSource actual)
{
Assert.NotNull(actual);
Assert.Equal(expected.Source, actual.Source);
Assert.Equal(expected.Id, actual.Id);
}

public static void CompareEpubMetadataLanguages(EpubMetadataLanguage expected, EpubMetadataLanguage actual)
{
Assert.NotNull(actual);
Assert.Equal(expected.Language, actual.Language);
Assert.Equal(expected.Id, actual.Id);
}

public static void CompareEpubMetadataRelations(EpubMetadataRelation expected, EpubMetadataRelation actual)
{
Assert.NotNull(actual);
Assert.Equal(expected.Relation, actual.Relation);
Assert.Equal(expected.Id, actual.Id);
Assert.Equal(expected.TextDirection, actual.TextDirection);
Assert.Equal(expected.Language, actual.Language);
}

public static void CompareEpubMetadataCoverages(EpubMetadataCoverage expected, EpubMetadataCoverage actual)
{
Assert.NotNull(actual);
Assert.Equal(expected.Coverage, actual.Coverage);
Assert.Equal(expected.Id, actual.Id);
Assert.Equal(expected.TextDirection, actual.TextDirection);
Assert.Equal(expected.Language, actual.Language);
}

public static void CompareEpubMetadataRights(EpubMetadataRights expected, EpubMetadataRights actual)
{
Assert.NotNull(actual);
Assert.Equal(expected.Rights, actual.Rights);
Assert.Equal(expected.Id, actual.Id);
Assert.Equal(expected.TextDirection, actual.TextDirection);
Assert.Equal(expected.Language, actual.Language);
}

public static void CompareEpubMetadataLinkLists(List<EpubMetadataLink> expected, List<EpubMetadataLink> actual)
{
CollectionComparer.CompareCollections(expected, actual, CompareEpubMetadataLinks);
}

public static void CompareEpubMetadataLinks(EpubMetadataLink expected, EpubMetadataLink actual)
{
Assert.NotNull(actual);
Assert.Equal(expected.Href, actual.Href);
Assert.Equal(expected.Id, actual.Id);
Assert.Equal(expected.MediaType, actual.MediaType);
Assert.Equal(expected.Properties, actual.Properties);
Assert.Equal(expected.Refines, actual.Refines);
Assert.Equal(expected.Relationships, actual.Relationships);
}

public static void CompareEpubMetadataMetas(EpubMetadataMeta expected, EpubMetadataMeta actual)
{
Assert.NotNull(actual);
Assert.Equal(expected.Name, actual.Name);
Assert.Equal(expected.Content, actual.Content);
Assert.Equal(expected.Id, actual.Id);
Assert.Equal(expected.Refines, actual.Refines);
Assert.Equal(expected.Property, actual.Property);
Assert.Equal(expected.Scheme, actual.Scheme);
Assert.Equal(expected.TextDirection, actual.TextDirection);
Assert.Equal(expected.Language, actual.Language);
}
}
}
101 changes: 24 additions & 77 deletions Source/VersOne.Epub.Test/Comparers/EpubPackageComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,93 +7,23 @@ internal static class EpubPackageComparer
public static void CompareEpubPackages(EpubPackage expected, EpubPackage actual)
{
Assert.NotNull(actual);
Assert.Equal(expected.UniqueIdentifier, actual.UniqueIdentifier);
Assert.Equal(expected.EpubVersion, actual.EpubVersion);
CompareEpubMetadatas(expected.Metadata, actual.Metadata);
EpubMetadataComparer.CompareEpubMetadatas(expected.Metadata, actual.Metadata);
CompareEpubManifests(expected.Manifest, actual.Manifest);
CompareEpubSpines(expected.Spine, actual.Spine);
CompareEpubGuides(expected.Guide, actual.Guide);
}

public static void CompareEpubMetadatas(EpubMetadata expected, EpubMetadata actual)
{
Assert.NotNull(actual);
Assert.Equal(expected.Titles, actual.Titles);
CollectionComparer.CompareCollections(expected.Creators, actual.Creators, CompareEpubMetadataCreators);
Assert.Equal(expected.Subjects, actual.Subjects);
Assert.Equal(expected.Description, actual.Description);
Assert.Equal(expected.Publishers, actual.Publishers);
CollectionComparer.CompareCollections(expected.Contributors, actual.Contributors, CompareEpubMetadataContributors);
CollectionComparer.CompareCollections(expected.Dates, actual.Dates, CompareEpubMetadataDates);
Assert.Equal(expected.Types, actual.Types);
Assert.Equal(expected.Formats, actual.Formats);
CollectionComparer.CompareCollections(expected.Identifiers, actual.Identifiers, CompareEpubMetadataIdentifiers);
Assert.Equal(expected.Sources, actual.Sources);
Assert.Equal(expected.Languages, actual.Languages);
Assert.Equal(expected.Relations, actual.Relations);
Assert.Equal(expected.Coverages, actual.Coverages);
Assert.Equal(expected.Rights, actual.Rights);
CollectionComparer.CompareCollections(expected.Links, actual.Links, CompareEpubMetadataLinks);
CollectionComparer.CompareCollections(expected.MetaItems, actual.MetaItems, CompareEpubMetadataMetas);
}

public static void CompareEpubMetadataCreators(EpubMetadataCreator expected, EpubMetadataCreator actual)
{
Assert.NotNull(actual);
Assert.Equal(expected.Id, actual.Id);
Assert.Equal(expected.Creator, actual.Creator);
Assert.Equal(expected.FileAs, actual.FileAs);
Assert.Equal(expected.Role, actual.Role);
}

public static void CompareEpubMetadataContributors(EpubMetadataContributor expected, EpubMetadataContributor actual)
{
Assert.NotNull(actual);
Assert.Equal(expected.Id, actual.Id);
Assert.Equal(expected.Contributor, actual.Contributor);
Assert.Equal(expected.FileAs, actual.FileAs);
Assert.Equal(expected.Role, actual.Role);
}

public static void CompareEpubMetadataDates(EpubMetadataDate expected, EpubMetadataDate actual)
{
Assert.NotNull(actual);
Assert.Equal(expected.Date, actual.Date);
Assert.Equal(expected.Event, actual.Event);
}

public static void CompareEpubMetadataIdentifiers(EpubMetadataIdentifier expected, EpubMetadataIdentifier actual)
{
Assert.NotNull(actual);
CompareEpubCollectionLists(expected.Collections, actual.Collections);
Assert.Equal(expected.Id, actual.Id);
Assert.Equal(expected.Scheme, actual.Scheme);
Assert.Equal(expected.Identifier, actual.Identifier);
}

public static void CompareEpubMetadataLinks(EpubMetadataLink expected, EpubMetadataLink actual)
{
Assert.NotNull(actual);
Assert.Equal(expected.Id, actual.Id);
Assert.Equal(expected.Href, actual.Href);
Assert.Equal(expected.MediaType, actual.MediaType);
Assert.Equal(expected.Properties, actual.Properties);
Assert.Equal(expected.Refines, actual.Refines);
Assert.Equal(expected.Relationships, actual.Relationships);
}

public static void CompareEpubMetadataMetas(EpubMetadataMeta expected, EpubMetadataMeta actual)
{
Assert.NotNull(actual);
Assert.Equal(expected.Name, actual.Name);
Assert.Equal(expected.Content, actual.Content);
Assert.Equal(expected.Id, actual.Id);
Assert.Equal(expected.Refines, actual.Refines);
Assert.Equal(expected.Property, actual.Property);
Assert.Equal(expected.Scheme, actual.Scheme);
Assert.Equal(expected.TextDirection, actual.TextDirection);
Assert.Equal(expected.Prefix, actual.Prefix);
Assert.Equal(expected.Language, actual.Language);
}

public static void CompareEpubManifests(EpubManifest expected, EpubManifest actual)
{
Assert.NotNull(actual);
Assert.Equal(expected.Id, actual.Id);
CollectionComparer.CompareCollections(expected.Items, actual.Items, CompareEpubManifestItems);
}

Expand Down Expand Up @@ -154,5 +84,22 @@ public static void CompareEpubGuideReferences(EpubGuideReference expected, EpubG
Assert.Equal(expected.Title, actual.Title);
Assert.Equal(expected.Href, actual.Href);
}

public static void CompareEpubCollectionLists(List<EpubCollection> expected, List<EpubCollection> actual)
{
CollectionComparer.CompareCollections(expected, actual, CompareEpubCollections);
}

public static void CompareEpubCollections(EpubCollection expected, EpubCollection actual)
{
Assert.NotNull(actual);
Assert.Equal(expected.Role, actual.Role);
EpubMetadataComparer.CompareEpubMetadatas(expected.Metadata, actual.Metadata);
CompareEpubCollectionLists(expected.NestedCollections, actual.NestedCollections);
EpubMetadataComparer.CompareEpubMetadataLinkLists(expected.Links, actual.Links);
Assert.Equal(expected.Id, actual.Id);
Assert.Equal(expected.TextDirection, actual.TextDirection);
Assert.Equal(expected.Language, actual.Language);
}
}
}
Loading

0 comments on commit 148e71a

Please sign in to comment.