-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
1,359 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
Source/VersOne.Epub.Test/Unit/Comparers/EpubBookComparer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using VersOne.Epub.Test.Unit.TestUtils; | ||
|
||
namespace VersOne.Epub.Test.Unit.Comparers | ||
{ | ||
internal static class EpubBookComparer | ||
{ | ||
public static void CompareEpubBooks(EpubBook expected, EpubBook actual) | ||
{ | ||
Assert.NotNull(actual); | ||
Assert.Equal(expected.FilePath, actual.FilePath); | ||
Assert.Equal(expected.Title, actual.Title); | ||
Assert.Equal(expected.Author, actual.Author); | ||
Assert.Equal(expected.AuthorList, actual.AuthorList); | ||
Assert.Equal(expected.Description, actual.Description); | ||
Assert.Equal(expected.CoverImage, actual.CoverImage); | ||
AssertUtils.CollectionsEqual(expected.ReadingOrder, actual.ReadingOrder, EpubContentComparer.CompareEpubTextContentFiles); | ||
EpubNavigationItemComparer.CompareNavigationItemLists(expected.Navigation, actual.Navigation); | ||
EpubContentComparer.CompareEpubContents(expected.Content, actual.Content); | ||
EpubSchemaComparer.CompareEpubSchemas(expected.Schema, actual.Schema); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
Source/VersOne.Epub.Test/Unit/Comparers/EpubBookRefComparer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace VersOne.Epub.Test.Unit.Comparers | ||
{ | ||
internal static class EpubBookRefComparer | ||
{ | ||
public static void CompareEpubBookRefs(EpubBookRef expected, EpubBookRef actual) | ||
{ | ||
Assert.NotNull(actual); | ||
Assert.Equal(expected.FilePath, actual.FilePath); | ||
Assert.Equal(expected.Title, actual.Title); | ||
Assert.Equal(expected.Author, actual.Author); | ||
Assert.Equal(expected.AuthorList, actual.AuthorList); | ||
Assert.Equal(expected.Description, actual.Description); | ||
EpubSchemaComparer.CompareEpubSchemas(expected.Schema, actual.Schema); | ||
EpubContentRefComparer.CompareEpubContentRefs(expected.Content, actual.Content); | ||
Assert.Equal(expected.EpubFile, actual.EpubFile); | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
Source/VersOne.Epub.Test/Unit/Comparers/EpubContentComparer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using VersOne.Epub.Test.Unit.TestUtils; | ||
|
||
namespace VersOne.Epub.Test.Unit.Comparers | ||
{ | ||
internal static class EpubContentComparer | ||
{ | ||
public static void CompareEpubContents(EpubContent expected, EpubContent actual) | ||
{ | ||
CompareEpubContentFiles(expected.Cover, actual.Cover); | ||
CompareEpubContentFiles(expected.NavigationHtmlFile, actual.NavigationHtmlFile); | ||
AssertUtils.DictionariesEqual(expected.Html, actual.Html, CompareEpubTextContentFiles); | ||
AssertUtils.DictionariesEqual(expected.Css, actual.Css, CompareEpubTextContentFiles); | ||
AssertUtils.DictionariesEqual(expected.Images, actual.Images, CompareEpubByteContentFiles); | ||
AssertUtils.DictionariesEqual(expected.Fonts, actual.Fonts, CompareEpubByteContentFiles); | ||
AssertUtils.DictionariesEqual(expected.AllFiles, actual.AllFiles, CompareEpubContentFilesWithContent); | ||
} | ||
|
||
public static void CompareEpubTextContentFiles(EpubTextContentFile expected, EpubTextContentFile actual) | ||
{ | ||
CompareEpubContentFiles(expected, actual); | ||
Assert.Equal(expected.Content, actual.Content); | ||
} | ||
|
||
public static void CompareEpubByteContentFiles(EpubByteContentFile expected, EpubByteContentFile actual) | ||
{ | ||
CompareEpubContentFiles(expected, actual); | ||
Assert.Equal(expected.Content, actual.Content); | ||
} | ||
|
||
private static void CompareEpubContentFilesWithContent(EpubContentFile expected, EpubContentFile actual) | ||
{ | ||
if (expected is EpubTextContentFile) | ||
{ | ||
CompareEpubTextContentFiles(expected as EpubTextContentFile, actual as EpubTextContentFile); | ||
} | ||
else if (expected is EpubByteContentFile) | ||
{ | ||
CompareEpubByteContentFiles(expected as EpubByteContentFile, actual as EpubByteContentFile); | ||
} | ||
} | ||
|
||
private static void CompareEpubContentFiles(EpubContentFile expected, EpubContentFile actual) | ||
{ | ||
if (expected == null) | ||
{ | ||
Assert.Null(actual); | ||
} | ||
else | ||
{ | ||
Assert.NotNull(actual); | ||
Assert.Equal(expected.FileName, actual.FileName); | ||
Assert.Equal(expected.FilePathInEpubArchive, actual.FilePathInEpubArchive); | ||
Assert.Equal(expected.ContentType, actual.ContentType); | ||
Assert.Equal(expected.ContentMimeType, actual.ContentMimeType); | ||
} | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
Source/VersOne.Epub.Test/Unit/Comparers/EpubNavigationItemComparer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using VersOne.Epub.Test.Unit.TestUtils; | ||
|
||
namespace VersOne.Epub.Test.Unit.Comparers | ||
{ | ||
internal static class EpubNavigationItemComparer | ||
{ | ||
public static void CompareNavigationItemLists(List<EpubNavigationItem> expected, List<EpubNavigationItem> actual) | ||
{ | ||
if (expected == null) | ||
{ | ||
Assert.Null(actual); | ||
} | ||
else | ||
{ | ||
Assert.NotNull(actual); | ||
AssertUtils.CollectionsEqual(expected, actual, CompareNavigationItems); | ||
} | ||
} | ||
|
||
public static void CompareNavigationItemLinks(EpubNavigationItemLink expected, EpubNavigationItemLink actual) | ||
{ | ||
if (expected == null) | ||
{ | ||
Assert.Null(actual); | ||
} | ||
else | ||
{ | ||
Assert.NotNull(actual); | ||
Assert.Equal(expected.ContentFileName, actual.ContentFileName); | ||
Assert.Equal(expected.ContentFilePathInEpubArchive, actual.ContentFilePathInEpubArchive); | ||
Assert.Equal(expected.Anchor, actual.Anchor); | ||
} | ||
} | ||
|
||
private static void CompareNavigationItems(EpubNavigationItem expected, EpubNavigationItem actual) | ||
{ | ||
Assert.NotNull(actual); | ||
Assert.Equal(expected.Type, actual.Type); | ||
Assert.Equal(expected.Title, actual.Title); | ||
CompareNavigationItemLinks(expected.Link, actual.Link); | ||
EpubContentComparer.CompareEpubTextContentFiles(expected.HtmlContentFile, actual.HtmlContentFile); | ||
CompareNavigationItemLists(expected.NestedItems, actual.NestedItems); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using VersOne.Epub.Environment; | ||
|
||
namespace VersOne.Epub.Test.Unit.Mocks | ||
{ | ||
internal class TestFileSystem : IFileSystem | ||
{ | ||
private readonly Dictionary<string, TestZipFile> testZipFilesByPath; | ||
private readonly Dictionary<Stream, TestZipFile> testZipFilesByStream; | ||
|
||
public TestFileSystem() | ||
{ | ||
testZipFilesByPath = new Dictionary<string, TestZipFile>(); | ||
testZipFilesByStream = new Dictionary<Stream, TestZipFile>(); | ||
} | ||
|
||
public void AddTestZipFile(string path, TestZipFile testZipFile) | ||
{ | ||
testZipFilesByPath.Add(path, testZipFile); | ||
} | ||
|
||
public void AddTestZipFile(Stream stream, TestZipFile testZipFile) | ||
{ | ||
testZipFilesByStream.Add(stream, testZipFile); | ||
} | ||
|
||
public bool FileExists(string path) | ||
{ | ||
return testZipFilesByPath.ContainsKey(path); | ||
} | ||
|
||
public IZipFile OpenZipFile(string path) | ||
{ | ||
return testZipFilesByPath[path]; | ||
} | ||
|
||
public IZipFile OpenZipFile(Stream stream) | ||
{ | ||
return testZipFilesByStream[stream]; | ||
} | ||
} | ||
} |
Oops, something went wrong.