docs(tests): fix CommentChecker findings across tests/ — 13,392 → 0 (repo-wide scan clean)
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.
This commit is contained in:
@@ -18,37 +18,59 @@ using ParkedMessagesPage = ZB.MOM.WW.ScadaBridge.CentralUI.Components.Pages.Moni
|
||||
namespace ZB.MOM.WW.ScadaBridge.CentralUI.Tests.Shared;
|
||||
|
||||
/// <summary>
|
||||
/// Regression tests for CentralUI-023. <c>DiffDialog.TryLockBodyAsync</c> /
|
||||
/// Regression tests for JS-interop failure logging. <c>DiffDialog.TryLockBodyAsync</c> /
|
||||
/// <c>TryUnlockBodyAsync</c> and <c>ParkedMessages.CopyAsync</c> wrapped JS
|
||||
/// interop in bare <c>catch { }</c> blocks: a genuine <see cref="JSException"/>
|
||||
/// was indistinguishable from an expected <see cref="JSDisconnectedException"/>
|
||||
/// and neither was logged. The fix narrows the catch and logs real interop
|
||||
/// failures via <c>ILogger</c>, consistent with the CentralUI-018 fixes.
|
||||
/// failures via <c>ILogger</c>, consistent with the earlier JS-interop logging fixes.
|
||||
/// </summary>
|
||||
public class JsInteropLoggingTests : BunitContext
|
||||
{
|
||||
/// <summary>Captures log entries so the test can assert on them.</summary>
|
||||
private sealed class CapturingLoggerProvider : ILoggerProvider
|
||||
{
|
||||
/// <summary>Gets the log entries captured by the factory's loggers.</summary>
|
||||
public List<(LogLevel Level, string Message, Exception? Exception)> Entries { get; } = new();
|
||||
|
||||
/// <summary>Creates a logger that records into the shared entry list.</summary>
|
||||
/// <param name="categoryName">The logger category name, which is ignored.</param>
|
||||
/// <returns>A logger that captures its entries.</returns>
|
||||
public ILogger CreateLogger(string categoryName) => new CapturingLogger(Entries);
|
||||
/// <summary>Does nothing; there is nothing to release.</summary>
|
||||
public void Dispose() { }
|
||||
|
||||
private sealed class CapturingLogger : ILogger
|
||||
{
|
||||
private readonly List<(LogLevel, string, Exception?)> _entries;
|
||||
/// <summary>Initializes a new instance of the <c>CapturingLogger</c> class.</summary>
|
||||
/// <param name="entries">The list that receives captured log entries.</param>
|
||||
public CapturingLogger(List<(LogLevel, string, Exception?)> entries) => _entries = entries;
|
||||
|
||||
/// <summary>Returns no scope because the fake does not track scopes.</summary>
|
||||
/// <typeparam name="TState">The type of the state object.</typeparam>
|
||||
/// <param name="state">The scope or log state.</param>
|
||||
/// <returns>A no-op scope.</returns>
|
||||
public IDisposable? BeginScope<TState>(TState state) where TState : notnull => null;
|
||||
/// <summary>Reports whether logging is enabled for the given level.</summary>
|
||||
/// <param name="logLevel">The log level.</param>
|
||||
/// <returns>True if the level is enabled; otherwise false.</returns>
|
||||
public bool IsEnabled(LogLevel logLevel) => true;
|
||||
|
||||
/// <summary>Records the log entry for later assertions.</summary>
|
||||
/// <typeparam name="TState">The type of the state object.</typeparam>
|
||||
/// <param name="logLevel">The log level.</param>
|
||||
/// <param name="eventId">The event id.</param>
|
||||
/// <param name="state">The scope or log state.</param>
|
||||
/// <param name="exception">The exception associated with the entry, if any.</param>
|
||||
/// <param name="formatter">Formats the state and exception into the message text.</param>
|
||||
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state,
|
||||
Exception? exception, Func<TState, Exception?, string> formatter)
|
||||
=> _entries.Add((logLevel, formatter(state, exception), exception));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a genuine JavaScript exception while locking the diff dialog body is logged.</summary>
|
||||
[Fact]
|
||||
public void DiffDialog_BodyLock_GenuineJsException_IsLogged()
|
||||
{
|
||||
@@ -74,6 +96,7 @@ public class JsInteropLoggingTests : BunitContext
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a circuit disconnect while locking the diff dialog body is not logged.</summary>
|
||||
[Fact]
|
||||
public void DiffDialog_BodyLock_Disconnect_IsNotLogged()
|
||||
{
|
||||
@@ -93,6 +116,8 @@ public class JsInteropLoggingTests : BunitContext
|
||||
Assert.DoesNotContain(provider.Entries, e => e.Level >= LogLevel.Warning);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a genuine JavaScript exception while copying parked messages is logged.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task ParkedMessages_Copy_GenuineJsException_IsLogged()
|
||||
{
|
||||
@@ -135,7 +160,10 @@ public class JsInteropLoggingTests : BunitContext
|
||||
private sealed class StubAuthStateProvider : AuthenticationStateProvider
|
||||
{
|
||||
private readonly AuthenticationState _state;
|
||||
/// <summary>Initializes a new instance of the <c>StubAuthStateProvider</c> class.</summary>
|
||||
/// <param name="state">The authentication state the provider returns.</param>
|
||||
public StubAuthStateProvider(AuthenticationState state) => _state = state;
|
||||
/// <inheritdoc />
|
||||
public override Task<AuthenticationState> GetAuthenticationStateAsync()
|
||||
=> Task.FromResult(_state);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user