using FluentAssertions; using Microsoft.Extensions.Logging.Abstractions; using StellaOps.Replay.Loaders; using StellaOps.TestKit; using Xunit; namespace StellaOps.Replay.Tests; public sealed class FeedSnapshotLoaderTests { [Trait("Category", TestCategories.Unit)] [Fact] public async Task LoadByDigestAsync_InvalidDigest_ThrowsFormatException() { var loader = new FeedSnapshotLoader(new FeedStorageStub(null), NullLogger.Instance); var digest = SnapshotTestData.CreateInvalidDigest('a'); var action = () => loader.LoadByDigestAsync(digest); await action.Should().ThrowAsync(); } [Trait("Category", TestCategories.Unit)] [Fact] public async Task LoadByDigestAsync_ShortDigest_ThrowsFormatException() { var loader = new FeedSnapshotLoader(new FeedStorageStub(null), NullLogger.Instance); var digest = new string('a', 63); var action = () => loader.LoadByDigestAsync(digest); await action.Should().ThrowAsync(); } [Trait("Category", TestCategories.Unit)] [Fact] public async Task LoadByDigestAsync_DigestMismatch_ThrowsException() { var snapshot = SnapshotTestData.CreateFeedSnapshot(SnapshotTestData.CreateValidDigest('b')); var actualDigest = SnapshotTestData.ComputeDigest(snapshot); var expectedDigest = SnapshotTestData.CreateDifferentDigest(actualDigest); var loader = new FeedSnapshotLoader(new FeedStorageStub(snapshot), NullLogger.Instance); var action = () => loader.LoadByDigestAsync(expectedDigest); await action.Should().ThrowAsync(); } }