Some checks are pending
CI / Build og unit tests (push) Waiting to run
CI / Integration (mcr.microsoft.com/mssql/server:2017-latest) (push) Blocked by required conditions
CI / Integration (mcr.microsoft.com/mssql/server:2019-latest) (push) Blocked by required conditions
CI / Integration (mcr.microsoft.com/mssql/server:2022-latest) (push) Blocked by required conditions
CI / Integration (mcr.microsoft.com/mssql/server:2025-latest) (push) Blocked by required conditions
A PDF report for management and auditors (PDFsharp/MigraDoc, MIT, with the Inter font embedded): key figures, a plain-language summary, compliance controls backed by rules (met, not met, not measured), instances and the critical and high findings. Downloadable from the web UI (/rapporter) and mailed monthly by the agent with the PDF attached, once per month, across daylight saving changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E3EExwndy8Z22EK2Qpt6BK
35 lines
1.6 KiB
C#
35 lines
1.6 KiB
C#
using SQLInsight.Agent.Reports;
|
|
|
|
namespace SQLInsight.Agent.Tests;
|
|
|
|
public class MonthlyReportTests
|
|
{
|
|
private static readonly TimeZoneInfo Copenhagen = TimeZoneInfo.FindSystemTimeZoneById("Europe/Copenhagen");
|
|
|
|
[Fact]
|
|
public void Previous_month_is_due_after_the_send_hour_across_a_daylight_saving_change()
|
|
{
|
|
var period = MonthlyReportService.DuePeriod(new DateTimeOffset(2026, 11, 1, 7, 30, 0, TimeSpan.FromHours(1)), Copenhagen, day: 1, hour: 7, lastSent: "2026-10");
|
|
|
|
Assert.NotNull(period);
|
|
Assert.Equal("2026-11", period.Key);
|
|
Assert.Equal(new DateTimeOffset(2026, 10, 1, 0, 0, 0, TimeSpan.FromHours(2)), period.From);
|
|
Assert.Equal(new DateTimeOffset(2026, 11, 1, 0, 0, 0, TimeSpan.FromHours(1)), period.To);
|
|
}
|
|
|
|
[Fact]
|
|
public void Nothing_is_due_before_the_send_time_or_after_it_was_sent()
|
|
{
|
|
Assert.Null(MonthlyReportService.DuePeriod(new DateTimeOffset(2026, 11, 1, 6, 59, 0, TimeSpan.FromHours(1)), Copenhagen, 1, 7, "2026-10"));
|
|
Assert.Null(MonthlyReportService.DuePeriod(new DateTimeOffset(2026, 11, 3, 6, 0, 0, TimeSpan.FromHours(1)), Copenhagen, 5, 7, "2026-10"));
|
|
Assert.Null(MonthlyReportService.DuePeriod(new DateTimeOffset(2026, 11, 20, 12, 0, 0, TimeSpan.FromHours(1)), Copenhagen, 1, 7, "2026-11"));
|
|
}
|
|
|
|
[Fact]
|
|
public void A_report_missed_while_the_agent_was_down_is_sent_later_in_the_month()
|
|
{
|
|
var period = MonthlyReportService.DuePeriod(new DateTimeOffset(2027, 1, 14, 9, 0, 0, TimeSpan.FromHours(1)), Copenhagen, 1, 7, lastSent: null);
|
|
|
|
Assert.Equal(new DateTimeOffset(2026, 12, 1, 0, 0, 0, TimeSpan.FromHours(1)), period!.From);
|
|
}
|
|
}
|