LediReader
/
EpubReader
/Source
/VersOne.Epub.Test
/Unit
/Content
/Collections
/EpubContentCollectionRefTests.cs
| using System.Collections.ObjectModel; | |
| using VersOne.Epub.Test.Comparers; | |
| using VersOne.Epub.Test.Unit.Mocks; | |
| using VersOne.Epub.Test.Unit.TestData; | |
| using static VersOne.Epub.Test.Unit.TestData.TestEpubData; | |
| namespace VersOne.Epub.Test.Unit.Content.Collections | |
| { | |
| public class EpubContentCollectionRefTests | |
| { | |
| private static ReadOnlyCollection<EpubLocalTextContentFileRef> Local | |
| { | |
| get | |
| { | |
| List<EpubLocalTextContentFileRef> list = new() | |
| { | |
| TestEpubContentRef.Chapter1FileRef, | |
| TestEpubContentRef.Chapter2FileRef | |
| }; | |
| return list.AsReadOnly(); | |
| } | |
| } | |
| private static ReadOnlyCollection<EpubRemoteTextContentFileRef> Remote | |
| { | |
| get | |
| { | |
| List<EpubRemoteTextContentFileRef> list = new() | |
| { | |
| TestEpubContentRef.RemoteHtmlContentFileRef, | |
| TestEpubContentRef.RemoteCssContentFileRef | |
| }; | |
| return list.AsReadOnly(); | |
| } | |
| } | |
| private static IEpubContentLoader ContentLoader => new TestEpubContentLoader(); | |
| [] | |
| public void ConstructorWithNonNullParametersTest() | |
| { | |
| EpubContentCollectionRef<EpubLocalTextContentFileRef, EpubRemoteTextContentFileRef> epubContentCollectionRef = new(); | |
| Assert.NotNull(epubContentCollectionRef.Local); | |
| Assert.Empty(epubContentCollectionRef.Local); | |
| Assert.NotNull(epubContentCollectionRef.Remote); | |
| Assert.Empty(epubContentCollectionRef.Remote); | |
| } | |
| [] | |
| public void ConstructorWithNullLocalParameterTest() | |
| { | |
| EpubContentCollectionRef<EpubLocalTextContentFileRef, EpubRemoteTextContentFileRef> epubContentCollectionRef = new(null, Remote); | |
| Assert.NotNull(epubContentCollectionRef.Local); | |
| Assert.Empty(epubContentCollectionRef.Local); | |
| CompareRemoteTextRefReadOnlyCollections(Remote, epubContentCollectionRef.Remote); | |
| } | |
| [] | |
| public void ConstructorWithNullRemoteParameterTest() | |
| { | |
| EpubContentCollectionRef<EpubLocalTextContentFileRef, EpubRemoteTextContentFileRef> epubContentCollectionRef = new(Local, null); | |
| CompareLocalTextRefReadOnlyCollections(Local, epubContentCollectionRef.Local); | |
| Assert.NotNull(epubContentCollectionRef.Remote); | |
| Assert.Empty(epubContentCollectionRef.Remote); | |
| } | |
| [] | |
| public void ConstructorWithLocalDuplicateKeysTest() | |
| { | |
| string duplicateKey = CHAPTER1_FILE_NAME; | |
| ReadOnlyCollection<EpubLocalTextContentFileRef> localWithDuplicateKeys = new | |
| ( | |
| new List<EpubLocalTextContentFileRef>() | |
| { | |
| new EpubLocalTextContentFileRef | |
| ( | |
| metadata: new EpubContentFileRefMetadata | |
| ( | |
| key: duplicateKey, | |
| contentType: HTML_CONTENT_TYPE, | |
| contentMimeType: HTML_CONTENT_MIME_TYPE | |
| ), | |
| filePath: CHAPTER1_FILE_PATH, | |
| epubContentLoader: ContentLoader | |
| ), | |
| new EpubLocalTextContentFileRef | |
| ( | |
| metadata: new EpubContentFileRefMetadata | |
| ( | |
| key: duplicateKey, | |
| contentType: HTML_CONTENT_TYPE, | |
| contentMimeType: HTML_CONTENT_MIME_TYPE | |
| ), | |
| filePath: CHAPTER2_FILE_PATH, | |
| epubContentLoader: ContentLoader | |
| ) | |
| } | |
| ); | |
| Assert.Throws<EpubPackageException>(() => new EpubContentCollectionRef<EpubLocalTextContentFileRef, EpubRemoteTextContentFileRef>(localWithDuplicateKeys, Remote)); | |
| } | |
| [] | |
| public void ConstructorWithLocalDuplicateFilePathsTest() | |
| { | |
| string duplicateFilePath = CHAPTER1_FILE_PATH; | |
| ReadOnlyCollection<EpubLocalTextContentFileRef> localWithDuplicateFilePaths = new | |
| ( | |
| new List<EpubLocalTextContentFileRef>() | |
| { | |
| new EpubLocalTextContentFileRef | |
| ( | |
| metadata: new EpubContentFileRefMetadata | |
| ( | |
| key: CHAPTER1_FILE_NAME, | |
| contentType: HTML_CONTENT_TYPE, | |
| contentMimeType: HTML_CONTENT_MIME_TYPE | |
| ), | |
| filePath: duplicateFilePath, | |
| epubContentLoader: ContentLoader | |
| ), | |
| new EpubLocalTextContentFileRef | |
| ( | |
| metadata: new EpubContentFileRefMetadata | |
| ( | |
| key: CHAPTER2_FILE_NAME, | |
| contentType: HTML_CONTENT_TYPE, | |
| contentMimeType: HTML_CONTENT_MIME_TYPE | |
| ), | |
| filePath: duplicateFilePath, | |
| epubContentLoader: ContentLoader | |
| ) | |
| } | |
| ); | |
| Assert.Throws<EpubPackageException>(() => new EpubContentCollectionRef<EpubLocalTextContentFileRef, EpubRemoteTextContentFileRef>(localWithDuplicateFilePaths, Remote)); | |
| } | |
| [] | |
| public void ConstructorWithRemoteDuplicateUrlsTest() | |
| { | |
| string duplicateKey = REMOTE_HTML_CONTENT_FILE_HREF; | |
| ReadOnlyCollection<EpubRemoteTextContentFileRef> remoteWithDuplicateKeys = new | |
| ( | |
| new List<EpubRemoteTextContentFileRef>() | |
| { | |
| new EpubRemoteTextContentFileRef | |
| ( | |
| metadata: new EpubContentFileRefMetadata | |
| ( | |
| key: duplicateKey, | |
| contentType: HTML_CONTENT_TYPE, | |
| contentMimeType: HTML_CONTENT_MIME_TYPE | |
| ), | |
| epubContentLoader: ContentLoader | |
| ), | |
| new EpubRemoteTextContentFileRef | |
| ( | |
| metadata: new EpubContentFileRefMetadata | |
| ( | |
| key: duplicateKey, | |
| contentType: HTML_CONTENT_TYPE, | |
| contentMimeType: HTML_CONTENT_MIME_TYPE | |
| ), | |
| epubContentLoader: ContentLoader | |
| ) | |
| } | |
| ); | |
| Assert.Throws<EpubPackageException>(() => new EpubContentCollectionRef<EpubLocalTextContentFileRef, EpubRemoteTextContentFileRef>(Local, remoteWithDuplicateKeys)); | |
| } | |
| [] | |
| public void ContainsLocalFileWithKeyWithNonNullKeyTest() | |
| { | |
| string existingKey = CHAPTER1_FILE_NAME; | |
| string nonExistingKey = CHAPTER2_FILE_NAME; | |
| ReadOnlyCollection<EpubLocalTextContentFileRef> local = new | |
| ( | |
| new List<EpubLocalTextContentFileRef>() | |
| { | |
| new EpubLocalTextContentFileRef | |
| ( | |
| metadata: new EpubContentFileRefMetadata | |
| ( | |
| key: existingKey, | |
| contentType: HTML_CONTENT_TYPE, | |
| contentMimeType: HTML_CONTENT_MIME_TYPE | |
| ), | |
| filePath: CHAPTER1_FILE_PATH, | |
| epubContentLoader: ContentLoader | |
| ) | |
| } | |
| ); | |
| EpubContentCollectionRef<EpubLocalTextContentFileRef, EpubRemoteTextContentFileRef> epubContentCollectionRef = new(local, Remote); | |
| Assert.True(epubContentCollectionRef.ContainsLocalFileRefWithKey(existingKey)); | |
| Assert.False(epubContentCollectionRef.ContainsLocalFileRefWithKey(nonExistingKey)); | |
| } | |
| [] | |
| public void ContainsLocalFileWithKeyWithNullKeyTest() | |
| { | |
| EpubContentCollectionRef<EpubLocalTextContentFileRef, EpubRemoteTextContentFileRef> epubContentCollectionRef = new(Local, Remote); | |
| Assert.Throws<ArgumentNullException>(() => epubContentCollectionRef.ContainsLocalFileRefWithKey(null!)); | |
| } | |
| [] | |
| public void GetLocalFileByKeyWithExistingKeyTest() | |
| { | |
| string existingKey = CHAPTER1_FILE_NAME; | |
| EpubLocalTextContentFileRef expectedFileRef = new | |
| ( | |
| metadata: new EpubContentFileRefMetadata | |
| ( | |
| key: existingKey, | |
| contentType: HTML_CONTENT_TYPE, | |
| contentMimeType: HTML_CONTENT_MIME_TYPE | |
| ), | |
| filePath: CHAPTER1_FILE_PATH, | |
| epubContentLoader: ContentLoader | |
| ); | |
| ReadOnlyCollection<EpubLocalTextContentFileRef> local = new | |
| ( | |
| new List<EpubLocalTextContentFileRef>() | |
| { | |
| expectedFileRef | |
| } | |
| ); | |
| EpubContentCollectionRef<EpubLocalTextContentFileRef, EpubRemoteTextContentFileRef> epubContentCollectionRef = new(local, Remote); | |
| EpubLocalTextContentFileRef actualFileRef = epubContentCollectionRef.GetLocalFileRefByKey(existingKey); | |
| EpubContentRefComparer.CompareEpubLocalContentFileRefs(expectedFileRef, actualFileRef); | |
| } | |
| [] | |
| public void GetLocalFileByKeyWithNonExistingKeyTest() | |
| { | |
| string nonExistingKey = CHAPTER2_FILE_NAME; | |
| ReadOnlyCollection<EpubLocalTextContentFileRef> local = new | |
| ( | |
| new List<EpubLocalTextContentFileRef>() | |
| { | |
| new EpubLocalTextContentFileRef | |
| ( | |
| metadata: new EpubContentFileRefMetadata | |
| ( | |
| key: CHAPTER1_FILE_NAME, | |
| contentType: HTML_CONTENT_TYPE, | |
| contentMimeType: HTML_CONTENT_MIME_TYPE | |
| ), | |
| filePath: CHAPTER1_FILE_PATH, | |
| epubContentLoader: ContentLoader | |
| ) | |
| } | |
| ); | |
| EpubContentCollectionRef<EpubLocalTextContentFileRef, EpubRemoteTextContentFileRef> epubContentCollectionRef = new(local, Remote); | |
| Assert.Throws<EpubContentCollectionRefException>(() => epubContentCollectionRef.GetLocalFileRefByKey(nonExistingKey)); | |
| } | |
| [] | |
| public void GetLocalFileByKeyWithNullKeyTest() | |
| { | |
| EpubContentCollectionRef<EpubLocalTextContentFileRef, EpubRemoteTextContentFileRef> epubContentCollectionRef = new(Local, Remote); | |
| Assert.Throws<ArgumentNullException>(() => epubContentCollectionRef.GetLocalFileRefByKey(null!)); | |
| } | |
| [] | |
| public void TryGetLocalFileByKeyWithNonNullKeyTest() | |
| { | |
| string existingKey = CHAPTER1_FILE_NAME; | |
| string nonExistingKey = CHAPTER2_FILE_NAME; | |
| EpubLocalTextContentFileRef expectedFileRef = new | |
| ( | |
| metadata: new EpubContentFileRefMetadata | |
| ( | |
| key: existingKey, | |
| contentType: HTML_CONTENT_TYPE, | |
| contentMimeType: HTML_CONTENT_MIME_TYPE | |
| ), | |
| filePath: CHAPTER1_FILE_PATH, | |
| epubContentLoader: ContentLoader | |
| ); | |
| ReadOnlyCollection<EpubLocalTextContentFileRef> local = new | |
| ( | |
| new List<EpubLocalTextContentFileRef>() | |
| { | |
| expectedFileRef | |
| } | |
| ); | |
| EpubContentCollectionRef<EpubLocalTextContentFileRef, EpubRemoteTextContentFileRef> epubContentCollectionRef = new(local, Remote); | |
| Assert.True(epubContentCollectionRef.TryGetLocalFileRefByKey(existingKey, out EpubLocalTextContentFileRef actualFileRefForExistingKey)); | |
| EpubContentRefComparer.CompareEpubLocalContentFileRefs(expectedFileRef, actualFileRefForExistingKey); | |
| Assert.False(epubContentCollectionRef.TryGetLocalFileRefByKey(nonExistingKey, out EpubLocalTextContentFileRef actualFileRefForNonExistingKey)); | |
| Assert.Null(actualFileRefForNonExistingKey); | |
| } | |
| [] | |
| public void TryGetLocalFileByKeyWithNullKeyTest() | |
| { | |
| EpubContentCollectionRef<EpubLocalTextContentFileRef, EpubRemoteTextContentFileRef> epubContentCollectionRef = new(Local, Remote); | |
| Assert.Throws<ArgumentNullException>(() => epubContentCollectionRef.TryGetLocalFileRefByKey(null!, out _)); | |
| } | |
| [] | |
| public void ContainsLocalFileWithFilePathWithNonNullFilePathTest() | |
| { | |
| string existingFilePath = CHAPTER1_FILE_PATH; | |
| string nonExistingFilePath = CHAPTER2_FILE_PATH; | |
| ReadOnlyCollection<EpubLocalTextContentFileRef> local = new | |
| ( | |
| new List<EpubLocalTextContentFileRef>() | |
| { | |
| new EpubLocalTextContentFileRef | |
| ( | |
| metadata: new EpubContentFileRefMetadata | |
| ( | |
| key: CHAPTER1_FILE_NAME, | |
| contentType: HTML_CONTENT_TYPE, | |
| contentMimeType: HTML_CONTENT_MIME_TYPE | |
| ), | |
| filePath: existingFilePath, | |
| epubContentLoader: ContentLoader | |
| ) | |
| } | |
| ); | |
| EpubContentCollectionRef<EpubLocalTextContentFileRef, EpubRemoteTextContentFileRef> epubContentCollectionRef = new(local, Remote); | |
| Assert.True(epubContentCollectionRef.ContainsLocalFileRefWithFilePath(existingFilePath)); | |
| Assert.False(epubContentCollectionRef.ContainsLocalFileRefWithFilePath(nonExistingFilePath)); | |
| } | |
| [] | |
| public void ContainsLocalFileWithFilePathWithNullFilePathTest() | |
| { | |
| EpubContentCollectionRef<EpubLocalTextContentFileRef, EpubRemoteTextContentFileRef> epubContentCollectionRef = new(Local, Remote); | |
| Assert.Throws<ArgumentNullException>(() => epubContentCollectionRef.ContainsLocalFileRefWithFilePath(null!)); | |
| } | |
| [] | |
| public void GetLocalFileByFilePathWithExistingFilePathTest() | |
| { | |
| string existingFilePath = CHAPTER1_FILE_PATH; | |
| EpubLocalTextContentFileRef expectedFileRef = new | |
| ( | |
| metadata: new EpubContentFileRefMetadata | |
| ( | |
| key: CHAPTER1_FILE_NAME, | |
| contentType: HTML_CONTENT_TYPE, | |
| contentMimeType: HTML_CONTENT_MIME_TYPE | |
| ), | |
| filePath: existingFilePath, | |
| epubContentLoader: ContentLoader | |
| ); | |
| ReadOnlyCollection<EpubLocalTextContentFileRef> local = new | |
| ( | |
| new List<EpubLocalTextContentFileRef>() | |
| { | |
| expectedFileRef | |
| } | |
| ); | |
| EpubContentCollectionRef<EpubLocalTextContentFileRef, EpubRemoteTextContentFileRef> epubContentCollectionRef = new(local, Remote); | |
| EpubLocalTextContentFileRef actualFileRef = epubContentCollectionRef.GetLocalFileRefByFilePath(existingFilePath); | |
| EpubContentRefComparer.CompareEpubLocalContentFileRefs(expectedFileRef, actualFileRef); | |
| } | |
| [] | |
| public void GetLocalFileByFilePathWithNonExistingFilePathTest() | |
| { | |
| string nonExistingFilePath = CHAPTER2_FILE_PATH; | |
| ReadOnlyCollection<EpubLocalTextContentFileRef> local = new | |
| ( | |
| new List<EpubLocalTextContentFileRef>() | |
| { | |
| new EpubLocalTextContentFileRef | |
| ( | |
| metadata: new EpubContentFileRefMetadata | |
| ( | |
| key: CHAPTER1_FILE_NAME, | |
| contentType: HTML_CONTENT_TYPE, | |
| contentMimeType: HTML_CONTENT_MIME_TYPE | |
| ), | |
| filePath: CHAPTER1_FILE_PATH, | |
| epubContentLoader: ContentLoader | |
| ) | |
| } | |
| ); | |
| EpubContentCollectionRef<EpubLocalTextContentFileRef, EpubRemoteTextContentFileRef> epubContentCollectionRef = new(local, Remote); | |
| Assert.Throws<EpubContentCollectionRefException>(() => epubContentCollectionRef.GetLocalFileRefByFilePath(nonExistingFilePath)); | |
| } | |
| [] | |
| public void GetLocalFileByFilePathWithNullFilePathTest() | |
| { | |
| EpubContentCollectionRef<EpubLocalTextContentFileRef, EpubRemoteTextContentFileRef> epubContentCollectionRef = new(Local, Remote); | |
| Assert.Throws<ArgumentNullException>(() => epubContentCollectionRef.GetLocalFileRefByFilePath(null!)); | |
| } | |
| [] | |
| public void TryGetLocalFileByFilePathWithNonNullFilePathTest() | |
| { | |
| string existingFilePath = CHAPTER1_FILE_PATH; | |
| string nonExistingFilePath = CHAPTER2_FILE_PATH; | |
| EpubLocalTextContentFileRef expectedFileRef = new | |
| ( | |
| metadata: new EpubContentFileRefMetadata | |
| ( | |
| key: CHAPTER1_FILE_NAME, | |
| contentType: HTML_CONTENT_TYPE, | |
| contentMimeType: HTML_CONTENT_MIME_TYPE | |
| ), | |
| filePath: existingFilePath, | |
| epubContentLoader: ContentLoader | |
| ); | |
| ReadOnlyCollection<EpubLocalTextContentFileRef> local = new | |
| ( | |
| new List<EpubLocalTextContentFileRef>() | |
| { | |
| expectedFileRef | |
| } | |
| ); | |
| EpubContentCollectionRef<EpubLocalTextContentFileRef, EpubRemoteTextContentFileRef> epubContentCollectionRef = new(local, Remote); | |
| Assert.True(epubContentCollectionRef.TryGetLocalFileRefByFilePath(existingFilePath, out EpubLocalTextContentFileRef actualFileRefForExistingFilePath)); | |
| EpubContentRefComparer.CompareEpubLocalContentFileRefs(expectedFileRef, actualFileRefForExistingFilePath); | |
| Assert.False(epubContentCollectionRef.TryGetLocalFileRefByFilePath(nonExistingFilePath, out EpubLocalTextContentFileRef actualFileRefForNonExistingFilePath)); | |
| Assert.Null(actualFileRefForNonExistingFilePath); | |
| } | |
| [] | |
| public void TryGetLocalFileByFilePathWithNullFilePathTest() | |
| { | |
| EpubContentCollectionRef<EpubLocalTextContentFileRef, EpubRemoteTextContentFileRef> epubContentCollectionRef = new(Local, Remote); | |
| Assert.Throws<ArgumentNullException>(() => epubContentCollectionRef.TryGetLocalFileRefByFilePath(null!, out _)); | |
| } | |
| [] | |
| public void ContainsRemoteFileWithUrlWithNonNullUrlTest() | |
| { | |
| string existingUrl = REMOTE_HTML_CONTENT_FILE_HREF; | |
| string nonExistingUrl = REMOTE_CSS_CONTENT_FILE_HREF; | |
| ReadOnlyCollection<EpubRemoteTextContentFileRef> remote = new | |
| ( | |
| new List<EpubRemoteTextContentFileRef>() | |
| { | |
| new EpubRemoteTextContentFileRef | |
| ( | |
| metadata: new EpubContentFileRefMetadata | |
| ( | |
| key: existingUrl, | |
| contentType: HTML_CONTENT_TYPE, | |
| contentMimeType: HTML_CONTENT_MIME_TYPE | |
| ), | |
| epubContentLoader: ContentLoader | |
| ) | |
| } | |
| ); | |
| EpubContentCollectionRef<EpubLocalTextContentFileRef, EpubRemoteTextContentFileRef> epubContentCollectionRef = new(Local, remote); | |
| Assert.True(epubContentCollectionRef.ContainsRemoteFileRefWithUrl(existingUrl)); | |
| Assert.False(epubContentCollectionRef.ContainsRemoteFileRefWithUrl(nonExistingUrl)); | |
| } | |
| [] | |
| public void ContainsRemoteFileWithUrlWithNullUrlTest() | |
| { | |
| EpubContentCollectionRef<EpubLocalTextContentFileRef, EpubRemoteTextContentFileRef> epubContentCollectionRef = new(Local, Remote); | |
| Assert.Throws<ArgumentNullException>(() => epubContentCollectionRef.ContainsRemoteFileRefWithUrl(null!)); | |
| } | |
| [] | |
| public void GetRemoteFileByUrlWithExistingUrlTest() | |
| { | |
| string existingUrl = REMOTE_HTML_CONTENT_FILE_HREF; | |
| EpubRemoteTextContentFileRef expectedFileRef = new | |
| ( | |
| metadata: new EpubContentFileRefMetadata | |
| ( | |
| key: existingUrl, | |
| contentType: HTML_CONTENT_TYPE, | |
| contentMimeType: HTML_CONTENT_MIME_TYPE | |
| ), | |
| epubContentLoader: ContentLoader | |
| ); | |
| ReadOnlyCollection<EpubRemoteTextContentFileRef> remote = new | |
| ( | |
| new List<EpubRemoteTextContentFileRef>() | |
| { | |
| expectedFileRef | |
| } | |
| ); | |
| EpubContentCollectionRef<EpubLocalTextContentFileRef, EpubRemoteTextContentFileRef> epubContentCollectionRef = new(Local, remote); | |
| EpubRemoteTextContentFileRef actualFileRef = epubContentCollectionRef.GetRemoteFileRefByUrl(existingUrl); | |
| EpubContentRefComparer.CompareEpubRemoteContentFileRefs(expectedFileRef, actualFileRef); | |
| } | |
| [] | |
| public void GetRemoteFileByUrlWithNonExistingUrlTest() | |
| { | |
| string nonExistingUrl = REMOTE_CSS_CONTENT_FILE_HREF; | |
| ReadOnlyCollection<EpubRemoteTextContentFileRef> remote = new | |
| ( | |
| new List<EpubRemoteTextContentFileRef>() | |
| { | |
| new EpubRemoteTextContentFileRef | |
| ( | |
| metadata: new EpubContentFileRefMetadata | |
| ( | |
| key: REMOTE_HTML_CONTENT_FILE_HREF, | |
| contentType: HTML_CONTENT_TYPE, | |
| contentMimeType: HTML_CONTENT_MIME_TYPE | |
| ), | |
| epubContentLoader: ContentLoader | |
| ) | |
| } | |
| ); | |
| EpubContentCollectionRef<EpubLocalTextContentFileRef, EpubRemoteTextContentFileRef> epubContentCollectionRef = new(Local, remote); | |
| Assert.Throws<EpubContentCollectionRefException>(() => epubContentCollectionRef.GetRemoteFileRefByUrl(nonExistingUrl)); | |
| } | |
| [] | |
| public void GetRemoteFileByUrlWithNullUrlTest() | |
| { | |
| EpubContentCollectionRef<EpubLocalTextContentFileRef, EpubRemoteTextContentFileRef> epubContentCollectionRef = new(Local, Remote); | |
| Assert.Throws<ArgumentNullException>(() => epubContentCollectionRef.GetRemoteFileRefByUrl(null!)); | |
| } | |
| [] | |
| public void TryGetRemoteFileByUrlWithNonNullUrlTest() | |
| { | |
| string existingUrl = REMOTE_HTML_CONTENT_FILE_HREF; | |
| string nonExistingUrl = REMOTE_CSS_CONTENT_FILE_HREF; | |
| EpubRemoteTextContentFileRef expectedFileRef = new | |
| ( | |
| metadata: new EpubContentFileRefMetadata | |
| ( | |
| key: existingUrl, | |
| contentType: HTML_CONTENT_TYPE, | |
| contentMimeType: HTML_CONTENT_MIME_TYPE | |
| ), | |
| epubContentLoader: ContentLoader | |
| ); | |
| ReadOnlyCollection<EpubRemoteTextContentFileRef> remote = new | |
| ( | |
| new List<EpubRemoteTextContentFileRef>() | |
| { | |
| expectedFileRef | |
| } | |
| ); | |
| EpubContentCollectionRef<EpubLocalTextContentFileRef, EpubRemoteTextContentFileRef> epubContentCollectionRef = new(Local, remote); | |
| Assert.True(epubContentCollectionRef.TryGetRemoteFileRefByUrl(existingUrl, out EpubRemoteTextContentFileRef actualFileRefForExistingUrl)); | |
| EpubContentRefComparer.CompareEpubRemoteContentFileRefs(expectedFileRef, actualFileRefForExistingUrl); | |
| Assert.False(epubContentCollectionRef.TryGetRemoteFileRefByUrl(nonExistingUrl, out EpubRemoteTextContentFileRef actualFileRefForNonExistingUrl)); | |
| Assert.Null(actualFileRefForNonExistingUrl); | |
| } | |
| [] | |
| public void TryGetRemoteFileByUrlWithNullUrlTest() | |
| { | |
| EpubContentCollectionRef<EpubLocalTextContentFileRef, EpubRemoteTextContentFileRef> epubContentCollectionRef = new(Local, Remote); | |
| Assert.Throws<ArgumentNullException>(() => epubContentCollectionRef.TryGetRemoteFileRefByUrl(null!, out _)); | |
| } | |
| private static void CompareLocalTextRefReadOnlyCollections(ReadOnlyCollection<EpubLocalTextContentFileRef> expected, ReadOnlyCollection<EpubLocalTextContentFileRef> actual) | |
| { | |
| CollectionComparer.CompareCollections(expected, actual, EpubContentRefComparer.CompareEpubLocalContentFileRefs); | |
| } | |
| private static void CompareRemoteTextRefReadOnlyCollections(ReadOnlyCollection<EpubRemoteTextContentFileRef> expected, ReadOnlyCollection<EpubRemoteTextContentFileRef> actual) | |
| { | |
| CollectionComparer.CompareCollections(expected, actual, EpubContentRefComparer.CompareEpubRemoteContentFileRefs); | |
| } | |
| } | |
| } | |