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.
37 lines
1.6 KiB
C#
37 lines
1.6 KiB
C#
using Microsoft.Extensions.DependencyInjection;
|
|
using ZB.MOM.WW.ScadaBridge.SiteRuntime;
|
|
using ZB.MOM.WW.ScadaBridge.SiteRuntime.Scripts;
|
|
|
|
namespace ZB.MOM.WW.ScadaBridge.SiteRuntime.Tests;
|
|
|
|
/// <summary>
|
|
/// Pins the DI lifetimes that carry a behavioural contract rather than a convention.
|
|
/// </summary>
|
|
public class SiteRuntimeServiceRegistrationTests
|
|
{
|
|
/// <summary>
|
|
/// Register row 100. <c>ScriptCompilationService</c> owns the
|
|
/// <c>SiteScriptCompileCache</c>, so "one Roslyn compile per script body per process"
|
|
/// (the warm-then-gate deploy path) is precisely the statement that DI hands
|
|
/// out ONE of these per host. The cache stopped being <c>static</c> when row 100 removed
|
|
/// the process-global state tests were clobbering; this registration is what replaced
|
|
/// the static as the guarantee, so it is pinned here.
|
|
///
|
|
/// <para>Downgrading this to Scoped or Transient would give every consumer — the deploy
|
|
/// gate, each Instance Actor's PreStart, SharedScriptLibrary — its own empty cache and
|
|
/// silently reintroduce the recompile storms the warm-then-gate path removed, with no functional test
|
|
/// failing. This assertion is the only thing that would notice.</para>
|
|
/// </summary>
|
|
[Fact]
|
|
public void AddSiteRuntime_RegistersScriptCompilationServiceAsSingleton_SoOneCompileCacheExistsPerProcess()
|
|
{
|
|
var services = new ServiceCollection();
|
|
|
|
services.AddSiteRuntime();
|
|
|
|
var descriptor = Assert.Single(
|
|
services, d => d.ServiceType == typeof(ScriptCompilationService));
|
|
Assert.Equal(ServiceLifetime.Singleton, descriptor.Lifetime);
|
|
}
|
|
}
|