Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Services/SclSafeTrialRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ public static async Task<SclSafeTrialRunResult> RunAsync(
var document = XDocument.Load(command.SclPath, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
var sclXml = document.ToString(SaveOptions.DisableFormatting);

var client = new NativeIec61850Client();
// Own the entire read-only trial association, including failure and cancellation.
await using var client = new NativeIec61850Client();
result = await client.ConnectUsingSclAsync(
sclXml,
command.IedName,
Expand Down
13 changes: 13 additions & 0 deletions tests/ARSAS.Tests/SclSafeTrialRunnerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ public void CommandParser_RejectsInvalidMmsPort(string port)
Assert.Contains("port", error, StringComparison.OrdinalIgnoreCase);
}

[Fact]
public void TrialRunner_SourceContract_DisposesTrialClientOnEveryExit()
{
var source = File.ReadAllText(FindRepoFile("Services/SclSafeTrialRunner.cs"));

// An awaited using declaration includes normal return, cancellation and
// exception paths, and keeps the association alive for snapshot capture.
Assert.Contains(
"await using var client = new NativeIec61850Client();",
source,
StringComparison.Ordinal);
}

[Fact]
public void TrialRunner_SourceContract_HasNoDiscoveryWriteControlOrReportingEntryPoint()
{
Expand Down
Loading