part #2
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
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<FeedSnapshotLoader>.Instance);
|
||||
var digest = SnapshotTestData.CreateInvalidDigest('a');
|
||||
|
||||
var action = () => loader.LoadByDigestAsync(digest);
|
||||
|
||||
await action.Should().ThrowAsync<FormatException>();
|
||||
}
|
||||
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task LoadByDigestAsync_ShortDigest_ThrowsFormatException()
|
||||
{
|
||||
var loader = new FeedSnapshotLoader(new FeedStorageStub(null), NullLogger<FeedSnapshotLoader>.Instance);
|
||||
var digest = new string('a', 63);
|
||||
|
||||
var action = () => loader.LoadByDigestAsync(digest);
|
||||
|
||||
await action.Should().ThrowAsync<FormatException>();
|
||||
}
|
||||
|
||||
[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<FeedSnapshotLoader>.Instance);
|
||||
|
||||
var action = () => loader.LoadByDigestAsync(expectedDigest);
|
||||
|
||||
await action.Should().ThrowAsync<DigestMismatchException>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user