513fa1aa16
Comment/XML-doc changes only: - add summaries to ~10k test methods, fixtures, fakes and helpers (+ <param> on theories, <returns> on async Task methods, <inheritdoc/> on interface implementations the checker can resolve) - strip ~2.6k project-tracking references (WP*, P*-*, row-NN, Task N, #NN, Component-0NN) from comments, keeping the explanatory text; reword false positives in comments only - real docs on fakes implementing BCL/library interfaces (IDisposable, ILogger, IOptionsMonitor, IAsyncLifetime) - reword the last 5 src/ false positives (CWE-1236, failures-1, year-0001, M365) Only non-comment edits: four one-line nested classes split across lines so members can carry docs. Build 0 errors / 0 warnings.
54 lines
2.2 KiB
C#
54 lines
2.2 KiB
C#
using Bunit;
|
|
using ZB.MOM.WW.ScadaBridge.CentralUI.Components.Shared;
|
|
|
|
namespace ZB.MOM.WW.ScadaBridge.CentralUI.Tests.Shared;
|
|
|
|
/// <summary>
|
|
/// Regression tests for rendering a null timestamp. A heartbeat-only registered site has
|
|
/// a <c>null</c> <c>LastReportReceivedAt</c> ("no full report yet"). The health
|
|
/// dashboard passes that value straight into <see cref="TimestampDisplay"/>, so the
|
|
/// component's <c>Value</c> must accept <c>DateTimeOffset?</c> and render a
|
|
/// <c>null</c> as a human-readable placeholder ("never") instead of the
|
|
/// <c>DateTimeOffset.MinValue</c> year 0001 sentinel. Non-null callers must keep
|
|
/// rendering the formatted timestamp exactly as before.
|
|
/// </summary>
|
|
public class TimestampDisplayTests : BunitContext
|
|
{
|
|
/// <summary>Verifies that a non-null value renders as a formatted timestamp.</summary>
|
|
[Fact]
|
|
public void Render_NonNullValue_ShowsFormattedTimestamp()
|
|
{
|
|
var value = new DateTimeOffset(2026, 5, 17, 14, 30, 45, TimeSpan.Zero);
|
|
|
|
var cut = Render<TimestampDisplay>(parameters => parameters
|
|
.Add(p => p.Value, (DateTimeOffset?)value)
|
|
.Add(p => p.Format, "HH:mm:ss"));
|
|
|
|
var span = cut.Find("span");
|
|
Assert.Equal(value.LocalDateTime.ToString("HH:mm:ss"), span.TextContent.Trim());
|
|
Assert.Contains("2026-05-17 14:30:45 UTC", span.GetAttribute("title")!);
|
|
}
|
|
|
|
/// <summary>Verifies that a null value renders the "never" placeholder.</summary>
|
|
[Fact]
|
|
public void Render_NullValue_ShowsNeverPlaceholder()
|
|
{
|
|
var cut = Render<TimestampDisplay>(parameters => parameters
|
|
.Add(p => p.Value, (DateTimeOffset?)null)
|
|
.Add(p => p.Format, "HH:mm:ss"));
|
|
|
|
Assert.Contains("never", cut.Markup, StringComparison.OrdinalIgnoreCase);
|
|
}
|
|
|
|
/// <summary>Verifies that a null value does not render the year 0001 minimum-value sentinel.</summary>
|
|
[Fact]
|
|
public void Render_NullValue_DoesNotRenderYear0001Sentinel()
|
|
{
|
|
var cut = Render<TimestampDisplay>(parameters => parameters
|
|
.Add(p => p.Value, (DateTimeOffset?)null));
|
|
|
|
// The year 0001 DateTimeOffset.MinValue sentinel must never reach the UI.
|
|
Assert.DoesNotContain("0001", cut.Markup);
|
|
}
|
|
}
|