Files
UA-.NETStandard/tests/Opc.Ua.Server.Tests/RuntimeNodeSet/RuntimeNodeSetNodeManagerFactoryTests.cs
romanett 9b034f8291 Enable nullable reference types centrally; migrate all unset and annotations-only projects (#4700)
# Description

Nullable reference types are now enabled once, in `common.props`, and
every project in the repository builds warning-clean with them.

**Configuration**
- `<Nullable>enable</Nullable>` lives in `common.props`. All per-project
`<Nullable>` settings are removed: 178 project files (enable,
annotations, and the `disable` in the three Aot test projects).
- 419 per-file `#nullable enable`/`restore` directives and the 4
`#nullable disable` directives are removed.
- Kept on purpose:
- The 5 `<auto-generated>` schema files (`UANodeSet.cs`, `UA Type
Dictionary.cs`, `OPCBinarySchema.cs`, `SecuredApplication.cs`,
`PInvokeHelper.cs`) keep `#nullable enable`. The compiler ignores the
project setting in generated code, so the directive is required there.
- `tests/Opc.Ua.Interop.LegacyPeer` keeps `disable`. It builds against
the 1.5.378 packages and does not import the repository props.
- `docs/DeveloperGuide.md` and `.github/copilot-instructions.md` now
describe the central setting.

**Migration** (the 43 unset and 13 annotations-only projects, roughly
10k diagnostics)
- **Production code: annotated at the declarations.** Covers
`tools/Opc.Ua.SourceGeneration.Core`, `src/Opc.Ua.Lds.Server` and the
LDS sample.
- Members, parameters and returns are nullable where null actually
flows.
- Null-check helpers carry `[NotNullWhen]` (`IsNull`, `IsValidXmlName`,
`IsMethodTypeDesign`).
- `CoreUtils.Format`, `Utils.Format`, `ITemplateWriter.WriteLine` take
`params object?[]`. `Template.AddReplacement` takes `string?` (rendering
already skips null replacements).
- `IRegisteredServerStore.RegisterAsync` returns
`Task<RegistrationEntry?>`: it returns null when a registration is
removed.
- Dereferences backed by an invariant (for example, the validated model)
use `!`, so runtime behaviour is unchanged.
- **Behavioural changes in production code** (small, deliberate):
- `NodeSetToModelDesign` throws `InvalidOperationException` when the
file is not a NodeSet. Before, it threw a NullReferenceException on the
next line.
- `ModelDesignValidator` starts its lookup tables empty instead of null.
A redundant `if (m_nodes == null) return;` guard is gone.
- **Test code: minimal annotations.**
  - `?` on values that can be null, `!` where the test asserts non-null.
  - `= null!` for fixture members assigned in SetUp.
- `TryGetStructure<T>(out T? x)` where the inferred `T?` broke the
`IEncodeable` constraint.
- A few redundant `== null` checks on structs (`NodeId`, `ArrayOf<T>`)
folded into the adjacent `IsNull`/`Count` checks.

**Notes for reviewers**
- The diff is large (~1,500 files) but almost entirely mechanical: `?`,
`!` and directive removal. The non-annotation changes are listed above.
- Known follow-up, not done here:
`IModelDesign.Namespaces/TargetNamespace/NamespaceUris` stay
non-nullable even though the validator returns null before it loads a
dictionary. Making them nullable would ripple through every generator
call site.

## Related Issues

- Fixes #4439

## Checklist

- [ ] I have signed the
[CLA](https://opcfoundation.org/license/cla/ContributorLicenseAgreementv1.0.pdf)
and read the
[CONTRIBUTING](https://github.com/OPCFoundation/UA-.NETStandard/blob/master/CONTRIBUTING.md)
doc.
- [ ] I have added tests that prove my fix is effective or that my
feature works and increased code coverage.
- [x] I have added all necessary documentation.
- [x] I have verified that my changes do not introduce (new) build or
analyzer warnings.
- [ ] I ran **all** tests locally using the **UA.slnx** solution against
at least .net **framework** and .net **10**, and all passed.
- [ ] I fixed **all** failing and flaky tests in the CI pipelines and
**all** CodeQL warnings.
- [ ] I have addressed **all** PR feedback received.

The "no new warnings" box covers net10.0 and net48: full non-incremental
builds of `UA.slnx`, `tools/SourceGeneration.slnx`,
`tools/MigrationAnalyzer.slnx` and the Aot test projects finished with 0
warnings and 0 errors under the repository's warnings-as-errors
settings. net9.0 and net8.0 also had no nullable diagnostics, but they
were not rebuilt after the final fixes. Tests have not been run locally
yet.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 08:48:13 +02:00

548 lines
22 KiB
C#

/* ========================================================================
* Copyright (c) 2005-2026 The OPC Foundation, Inc. All rights reserved.
*
* OPC Foundation MIT License 1.00
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* The complete license agreement can be found here:
* http://opcfoundation.org/License/MIT/1.00/
* ======================================================================*/
using System;
using System.IO;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Moq;
using NUnit.Framework;
using Opc.Ua.Server.RuntimeNodeSet;
namespace Opc.Ua.Server.Tests.RuntimeNodeSet
{
/// <summary>
/// Unit tests for <see cref="RuntimeNodeSetNodeManagerFactory"/> covering
/// constructor argument validation, <see cref="IAsyncNodeManagerFactory.NamespacesUris"/>
/// population, options snapshot semantics, cycle detection, and duplicate model URI
/// rejection.
/// </summary>
[TestFixture]
[Category("RuntimeNodeSet")]
[Parallelizable(ParallelScope.All)]
[FixtureLifeCycle(LifeCycle.InstancePerTestCase)]
public sealed class RuntimeNodeSetNodeManagerFactoryTests
{
private const string kUriA = "urn:test:ModelA";
private const string kUriB = "urn:test:ModelB";
private static StreamRuntimeNodeSetSource MakeStreamSource(string modelUri, string xml)
{
return RuntimeNodeSetSource.FromStream(
modelUri,
_ => new ValueTask<Stream>(
new MemoryStream(Encoding.UTF8.GetBytes(xml))),
[modelUri]);
}
private static string MakeMinimalXml(string modelUri)
{
return
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
"<UANodeSet xmlns=\"http://opcfoundation.org/UA/2011/03/UANodeSet.xsd\">\r\n" +
" <Models>\r\n" +
" <Model ModelUri=\"" + modelUri + "\" />\r\n" +
" </Models>\r\n" +
"</UANodeSet>";
}
private static string MakeCycleXml(string ownUri, string requiresUri)
{
return
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
"<UANodeSet xmlns=\"http://opcfoundation.org/UA/2011/03/UANodeSet.xsd\">\r\n" +
" <Models>\r\n" +
" <Model ModelUri=\"" + ownUri + "\">\r\n" +
" <RequiredModel ModelUri=\"" + requiresUri + "\" />\r\n" +
" </Model>\r\n" +
" </Models>\r\n" +
"</UANodeSet>";
}
/// <summary>
/// Constructor must throw when <c>options</c> is <c>null</c>.
/// </summary>
[Test]
public void ConstructorRejectsNullOptions()
{
Assert.That(
() => new RuntimeNodeSetNodeManagerFactory(null!),
Throws.ArgumentNullException.With.Property("ParamName").EqualTo("options"));
}
/// <summary>
/// Constructor must throw when <see cref="RuntimeNodeSetOptions.Sources"/> is empty.
/// </summary>
[Test]
public void ConstructorRejectsEmptySourceList()
{
var options = new RuntimeNodeSetOptions
{
Sources = []
};
Assert.That(
() => new RuntimeNodeSetNodeManagerFactory(options),
Throws.InvalidOperationException.With.Message.Contains("At least one"));
}
/// <summary>
/// Constructor must throw when two sources declare the same model namespace URI.
/// Duplicates are detected eagerly before the server starts.
/// </summary>
[Test]
public void ConstructorRejectsDuplicateModelUrisAcrossSources()
{
StreamRuntimeNodeSetSource sourceA = MakeStreamSource(kUriA, MakeMinimalXml(kUriA));
StreamRuntimeNodeSetSource sourceB = MakeStreamSource(kUriA, MakeMinimalXml(kUriA));
var options = new RuntimeNodeSetOptions
{
Sources = [sourceA, sourceB]
};
Assert.That(
() => new RuntimeNodeSetNodeManagerFactory(options),
Throws.InvalidOperationException.With.Message.Contains(kUriA));
}
/// <summary>
/// Constructor must throw when <see cref="RuntimeNodeSetOptions.DefaultNamespaceUri"/>
/// names a URI that is not owned by any configured source.
/// </summary>
[Test]
public void ConstructorRejectsDefaultNsNotOwnedByAnySources()
{
StreamRuntimeNodeSetSource source = MakeStreamSource(kUriA, MakeMinimalXml(kUriA));
var options = new RuntimeNodeSetOptions
{
Sources = [source],
DefaultNamespaceUri = "urn:not:owned"
};
Assert.That(
() => new RuntimeNodeSetNodeManagerFactory(options),
Throws.InvalidOperationException.With.Message.Contains("not owned"));
}
/// <summary>
/// <see cref="RuntimeNodeSetNodeManagerFactory.NamespacesUris"/> aggregates the
/// model URIs from all configured sources in declaration order.
/// </summary>
[Test]
public void NamespacesUrisAggregatesAllSourceModelUris()
{
StreamRuntimeNodeSetSource sourceA = MakeStreamSource(kUriA, MakeMinimalXml(kUriA));
StreamRuntimeNodeSetSource sourceB = MakeStreamSource(kUriB, MakeMinimalXml(kUriB));
var options = new RuntimeNodeSetOptions
{
Sources = [sourceA, sourceB]
};
var factory = new RuntimeNodeSetNodeManagerFactory(options);
Assert.That(factory.NamespacesUris.Count, Is.EqualTo(2));
Assert.That(factory.NamespacesUris[0], Is.EqualTo(kUriA));
Assert.That(factory.NamespacesUris[1], Is.EqualTo(kUriB));
}
/// <summary>
/// Mutating <see cref="RuntimeNodeSetOptions.Sources"/> after the factory is
/// constructed must not change the factory's
/// <see cref="RuntimeNodeSetNodeManagerFactory.NamespacesUris"/>.
/// </summary>
[Test]
public void NamespacesUrisSnapshotAtConstruction()
{
StreamRuntimeNodeSetSource sourceA = MakeStreamSource(kUriA, MakeMinimalXml(kUriA));
var options = new RuntimeNodeSetOptions
{
Sources = [sourceA]
};
var factory = new RuntimeNodeSetNodeManagerFactory(options);
Assert.That(factory.NamespacesUris.Count, Is.EqualTo(1));
// Mutate the options after construction — must not affect the factory.
options.Sources = [];
Assert.That(factory.NamespacesUris.Count, Is.EqualTo(1));
Assert.That(factory.NamespacesUris[0], Is.EqualTo(kUriA));
}
/// <summary>
/// A single source with a valid <see cref="RuntimeNodeSetOptions.DefaultNamespaceUri"/>
/// that matches one of the owned URIs is accepted without error.
/// </summary>
[Test]
public void ValidDefaultNamespaceUriIsAccepted()
{
StreamRuntimeNodeSetSource source = MakeStreamSource(kUriA, MakeMinimalXml(kUriA));
var options = new RuntimeNodeSetOptions
{
Sources = [source],
DefaultNamespaceUri = kUriA
};
Assert.That(
() => new RuntimeNodeSetNodeManagerFactory(options),
Throws.Nothing);
}
/// <summary>
/// When two sources form a mutual dependency cycle,
/// <see cref="RuntimeNodeSetNodeManagerFactory.CreateAsync"/> throws
/// <see cref="InvalidOperationException"/> with a message that names the
/// participating sources.
/// </summary>
[Test]
public async Task CreateAsyncThrowsOnCycleInIncludedSourcesAsync()
{
// Source A requires B, source B requires A → cycle.
StreamRuntimeNodeSetSource sourceA = RuntimeNodeSetSource.FromStream(
kUriA,
_ => new ValueTask<Stream>(
new MemoryStream(Encoding.UTF8.GetBytes(MakeCycleXml(kUriA, kUriB)))),
[kUriA]);
StreamRuntimeNodeSetSource sourceB = RuntimeNodeSetSource.FromStream(
kUriB,
_ => new ValueTask<Stream>(
new MemoryStream(Encoding.UTF8.GetBytes(MakeCycleXml(kUriB, kUriA)))),
[kUriB]);
var options = new RuntimeNodeSetOptions
{
Sources = [sourceA, sourceB]
};
var factory = new RuntimeNodeSetNodeManagerFactory(options);
Mock<IServerInternal> mockServer = CreateMinimalServerMock();
InvalidOperationException ex = Assert.ThrowsAsync<InvalidOperationException>(
async () => await factory.CreateAsync(
mockServer.Object,
new ApplicationConfiguration(),
default).ConfigureAwait(false));
Assert.That(ex.Message, Does.Contain("circular"));
}
/// <summary>
/// When two sources in a group declare the same <c>ModelUri</c> inside their
/// NodeSet XML (as opposed to in the declared metadata), <c>CreateAsync</c>
/// rejects them with <see cref="InvalidOperationException"/>.
/// </summary>
[Test]
public async Task CreateAsyncThrowsOnDuplicateModelUriInParsedDocumentsAsync()
{
// Both sources declare kUriA in their XML but the factory metadata
// declares different URIs to bypass the constructor check. When the
// documents are parsed, the ModelUri from the XML overrides the
// declared URIs and the factory detects the duplicate.
const string kUriExtra = "urn:extra:X";
StreamRuntimeNodeSetSource source1 = RuntimeNodeSetSource.FromStream(
kUriA,
_ => new ValueTask<Stream>(
new MemoryStream(Encoding.UTF8.GetBytes(MakeMinimalXml(kUriA)))),
[kUriA]);
// Use a second source that declares a different URI at the factory
// level but whose embedded XML resolves to the same ModelUri as source1.
// This creates a conflict detected during ParseAndSortAsync.
StreamRuntimeNodeSetSource source2 = RuntimeNodeSetSource.FromStream(
kUriExtra,
_ => new ValueTask<Stream>(
new MemoryStream(Encoding.UTF8.GetBytes(MakeMinimalXml(kUriA)))),
[kUriExtra]);
var options = new RuntimeNodeSetOptions
{
Sources = [source1, source2]
};
var factory = new RuntimeNodeSetNodeManagerFactory(options);
Mock<IServerInternal> mockServer = CreateMinimalServerMock();
// Parsing fails because the XML in source2 declares kUriA, which
// does not match the declared URI kUriExtra.
await Assert.ThatAsync(
() => factory.CreateAsync(
mockServer.Object,
new ApplicationConfiguration(),
default).AsTask(),
Throws.TypeOf<InvalidOperationException>()).ConfigureAwait(false);
}
/// <summary>
/// <see cref="RuntimeNodeSetNodeManagerFactory.CreateAsync"/> rejects a
/// <c>null</c> server.
/// </summary>
[Test]
public void CreateAsyncRejectsNullServer()
{
StreamRuntimeNodeSetSource source = MakeStreamSource(kUriA, MakeMinimalXml(kUriA));
var factory = new RuntimeNodeSetNodeManagerFactory(
new RuntimeNodeSetOptions { Sources = [source] });
Assert.That(
() => factory.CreateAsync(null!, new ApplicationConfiguration(), default).AsTask(),
Throws.ArgumentNullException.With.Property("ParamName").EqualTo("server"));
}
/// <summary>
/// A single-source group with no fluent callback creates a runtime node
/// manager whose owned namespace matches the source.
/// </summary>
[Test]
public async Task CreateAsyncReturnsManagerForSingleSourceAsync()
{
StreamRuntimeNodeSetSource source = MakeStreamSource(kUriA, MakeMinimalXml(kUriA));
var factory = new RuntimeNodeSetNodeManagerFactory(
new RuntimeNodeSetOptions { Sources = [source] });
IAsyncNodeManager manager = await factory.CreateAsync(
BuildMockServer().Object,
new ApplicationConfiguration(),
CancellationToken.None).ConfigureAwait(false);
using (manager as IDisposable)
{
Assert.That(manager, Is.Not.Null);
}
}
/// <summary>
/// When a fluent callback is present and an explicit default namespace is
/// configured, the manager is created using that namespace.
/// </summary>
[Test]
public async Task CreateAsyncWithExplicitDefaultNamespaceAsync()
{
StreamRuntimeNodeSetSource source = MakeStreamSource(kUriA, MakeMinimalXml(kUriA));
var factory = new RuntimeNodeSetNodeManagerFactory(new RuntimeNodeSetOptions
{
Sources = [source],
DefaultNamespaceUri = kUriA,
Configure = _ => { }
});
IAsyncNodeManager manager = await factory.CreateAsync(
BuildMockServer().Object,
new ApplicationConfiguration(),
CancellationToken.None).ConfigureAwait(false);
using (manager as IDisposable)
{
Assert.That(manager, Is.Not.Null);
}
}
/// <summary>
/// When a fluent callback is present but no explicit default namespace is
/// set, a single-source group infers the namespace from that source.
/// </summary>
[Test]
public async Task CreateAsyncInfersDefaultNamespaceForSingleSourceAsync()
{
StreamRuntimeNodeSetSource source = MakeStreamSource(kUriA, MakeMinimalXml(kUriA));
var factory = new RuntimeNodeSetNodeManagerFactory(new RuntimeNodeSetOptions
{
Sources = [source],
Configure = _ => { }
});
IAsyncNodeManager manager = await factory.CreateAsync(
BuildMockServer().Object,
new ApplicationConfiguration(),
CancellationToken.None).ConfigureAwait(false);
using (manager as IDisposable)
{
Assert.That(manager, Is.Not.Null);
}
}
/// <summary>
/// A single source that declares two models where one requires the other is
/// well-formed and must not be reported as a circular dependency.
/// </summary>
[Test]
public async Task CreateAsyncAcceptsIntraDocumentModelDependencyAsync()
{
const string xml =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
"<UANodeSet xmlns=\"http://opcfoundation.org/UA/2011/03/UANodeSet.xsd\">\r\n" +
" <Models>\r\n" +
" <Model ModelUri=\"" + kUriA + "\" />\r\n" +
" <Model ModelUri=\"" + kUriB + "\">\r\n" +
" <RequiredModel ModelUri=\"" + kUriA + "\" />\r\n" +
" </Model>\r\n" +
" </Models>\r\n" +
"</UANodeSet>";
StreamRuntimeNodeSetSource source = RuntimeNodeSetSource.FromStream(
"combined",
_ => new ValueTask<Stream>(new MemoryStream(Encoding.UTF8.GetBytes(xml))),
[kUriA, kUriB]);
var factory = new RuntimeNodeSetNodeManagerFactory(
new RuntimeNodeSetOptions { Sources = [source] });
IAsyncNodeManager manager = await factory.CreateAsync(
BuildMockServer().Object,
new ApplicationConfiguration(),
CancellationToken.None).ConfigureAwait(false);
using (manager as IDisposable)
{
Assert.That(manager, Is.Not.Null);
}
}
/// <summary>
/// With a fluent callback and two dependent sources, the default namespace
/// is inferred as the unique leaf model (the one not required by another).
/// </summary>
[Test]
public async Task CreateAsyncInfersLeafNamespaceForDependentSourcesAsync()
{
// Source A requires B, so A is the leaf and B is a dependency.
StreamRuntimeNodeSetSource sourceA = MakeStreamSource(kUriA, MakeCycleXml(kUriA, kUriB));
StreamRuntimeNodeSetSource sourceB = MakeStreamSource(kUriB, MakeMinimalXml(kUriB));
var factory = new RuntimeNodeSetNodeManagerFactory(new RuntimeNodeSetOptions
{
Sources = [sourceA, sourceB],
Configure = _ => { }
});
IAsyncNodeManager manager = await factory.CreateAsync(
BuildMockServer().Object,
new ApplicationConfiguration(),
CancellationToken.None).ConfigureAwait(false);
using (manager as IDisposable)
{
Assert.That(manager, Is.Not.Null);
}
}
/// <summary>
/// With a fluent callback and two independent leaf models, the default
/// namespace cannot be inferred and creation fails with a clear error.
/// </summary>
[Test]
public void CreateAsyncThrowsWhenDefaultNamespaceAmbiguous()
{
StreamRuntimeNodeSetSource sourceA = MakeStreamSource(kUriA, MakeMinimalXml(kUriA));
StreamRuntimeNodeSetSource sourceB = MakeStreamSource(kUriB, MakeMinimalXml(kUriB));
var factory = new RuntimeNodeSetNodeManagerFactory(new RuntimeNodeSetOptions
{
Sources = [sourceA, sourceB],
Configure = _ => { }
});
Assert.That(
() => factory.CreateAsync(
BuildMockServer().Object,
new ApplicationConfiguration(),
default).AsTask(),
Throws.InvalidOperationException.With.Message.Contains("infer"));
}
/// <summary>
/// When a source declares more owned namespaces than the parsed NodeSet
/// defines, creation fails during validation.
/// </summary>
[Test]
public void CreateAsyncThrowsWhenDeclaredNamespaceCountMismatch()
{
StreamRuntimeNodeSetSource source = RuntimeNodeSetSource.FromStream(
"mismatch",
_ => new ValueTask<Stream>(
new MemoryStream(Encoding.UTF8.GetBytes(MakeMinimalXml(kUriA)))),
[kUriA, kUriB]);
var factory = new RuntimeNodeSetNodeManagerFactory(
new RuntimeNodeSetOptions { Sources = [source] });
Assert.That(
() => factory.CreateAsync(
BuildMockServer().Object,
new ApplicationConfiguration(),
default).AsTask(),
Throws.InvalidOperationException);
}
/// <summary>
/// Creates a minimal <see cref="IServerInternal"/> mock sufficient for
/// <see cref="RuntimeNodeSetNodeManagerFactory.CreateAsync"/> to attempt
/// parsing (a real logger is injected so diagnostic output works).
/// </summary>
private static Mock<IServerInternal> CreateMinimalServerMock()
{
var mockLoggerFactory = LoggerFactory.Create(b => b.AddDebug());
var mockTelemetry = new Mock<ITelemetryContext>();
mockTelemetry.SetupGet(t => t.LoggerFactory).Returns(mockLoggerFactory);
var mockServer = new Mock<IServerInternal>();
mockServer.SetupGet(s => s.Telemetry).Returns(mockTelemetry.Object);
return mockServer;
}
/// <summary>
/// Creates an <see cref="IServerInternal"/> mock with the namespace table
/// and system context required to fully construct a runtime node manager
/// during <see cref="RuntimeNodeSetNodeManagerFactory.CreateAsync"/>.
/// </summary>
private static Mock<IServerInternal> BuildMockServer()
{
var mockLoggerFactory = LoggerFactory.Create(b => b.AddDebug());
var mockTelemetry = new Mock<ITelemetryContext>();
mockTelemetry.SetupGet(t => t.LoggerFactory).Returns(mockLoggerFactory);
var mockServer = new Mock<IServerInternal>();
mockServer.SetupGet(s => s.Telemetry).Returns(mockTelemetry.Object);
mockServer.SetupGet(s => s.NamespaceUris).Returns(new NamespaceTable());
var systemContext = new ServerSystemContext(mockServer.Object);
mockServer.SetupGet(s => s.DefaultSystemContext).Returns(systemContext);
return mockServer;
}
}
}