File size: 2,918 Bytes
fab29d7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
namespace VersOne.Epub.Test.Comparers
{
internal static class EpubContentRefComparer
{
public static void CompareEpubContentRefs(EpubContentRef expected, EpubContentRef actual)
{
CompareEpubLocalContentFileRefs(expected.Cover, actual.Cover);
CompareEpubLocalContentFileRefs(expected.NavigationHtmlFile, actual.NavigationHtmlFile);
CompareContentCollectionRefs(expected.Html, actual.Html);
CompareContentCollectionRefs(expected.Css, actual.Css);
CompareContentCollectionRefs(expected.Images, actual.Images);
CompareContentCollectionRefs(expected.Fonts, actual.Fonts);
CompareContentCollectionRefs(expected.Audio, actual.Audio);
CompareContentCollectionRefs(expected.AllFiles, actual.AllFiles);
}
public static void CompareEpubLocalContentFileRefs(EpubLocalContentFileRef? expected, EpubLocalContentFileRef? actual)
{
CompareEpubContentFileRefs(expected, actual);
if (expected != null)
{
Assert.NotNull(actual);
Assert.Equal(expected.FilePath, actual.FilePath);
}
}
public static void CompareEpubRemoteContentFileRefs(EpubRemoteContentFileRef? expected, EpubRemoteContentFileRef? actual)
{
CompareEpubContentFileRefs(expected, actual);
if (expected != null)
{
Assert.NotNull(actual);
Assert.Equal(expected.Url, actual.Url);
}
}
private static void CompareContentCollectionRefs<TLocalContentFileRef, TRemoteContentFileRef>(
EpubContentCollectionRef<TLocalContentFileRef, TRemoteContentFileRef> expected,
EpubContentCollectionRef<TLocalContentFileRef, TRemoteContentFileRef> actual)
where TLocalContentFileRef : EpubLocalContentFileRef
where TRemoteContentFileRef : EpubRemoteContentFileRef
{
CollectionComparer.CompareCollections(expected.Local, actual.Local, CompareEpubLocalContentFileRefs);
CollectionComparer.CompareCollections(expected.Remote, actual.Remote, CompareEpubRemoteContentFileRefs);
}
private static void CompareEpubContentFileRefs(EpubContentFileRef? expected, EpubContentFileRef? actual)
{
if (expected == null)
{
Assert.Null(actual);
}
else
{
Assert.NotNull(actual);
Assert.Equal(expected.GetType(), actual.GetType());
Assert.Equal(expected.Key, actual.Key);
Assert.Equal(expected.ContentLocation, actual.ContentLocation);
Assert.Equal(expected.ContentType, actual.ContentType);
Assert.Equal(expected.ContentMimeType, actual.ContentMimeType);
}
}
}
}
|