From e1daa0393d052692dc28ee03b6e7b5427ac25ebe Mon Sep 17 00:00:00 2001 From: Rod Christiansen Date: Tue, 13 Oct 2026 01:04:28 -0700 Subject: [PATCH] Show the Services card as an accordion with a one-line summary per entry Each service or scheduled task is a collapsed Expander whose whole header row toggles it (click, Space or Enter). The header shows the friendly name, one summary line (kind, schedule, last result) and a state dot coloured from theme brushes. Expanding it shows the fields ReportMate's Windows System module uses, in its order: Name, Start type, Status, Account, Path and arguments, Triggers, Last run, Last result and Next run, omitting rows that do not apply. Task queries now also read the principal, Exec actions and next run time. Times follow the user's culture: short time for triggers, short date and time for Last run and Next run. --- src/BootstrapMate.App/Views/PrefsPage.xaml | 96 +++++--- src/BootstrapMate.Core/InstallFootprint.cs | 202 ++++++++++++--- .../InstallFootprintTests.cs | 231 +++++++++++++++--- 3 files changed, 421 insertions(+), 108 deletions(-) diff --git a/src/BootstrapMate.App/Views/PrefsPage.xaml b/src/BootstrapMate.App/Views/PrefsPage.xaml index 9c3fac9..a0ba136 100644 --- a/src/BootstrapMate.App/Views/PrefsPage.xaml +++ b/src/BootstrapMate.App/Views/PrefsPage.xaml @@ -268,7 +268,7 @@ - + @@ -291,48 +291,64 @@ + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/BootstrapMate.Core/InstallFootprint.cs b/src/BootstrapMate.Core/InstallFootprint.cs index c2823b3..a01783a 100644 --- a/src/BootstrapMate.Core/InstallFootprint.cs +++ b/src/BootstrapMate.Core/InstallFootprint.cs @@ -10,16 +10,35 @@ public enum FootprintKind { Service, ScheduledTask } /// One entry of the installer's footprint: what it is called and what it is for. public sealed record FootprintItem(string FriendlyName, string Name, FootprintKind Kind, string Description); -/// The live state of one footprint entry, already in plain words for display. +/// One label/value row of an expanded Services entry. +public sealed record FootprintDetail(string Label, string Value); + +/// +/// The live state of one footprint entry, in plain words for display: a one-line summary for the +/// collapsed row and the detail rows (labels as ReportMate's Windows System module uses them). +/// public sealed record FootprintStatus( - string FriendlyName, string Name, string KindText, string Description, - string State, string LastResult, string Trigger); + string FriendlyName, FootprintKind Kind, string State, string Summary, IReadOnlyList Details) +{ + public bool IsRunning => State == "Running"; + public bool IsReady => State == "Ready"; + /// Stopped, Disabled, Not installed or Unknown: the neutral dot. + public bool IsNeutral => !IsRunning && !IsReady; +} + +/// What the Task Scheduler reports for one task. +public sealed record TaskSnapshot( + string Path, bool Enabled, int State, DateTime LastRunTime, int LastTaskResult, DateTime NextRunTime, string Xml); + +/// What the service control manager reports for one service. +public sealed record ServiceSnapshot( + string StartMode, bool DelayedStart, string Status, string? Account, string? PathName, int Win32ExitCode); /// /// The Windows services and scheduled tasks the MSI installs, and a read-only look at their /// current state for the Prefs tab. The list is the installer's own (installer/Product.wxs): -/// it registers one scheduled task and no services. Querying never needs elevation; anything -/// the caller may not read shows as "Unknown". +/// it registers one scheduled task and no services, so only tasks are queried. Querying never +/// needs elevation; a value that exists but cannot be read shows as "Unknown". /// public static class InstallFootprint { @@ -46,8 +65,9 @@ public static class InstallFootprint private static FootprintStatus Query(FootprintItem item) => item.Kind switch { FootprintKind.ScheduledTask => QueryTask(item), - // The installer registers no services, so there is nothing to query here yet. - _ => Row(item, "Unknown", "—", "—"), + // The installer registers no services, so none are queried; a service entry added to + // Items needs a query that fills a ServiceSnapshot for ServiceStatus. + _ => Unreadable(item), }; private static FootprintStatus QueryTask(FootprintItem item) @@ -56,32 +76,102 @@ private static FootprintStatus QueryTask(FootprintItem item) { var type = Type.GetTypeFromProgID("Schedule.Service"); if (type is null) - return Row(item, "Unknown", "—", "—"); + return Unreadable(item); dynamic service = Activator.CreateInstance(type)!; service.Connect(); dynamic task = service.GetFolder("\\").GetTask(item.Name); - int state = task.State; - DateTime lastRun = task.LastRunTime; - int lastResult = task.LastTaskResult; - string xml = task.Xml; - - return Row(item, DescribeTaskState(state), DescribeTaskResult(lastRun, lastResult), DescribeTaskTriggers(xml)); + return TaskStatus(item, new TaskSnapshot( + (string)task.Path, (bool)task.Enabled, (int)task.State, (DateTime)task.LastRunTime, + (int)task.LastTaskResult, (DateTime)task.NextRunTime, (string)task.Xml)); } catch (Exception ex) when (ex.HResult is HResultFileNotFound or HResultPathNotFound) { - return Row(item, "Not installed", "—", "—"); + return NotInstalled(item); } catch (Exception) { // Access denied for a standard user, or the scheduler is unavailable. - return Row(item, "Unknown", "Unknown", "Unknown"); + return Unreadable(item); } } - private static FootprintStatus Row(FootprintItem item, string state, string lastResult, string trigger) => - new(item.FriendlyName, item.Name, DescribeKind(item.Kind), item.Description, state, lastResult, trigger); + // ── Rows ───────────────────────────────────────────────────── + + /// The collapsed summary and detail rows for a task. + public static FootprintStatus TaskStatus(FootprintItem item, TaskSnapshot task) + { + var state = DescribeTaskState(task.State); + var triggers = DescribeTaskTriggers(task.Xml); + var neverRun = task.LastTaskResult == SchedTaskHasNotRun || task.LastRunTime.Year < 2000; + + var summary = Join(DescribeKind(item.Kind), triggers, + neverRun ? "Never run" : $"Last result {FormatResultCode(task.LastTaskResult)}"); + + var details = new List + { + new("Name", task.Path), + new("Start type", task.Enabled ? "Enabled" : "Disabled"), + new("Status", state), + }; + AddIfPresent(details, "Account", DescribeTaskPrincipal(task.Xml)); + AddIfPresent(details, "Path and arguments", DescribeTaskActions(task.Xml)); + details.Add(new("Triggers", triggers)); + details.Add(new("Last run", neverRun ? "Never" : FormatDate(task.LastRunTime))); + details.Add(new("Last result", DescribeTaskResult(task.LastRunTime, task.LastTaskResult))); + details.Add(new("Next run", task.NextRunTime.Year < 2000 ? "Not scheduled" : FormatDate(task.NextRunTime))); + + return new(item.FriendlyName, item.Kind, state, summary, details); + } + + /// The collapsed summary and detail rows for a service. + public static FootprintStatus ServiceStatus(FootprintItem item, ServiceSnapshot service) + { + var startType = DescribeServiceStartType(service.StartMode, service.DelayedStart); + var state = startType == "Disabled" ? "Disabled" : service.Status; + + var details = new List + { + new("Name", item.Name), + new("Start type", startType), + new("Status", state), + }; + AddIfPresent(details, "Account", service.Account); + AddIfPresent(details, "Path and arguments", service.PathName); + details.Add(new("Triggers", DescribeStartType(service.StartMode, service.DelayedStart))); + if (service.Status == "Stopped") + details.Add(new("Last result", DescribeServiceResult(running: false, service.Win32ExitCode))); + + return new(item.FriendlyName, item.Kind, state, + Join(DescribeKind(item.Kind), startType, service.Account), details); + } + + private static FootprintStatus NotInstalled(FootprintItem item) => + new(item.FriendlyName, item.Kind, "Not installed", Join(DescribeKind(item.Kind), "Not installed"), + [new("Name", item.Name), new("Status", "Not installed")]); + + private static FootprintStatus Unreadable(FootprintItem item) + { + var details = new List { new("Name", item.Name) }; + var labels = item.Kind == FootprintKind.ScheduledTask + ? new[] { "Start type", "Status", "Account", "Path and arguments", "Triggers", "Last run", "Last result", "Next run" } + : new[] { "Start type", "Status", "Account", "Path and arguments", "Triggers" }; + details.AddRange(labels.Select(l => new FootprintDetail(l, "Unknown"))); + return new(item.FriendlyName, item.Kind, "Unknown", DescribeKind(item.Kind), details); + } + + private static void AddIfPresent(List details, string label, string? value) + { + if (!string.IsNullOrWhiteSpace(value)) + details.Add(new(label, value)); + } + + private static string Join(params string?[] parts) => + string.Join(" · ", parts.Where(p => !string.IsNullOrWhiteSpace(p))); + + // Times follow the user's culture: "g" (short date and time) here, "t" for trigger times. + private static string FormatDate(DateTime value) => value.ToString("g", CultureInfo.CurrentCulture); // ── Plain-words formatting ─────────────────────────────────── @@ -98,39 +188,91 @@ public static string DescribeKind(FootprintKind kind) => _ => "Unknown", }; + /// A result code as the summary shows it: 0, or the HRESULT in hex. + public static string FormatResultCode(int code) => code == 0 ? "0" : $"0x{code:X8}"; + /// - /// Last run time and result in words: "Never run", or "Succeeded" / "Failed (0x…)" with the - /// run time. The scheduler reports a task that has never run with a zero date or 0x41303. + /// The last result in words: "Succeeded", "Failed (0x…)" or "Never run". The scheduler + /// reports a task that has never run with a zero date or 0x41303. /// public static string DescribeTaskResult(DateTime lastRun, int lastResult) { if (lastResult == SchedTaskHasNotRun || lastRun.Year < 2000) return "Never run"; - var outcome = lastResult switch + return lastResult switch { 0 => "Succeeded", SchedTaskRunning => "Running", _ => $"Failed (0x{lastResult:X8})", }; - return $"{outcome} — {lastRun.ToString("MMM d, yyyy h:mm tt", CultureInfo.InvariantCulture)}"; } - /// A service start type in words ("Starts automatically at boot", …). - public static string DescribeStartType(string startType, bool delayed) => startType switch + /// A service start mode as a start type: Automatic, Automatic (delayed), Manual, Disabled. + public static string DescribeServiceStartType(string startMode, bool delayed) => startMode switch { - "Automatic" when delayed => "Starts automatically (delayed) at boot", - "Automatic" => "Starts automatically at boot", - "Boot" or "System" => "Starts with Windows", - "Manual" => "Starts manually", + "Automatic" or "Auto" when delayed => "Automatic (delayed)", + "Automatic" or "Auto" => "Automatic", + "Boot" or "System" => "Automatic", + "Manual" => "Manual", "Disabled" => "Disabled", _ => "Unknown", }; + /// A service start mode as a trigger in words ("At boot", …). + public static string DescribeStartType(string startMode, bool delayed) => startMode switch + { + "Automatic" or "Auto" when delayed => "At boot (delayed)", + "Automatic" or "Auto" => "At boot", + "Boot" or "System" => "With Windows", + "Manual" => "Manually", + "Disabled" => "Never (disabled)", + _ => "Unknown", + }; + /// A stopped service's Win32 exit code in words; "—" while it runs. public static string DescribeServiceResult(bool running, int win32ExitCode) => running ? "—" : $"Exit code {win32ExitCode}"; + /// + /// The account a task runs as, from its principal: the user or group, with well-known SIDs + /// named. Null when the definition names neither. + /// + public static string? DescribeTaskPrincipal(string taskXml) + { + var principal = Parse(taskXml)?.Root?.Element(TaskNs + "Principals")?.Element(TaskNs + "Principal"); + var id = (string?)principal?.Element(TaskNs + "UserId") ?? (string?)principal?.Element(TaskNs + "GroupId"); + if (string.IsNullOrWhiteSpace(id)) + return null; + return id.Trim() switch + { + "S-1-5-18" => "SYSTEM", + "S-1-5-19" => "LOCAL SERVICE", + "S-1-5-20" => "NETWORK SERVICE", + "S-1-5-32-544" => "Administrators", + "S-1-5-32-545" => "Users", + var other => other, + }; + } + + /// Each Exec action's command and arguments, one per line. Null when there are none. + public static string? DescribeTaskActions(string taskXml) + { + var lines = Parse(taskXml)?.Root?.Element(TaskNs + "Actions")?.Elements(TaskNs + "Exec") + .Select(e => ((string?)e.Element(TaskNs + "Command") ?? "").Trim() + + (string.IsNullOrWhiteSpace((string?)e.Element(TaskNs + "Arguments")) + ? "" : " " + ((string)e.Element(TaskNs + "Arguments")!).Trim())) + .Where(l => l.Length > 0) + .ToList(); + return lines is { Count: > 0 } ? string.Join("\n", lines) : null; + } + + private static XDocument? Parse(string xml) + { + try { return XDocument.Parse(xml); } + catch (XmlException) { return null; } + } + /// /// The enabled triggers of a task definition (Task Scheduler XML) in words, joined with "; ". /// @@ -197,12 +339,12 @@ private static string DescribeCalendar(XElement trigger) private static string FormatTime(XElement trigger) => TryBoundary(trigger, out var start) - ? start.ToString("h:mm tt", CultureInfo.InvariantCulture) + ? start.ToString("t", CultureInfo.CurrentCulture) : "an unknown time"; private static string FormatBoundary(XElement trigger) => TryBoundary(trigger, out var start) - ? start.ToString("MMM d, yyyy h:mm tt", CultureInfo.InvariantCulture) + ? FormatDate(start) : "an unknown time"; // StartBoundary is local wall-clock time, sometimes with an offset; the wall-clock part is diff --git a/tests/BootstrapMate.Core.Tests/InstallFootprintTests.cs b/tests/BootstrapMate.Core.Tests/InstallFootprintTests.cs index 62146a9..14aef48 100644 --- a/tests/BootstrapMate.Core.Tests/InstallFootprintTests.cs +++ b/tests/BootstrapMate.Core.Tests/InstallFootprintTests.cs @@ -1,17 +1,62 @@ +using System.Globalization; using BootstrapMate.Core; using Xunit; namespace BootstrapMate.Core.Tests; -public class InstallFootprintTests +/// +/// Times follow the current culture, so every test runs pinned to en-GB (24-hour) unless it pins +/// another culture itself. +/// +public sealed class InstallFootprintTests : IDisposable { - private static string TaskXml(string triggers) => $""" + private readonly CultureInfo _culture = CultureInfo.CurrentCulture; + + public InstallFootprintTests() => CultureInfo.CurrentCulture = new CultureInfo("en-GB"); + + public void Dispose() => CultureInfo.CurrentCulture = _culture; + + private static T In(string culture, Func action) + { + var previous = CultureInfo.CurrentCulture; + CultureInfo.CurrentCulture = new CultureInfo(culture); + try { return action(); } + finally { CultureInfo.CurrentCulture = previous; } + } + + // ICU puts a narrow no-break space before AM/PM; compare it as a plain space. + private static string Spaces(string value) => value.Replace(' ', ' ').Replace(' ', ' '); + + private static string TaskXml(string triggers, string principal = "", string actions = "") => $""" {triggers} + {principal} + {actions} """.Trim(); + // What schtasks /Create … /SC DAILY /ST 03:00 /RU SYSTEM registers for the self-heal task. + private static readonly string SelfHealXml = TaskXml( + """ + + 2026-10-12T03:00:00 + true + 1 + + """, + """S-1-5-18HighestAvailable""", + """"C:\Program Files\BootstrapMate\managedbootstrapinstall.exe"--silent --no-dialog"""); + + private static FootprintItem SelfHeal => InstallFootprint.Items[0]; + + private static TaskSnapshot Snapshot(int state = 3, int result = 0, int lastYear = 2026, int nextYear = 2026, bool enabled = true) => + new(@"\BootstrapMate Self-Heal", enabled, state, + new DateTime(lastYear, 10, 12, 3, 0, 0), result, new DateTime(nextYear, 10, 13, 3, 0, 0), SelfHealXml); + + private static string Detail(FootprintStatus status, string label) => + Assert.Single(status.Details, d => d.Label == label).Value; + [Fact] public void TheFootprintIsTheSelfHealTaskTheInstallerRegisters() { @@ -20,14 +65,111 @@ public void TheFootprintIsTheSelfHealTaskTheInstallerRegisters() Assert.Equal(FootprintKind.ScheduledTask, item.Kind); } + // ── Task rows ──────────────────────────────────────────────── + + [Fact] + public void TheCollapsedTaskSummaryNamesKindScheduleAndResult() => + Assert.Equal("Scheduled task · Daily at 03:00 · Last result 0", + InstallFootprint.TaskStatus(SelfHeal, Snapshot()).Summary); + + [Fact] + public void AFailedResultShowsItsHexCodeInTheSummary() => + Assert.EndsWith("Last result 0x80070005", + InstallFootprint.TaskStatus(SelfHeal, Snapshot(result: unchecked((int)0x80070005))).Summary); + + [Fact] + public void ATaskThatHasNeverRunSaysSoInTheSummary() => + Assert.Equal("Scheduled task · Daily at 03:00 · Never run", + InstallFootprint.TaskStatus(SelfHeal, Snapshot(result: 0x41303, lastYear: 1899)).Summary); + + [Fact] + public void TaskDetailsFollowTheReportMateOrderAndLabels() + { + var status = InstallFootprint.TaskStatus(SelfHeal, Snapshot()); + + Assert.Equal( + ["Name", "Start type", "Status", "Account", "Path and arguments", "Triggers", "Last run", "Last result", "Next run"], + status.Details.Select(d => d.Label)); + Assert.Equal(@"\BootstrapMate Self-Heal", Detail(status, "Name")); + Assert.Equal("Enabled", Detail(status, "Start type")); + Assert.Equal("Ready", Detail(status, "Status")); + Assert.Equal("SYSTEM", Detail(status, "Account")); + Assert.Equal("\"C:\\Program Files\\BootstrapMate\\managedbootstrapinstall.exe\" --silent --no-dialog", + Detail(status, "Path and arguments")); + Assert.Equal("Daily at 03:00", Detail(status, "Triggers")); + Assert.Equal("12/10/2026 03:00", Detail(status, "Last run")); + Assert.Equal("Succeeded", Detail(status, "Last result")); + Assert.Equal("13/10/2026 03:00", Detail(status, "Next run")); + } + + [Fact] + public void NeverRunAndNothingScheduledReadAsWords() + { + var status = InstallFootprint.TaskStatus(SelfHeal, Snapshot(result: 0x41303, lastYear: 1899, nextYear: 1899)); + Assert.Equal("Never", Detail(status, "Last run")); + Assert.Equal("Never run", Detail(status, "Last result")); + Assert.Equal("Not scheduled", Detail(status, "Next run")); + } + + [Fact] + public void ADisabledTaskShowsDisabledAndTheNeutralDot() + { + var status = InstallFootprint.TaskStatus(SelfHeal, Snapshot(state: 1, enabled: false)); + Assert.Equal("Disabled", status.State); + Assert.Equal("Disabled", Detail(status, "Start type")); + Assert.True(status.IsNeutral); + } + + [Theory] + [InlineData(4, "Running")] + [InlineData(3, "Ready")] + public void RunningAndReadyGetTheirOwnDots(int state, string word) + { + var status = InstallFootprint.TaskStatus(SelfHeal, Snapshot(state: state)); + Assert.Equal(word, status.State); + Assert.Equal(word == "Running", status.IsRunning); + Assert.Equal(word == "Ready", status.IsReady); + Assert.False(status.IsNeutral); + } + + // ── Service rows ───────────────────────────────────────────── + + [Fact] + public void ARunningServiceOmitsTheRowsItDoesNotHave() + { + var item = new FootprintItem("Agent", "ExampleSvc", FootprintKind.Service, ""); + var status = InstallFootprint.ServiceStatus(item, + new ServiceSnapshot("Auto", false, "Running", "LocalSystem", @"C:\x\svc.exe --run", 0)); + + Assert.Equal("Service · Automatic · LocalSystem", status.Summary); + Assert.Equal(["Name", "Start type", "Status", "Account", "Path and arguments", "Triggers"], + status.Details.Select(d => d.Label)); + Assert.Equal("At boot", Detail(status, "Triggers")); + } + + [Fact] + public void AStoppedServiceShowsItsExitCode() => + Assert.Equal("Exit code 1067", Detail(InstallFootprint.ServiceStatus( + new FootprintItem("Agent", "ExampleSvc", FootprintKind.Service, ""), + new ServiceSnapshot("Manual", false, "Stopped", "LocalSystem", null, 1067)), "Last result")); + + // ── Formatting ─────────────────────────────────────────────── + [Theory] - [InlineData("Automatic", false, "Starts automatically at boot")] - [InlineData("Automatic", true, "Starts automatically (delayed) at boot")] - [InlineData("Manual", false, "Starts manually")] + [InlineData("Auto", false, "Automatic")] + [InlineData("Automatic", true, "Automatic (delayed)")] + [InlineData("Manual", false, "Manual")] [InlineData("Disabled", false, "Disabled")] [InlineData("Something", false, "Unknown")] - public void StartTypesReadAsWords(string startType, bool delayed, string expected) => - Assert.Equal(expected, InstallFootprint.DescribeStartType(startType, delayed)); + public void ServiceStartTypesReadAsWords(string mode, bool delayed, string expected) => + Assert.Equal(expected, InstallFootprint.DescribeServiceStartType(mode, delayed)); + + [Theory] + [InlineData("Auto", false, "At boot")] + [InlineData("Auto", true, "At boot (delayed)")] + [InlineData("Manual", false, "Manually")] + public void ServiceStartTypesReadAsTriggers(string mode, bool delayed, string expected) => + Assert.Equal(expected, InstallFootprint.DescribeStartType(mode, delayed)); [Theory] [InlineData(1, "Disabled")] @@ -37,46 +179,41 @@ public void StartTypesReadAsWords(string startType, bool delayed, string expecte public void TaskStatesReadAsWords(int state, string expected) => Assert.Equal(expected, InstallFootprint.DescribeTaskState(state)); - [Fact] - public void ASuccessfulRunShowsSucceededWithItsTime() => - Assert.Equal("Succeeded — Oct 12, 2026 3:00 AM", - InstallFootprint.DescribeTaskResult(new DateTime(2026, 10, 12, 3, 0, 0), 0)); + [Theory] + [InlineData(0, "Succeeded")] + [InlineData(2, "Failed (0x00000002)")] + [InlineData(unchecked((int)0x80070005), "Failed (0x80070005)")] + public void ResultCodesReadAsWords(int code, string expected) => + Assert.Equal(expected, InstallFootprint.DescribeTaskResult(new DateTime(2026, 10, 12), code)); - [Fact] - public void AFailedRunShowsItsHexCode() => - Assert.StartsWith("Failed (0x00000002)", - InstallFootprint.DescribeTaskResult(new DateTime(2026, 10, 12, 3, 0, 0), 2)); + [Theory] + [InlineData("S-1-5-18", "SYSTEM")] + [InlineData("S-1-5-20", "NETWORK SERVICE")] + [InlineData("S-1-5-32-545", "Users")] + [InlineData(@"CONTOSO\svc-bootstrap", @"CONTOSO\svc-bootstrap")] + public void PrincipalsReadAsAccounts(string principal, string expected) => + Assert.Equal(expected, InstallFootprint.DescribeTaskPrincipal(TaskXml("", $"{principal}"))); [Fact] - public void ANegativeResultShowsAsAnHResult() => - Assert.StartsWith("Failed (0x80070005)", - InstallFootprint.DescribeTaskResult(new DateTime(2026, 10, 12, 3, 0, 0), unchecked((int)0x80070005))); + public void ATaskWithoutAPrincipalHasNoAccount() => + Assert.Null(InstallFootprint.DescribeTaskPrincipal(TaskXml(""))); - [Theory] - [InlineData(0x41303)] - [InlineData(0)] - public void ATaskThatHasNotRunSaysSo(int result) => - Assert.Equal("Never run", InstallFootprint.DescribeTaskResult(new DateTime(1899, 12, 30), result)); + [Fact] + public void EachExecActionIsOneLine() => + Assert.Equal("a.exe --one\nb.exe", InstallFootprint.DescribeTaskActions(TaskXml("", "", + "a.exe--oneb.exe"))); - [Theory] - [InlineData(false, 1067, "Exit code 1067")] - [InlineData(true, 0, "—")] - public void ServiceResultsReadAsWords(bool running, int code, string expected) => - Assert.Equal(expected, InstallFootprint.DescribeServiceResult(running, code)); + [Fact] + public void ATaskWithoutExecActionsHasNoPath() => + Assert.Null(InstallFootprint.DescribeTaskActions(TaskXml(""))); [Fact] public void TheSelfHealScheduleReadsAsDailyAtThree() => - Assert.Equal("Daily at 3:00 AM", InstallFootprint.DescribeTaskTriggers(TaskXml(""" - - 2026-10-12T03:00:00 - true - 1 - - """))); + Assert.Equal("Daily at 03:00", InstallFootprint.DescribeTaskTriggers(SelfHealXml)); [Fact] public void EveryFewDaysNamesTheInterval() => - Assert.Equal("Every 3 days at 9:30 PM", InstallFootprint.DescribeTaskTriggers(TaskXml(""" + Assert.Equal("Every 3 days at 21:30", InstallFootprint.DescribeTaskTriggers(TaskXml(""" 2026-10-12T21:30:00-07:00 3 @@ -85,7 +222,7 @@ public void EveryFewDaysNamesTheInterval() => [Fact] public void WeeklyListsItsDays() => - Assert.Equal("Weekly on Monday, Friday at 8:00 AM", InstallFootprint.DescribeTaskTriggers(TaskXml(""" + Assert.Equal("Weekly on Monday, Friday at 08:00", InstallFootprint.DescribeTaskTriggers(TaskXml(""" 2026-10-12T08:00:00 1 @@ -94,7 +231,7 @@ public void WeeklyListsItsDays() => [Fact] public void StartupLogonAndRepetitionReadAsWords() => - Assert.Equal("At startup; At logon of any user; Once at Oct 12, 2026 12:00 AM, then every 4 hours", + Assert.Equal("At startup; At logon of any user; Once at 12/10/2026 00:00, then every 4 hours", InstallFootprint.DescribeTaskTriggers(TaskXml(""" @@ -118,4 +255,22 @@ public void ATaskWithNoTriggersRunsOnDemand() => [Fact] public void UnreadableXmlIsUnknown() => Assert.Equal("Unknown", InstallFootprint.DescribeTaskTriggers(" + Assert.Equal(expected, Spaces(In(culture, () => InstallFootprint.DescribeTaskTriggers(SelfHealXml)))); + + [Theory] + [InlineData("en-GB", "12/10/2026 03:00", "13/10/2026 03:00")] + [InlineData("en-US", "10/12/2026 3:00 AM", "10/13/2026 3:00 AM")] + public void RunTimesUseTheCulturesShortDateAndTime(string culture, string lastRun, string nextRun) + { + var status = In(culture, () => InstallFootprint.TaskStatus(SelfHeal, Snapshot())); + Assert.Equal(lastRun, Spaces(Detail(status, "Last run"))); + Assert.Equal(nextRun, Spaces(Detail(status, "Next run"))); + } }