Files
ScadaBridge/tests/ZB.MOM.WW.ScadaBridge.CentralUI.Tests/ConfigurationMutationTestExtensions.cs
T
Joseph Doherty 513fa1aa16 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.
2026-10-07 15:05:49 -04:00

31 lines
1.4 KiB
C#

using Microsoft.Extensions.DependencyInjection.Extensions;
using NSubstitute;
using ZB.MOM.WW.ScadaBridge.CentralUI.Services;
using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Services;
namespace Microsoft.Extensions.DependencyInjection;
internal static class ConfigurationMutationTestExtensions
{
/// <summary>Registers the configuration command services with test doubles for auditing and transactions.</summary>
/// <param name="services">The service collection to add the registrations to.</param>
/// <returns>The same service collection, for chaining.</returns>
public static IServiceCollection AddTestConfigurationMutations(this IServiceCollection services)
{
services.TryAddScoped<ConfigurationCommandService>();
services.TryAddScoped<AuthorizedManualFailoverService>();
services.TryAddSingleton<IAuditService>(_ => Substitute.For<IAuditService>());
services.TryAddSingleton<IConfigurationCommandTransaction, RepositoryTransaction>();
return services;
}
private sealed class RepositoryTransaction(IServiceScopeFactory scopes) : IConfigurationCommandTransaction
{
/// <inheritdoc />
public async Task<object?> ExecuteAsync(Func<IServiceProvider, Task<object?>> operation)
{
using var scope = scopes.CreateScope();
return await operation(scope.ServiceProvider);
}
}
}