-
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.
Add
BookCoverReaderOptions.Epub2MetadataIgnoreMissingManifestItem
(#…
…121)
- Loading branch information
Showing
6 changed files
with
162 additions
and
44 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
Source/VersOne.Epub.Test/Unit/Options/BookCoverReaderOptionsTests.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,47 @@ | ||
using VersOne.Epub.Options; | ||
|
||
namespace VersOne.Epub.Test.Unit.Options | ||
{ | ||
public class BookCoverReaderOptionsTests | ||
{ | ||
[Fact(DisplayName = "Constructing a BookCoverReaderOptions instance with a non-null preset parameter should succeed")] | ||
public void ConstructorWithNonNullPresetTest() | ||
{ | ||
_ = new BookCoverReaderOptions(EpubReaderOptionsPreset.RELAXED); | ||
} | ||
|
||
[Fact(DisplayName = "Constructing a BookCoverReaderOptions instance with a null preset parameter should succeed")] | ||
public void ConstructorWithNullPresetTest() | ||
{ | ||
_ = new BookCoverReaderOptions(null); | ||
} | ||
|
||
[Fact(DisplayName = "Constructing a BookCoverReaderOptions instance with a null preset parameter should initialize properties with the expected values.")] | ||
public void InitializationWithNullPresetTest() | ||
{ | ||
BookCoverReaderOptions bookCoverReaderOptions = new(null); | ||
Assert.False(bookCoverReaderOptions.Epub2MetadataIgnoreMissingManifestItem); | ||
} | ||
|
||
[Fact(DisplayName = "Constructing a BookCoverReaderOptions instance with the STRICT preset parameter should initialize properties with the expected values.")] | ||
public void InitializationWithStrictPresetTest() | ||
{ | ||
BookCoverReaderOptions bookCoverReaderOptions = new(EpubReaderOptionsPreset.STRICT); | ||
Assert.False(bookCoverReaderOptions.Epub2MetadataIgnoreMissingManifestItem); | ||
} | ||
|
||
[Fact(DisplayName = "Constructing a BookCoverReaderOptions instance with the RELAXED preset parameter should initialize properties with the expected values.")] | ||
public void InitializationWithRelaxedPresetTest() | ||
{ | ||
BookCoverReaderOptions bookCoverReaderOptions = new(EpubReaderOptionsPreset.RELAXED); | ||
Assert.True(bookCoverReaderOptions.Epub2MetadataIgnoreMissingManifestItem); | ||
} | ||
|
||
[Fact(DisplayName = "Constructing a BookCoverReaderOptions instance with the IGNORE_ALL_ERRORS preset parameter should initialize properties with the expected values.")] | ||
public void InitializationWithIgnoreAllErrorsPresetTest() | ||
{ | ||
BookCoverReaderOptions bookCoverReaderOptions = new(EpubReaderOptionsPreset.IGNORE_ALL_ERRORS); | ||
Assert.True(bookCoverReaderOptions.Epub2MetadataIgnoreMissingManifestItem); | ||
} | ||
} | ||
} |
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,32 @@ | ||
namespace VersOne.Epub.Options | ||
{ | ||
/// <summary> | ||
/// Various options to configure the behavior of the EPUB book cover reader which is used for loading the EPUB book cover image. | ||
/// </summary> | ||
public class BookCoverReaderOptions | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="BookCoverReaderOptions"/> class. | ||
/// </summary> | ||
/// <param name="preset">An optional preset to initialize the <see cref="BookCoverReaderOptions" /> class with a predefined set of options.</param> | ||
public BookCoverReaderOptions(EpubReaderOptionsPreset? preset = null) | ||
{ | ||
switch (preset) | ||
{ | ||
case EpubReaderOptionsPreset.RELAXED: | ||
case EpubReaderOptionsPreset.IGNORE_ALL_ERRORS: | ||
Epub2MetadataIgnoreMissingManifestItem = true; | ||
break; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets a value indicating whether EPUB 2 book cover reader should ignore the error when the manifest item referenced by | ||
/// the EPUB 2 cover metadata item is missing. | ||
/// If it's set to <c>false</c> and the manifest item with the given ID is not present, then | ||
/// the "Incorrect EPUB manifest: item with ID = "..." referenced in EPUB 2 cover metadata is missing" exception will be thrown. | ||
/// Default value is <c>false</c>. | ||
/// </summary> | ||
public bool Epub2MetadataIgnoreMissingManifestItem { get; set; } | ||
} | ||
} |
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
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