From f8645802077f8dd9c5e60995cad0602188ec3cde Mon Sep 17 00:00:00 2001 From: Antigravity Date: Mon, 11 May 2026 18:09:07 +0000 Subject: [PATCH] test: add unit tests for EpubMetadataExtractor robustness --- .../Services/EpubMetadataExtractorTests.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/NexusReader.Application.Tests/Services/EpubMetadataExtractorTests.cs diff --git a/tests/NexusReader.Application.Tests/Services/EpubMetadataExtractorTests.cs b/tests/NexusReader.Application.Tests/Services/EpubMetadataExtractorTests.cs new file mode 100644 index 0000000..6b25ba5 --- /dev/null +++ b/tests/NexusReader.Application.Tests/Services/EpubMetadataExtractorTests.cs @@ -0,0 +1,28 @@ +using NexusReader.Infrastructure.Services; +using Xunit; + +namespace NexusReader.Application.Tests.Services; + +public class EpubMetadataExtractorTests +{ + private readonly EpubMetadataExtractor _sut; + + public EpubMetadataExtractorTests() + { + _sut = new EpubMetadataExtractor(); + } + + [Fact] + public async Task ExtractMetadataAsync_WithInvalidStream_ReturnsFailure() + { + // Arrange + using var invalidStream = new MemoryStream(new byte[] { 0, 1, 2, 3 }); + + // Act + var result = await _sut.ExtractMetadataAsync(invalidStream); + + // Assert + Assert.True(result.IsFailed); + Assert.Contains("Failed to extract EPUB metadata", result.Errors[0].Message); + } +}