using StellaOps.Scanner.Core.Utility;
using Xunit;

namespace StellaOps.Scanner.Core.Tests.Utility;

public sealed class ScannerTimestampsTests
{
    [Fact]
    public void Normalize_TrimsToMicroseconds()
    {
        var value = new DateTimeOffset(2025, 10, 18, 14, 30, 15, TimeSpan.Zero).AddTicks(7);
        var normalized = ScannerTimestamps.Normalize(value);

        var expectedTicks = value.UtcTicks - (value.UtcTicks % 10);
        Assert.Equal(expectedTicks, normalized.UtcTicks);
    }

    [Fact]
    public void ToIso8601_ProducesUtcString()
    {
        var value = new DateTimeOffset(2025, 10, 18, 14, 30, 15, TimeSpan.FromHours(-4));
        var iso = ScannerTimestamps.ToIso8601(value);

        Assert.Equal("2025-10-18T18:30:15.000000Z", iso);
    }
}
