Refactor code structure for improved readability and maintainability; optimize performance in key functions.
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
namespace StellaOps.AuditPack.Tests;
|
||||
|
||||
using StellaOps.AuditPack.Models;
|
||||
using StellaOps.AuditPack.Services;
|
||||
|
||||
[Trait("Category", "Unit")]
|
||||
public class AuditPackReplayerTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task Replay_ValidPack_ProducesResult()
|
||||
{
|
||||
// Arrange
|
||||
var pack = CreateTestPack();
|
||||
var importResult = new ImportResult
|
||||
{
|
||||
Success = true,
|
||||
Pack = pack,
|
||||
ExtractDirectory = Path.GetTempPath()
|
||||
};
|
||||
|
||||
var replayer = new AuditPackReplayer();
|
||||
|
||||
// Act
|
||||
var result = await replayer.ReplayAsync(importResult);
|
||||
|
||||
// Assert
|
||||
result.Success.Should().BeTrue();
|
||||
result.OriginalVerdictDigest.Should().NotBeNullOrEmpty();
|
||||
result.ReplayedVerdictDigest.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Replay_InvalidImport_Fails()
|
||||
{
|
||||
// Arrange
|
||||
var importResult = new ImportResult { Success = false };
|
||||
var replayer = new AuditPackReplayer();
|
||||
|
||||
// Act
|
||||
var result = await replayer.ReplayAsync(importResult);
|
||||
|
||||
// Assert
|
||||
result.Success.Should().BeFalse();
|
||||
result.Error.Should().Contain("Invalid import");
|
||||
}
|
||||
|
||||
private static AuditPack CreateTestPack()
|
||||
{
|
||||
return new AuditPack
|
||||
{
|
||||
PackId = "test-pack",
|
||||
Name = "Test Pack",
|
||||
CreatedAt = DateTimeOffset.UtcNow,
|
||||
RunManifest = new RunManifest("scan-1", DateTimeOffset.UtcNow),
|
||||
EvidenceIndex = new EvidenceIndex([]),
|
||||
Verdict = new Verdict("verdict-1", "pass"),
|
||||
OfflineBundle = new BundleManifest("bundle-1", "1.0"),
|
||||
Contents = new PackContents()
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user