namespace ScadaLink.DeploymentManager.Tests;

/// <summary>
/// WP-8: Tests for deployed vs template-derived state comparison.
/// </summary>
public class DeploymentComparisonTests
{
    [Fact]
    public void DeploymentComparisonResult_MatchingHashes_NotStale()
    {
        var result = new DeploymentComparisonResult(
            1, "sha256:abc", "sha256:abc", false, DateTimeOffset.UtcNow);

        Assert.False(result.IsStale);
        Assert.Equal("sha256:abc", result.DeployedRevisionHash);
        Assert.Equal("sha256:abc", result.CurrentRevisionHash);
    }

    [Fact]
    public void DeploymentComparisonResult_DifferentHashes_IsStale()
    {
        var result = new DeploymentComparisonResult(
            1, "sha256:old", "sha256:new", true, DateTimeOffset.UtcNow);

        Assert.True(result.IsStale);
        Assert.NotEqual(result.DeployedRevisionHash, result.CurrentRevisionHash);
    }

    [Fact]
    public void DeploymentComparisonResult_ContainsDeployedTimestamp()
    {
        var deployedAt = new DateTimeOffset(2026, 3, 16, 12, 0, 0, TimeSpan.Zero);
        var result = new DeploymentComparisonResult(1, "h1", "h2", true, deployedAt);

        Assert.Equal(deployedAt, result.DeployedAt);
    }
}
