mirror of
https://github.com/OPCFoundation/UA-.NETStandard.git
synced 2026-10-29 15:11:53 +08:00
# Description Update 55 NuGet dependencies to the latest stable releases available on 2026-10-19, preserving documented compatibility pins and framework-specific version bands. Existing OpenUSD prereleases remain unchanged because no newer releases are available. Migrate existing tests to NUnit 5: await asynchronous assertions, propagate async through helpers, handle nullable predicates, and replace obsolete `Order` attributes with sequencing dependencies. Sequencing dependencies use `AllowFailure = true`; filtering a dependent test also runs prerequisites. Adjust fixture-level parallelism where NUnit dependency scheduling requires it. Keep Roslyn API/runtime pins intact; select newer Immutable/Metadata runtime packages only for test and profiling hosts requiring them. Update the approved SDK pin to 10.0.402 across local, CI, and container builds. Document NUnit 5 conventions.
138 lines
6.2 KiB
C#
138 lines
6.2 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.Collections.Generic;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using NUnit.Framework;
|
|
|
|
namespace Opc.Ua.Server.Tests.Location
|
|
{
|
|
/// <summary>
|
|
/// Verifies that geolocation watches, faults, and updates preserve the distinction between missing and sampled
|
|
/// sources.
|
|
/// </summary>
|
|
[TestFixture]
|
|
[Category("GeoLocation")]
|
|
public sealed class GeoLocationSourceStateRegressionTests
|
|
{
|
|
/// <summary>
|
|
/// Verifies that watching a missing source waits for its first update without making a sample readable.
|
|
/// </summary>
|
|
[Test]
|
|
public async Task WatchingUnknownSourceDoesNotInventAGoodSampleAsync()
|
|
{
|
|
using var provider = new InMemoryGeoLocationProvider();
|
|
using var cancellation = new CancellationTokenSource();
|
|
await using IAsyncEnumerator<GeoLocationSample> watch =
|
|
provider.WatchAsync("new", cancellation.Token).GetAsyncEnumerator();
|
|
Task<bool> pending = watch.MoveNextAsync().AsTask();
|
|
try
|
|
{
|
|
await AssertMissing(provider);
|
|
Assert.That(pending.IsCompleted, Is.False);
|
|
GeoLocationSample expected = GeoLocationSample.Good(
|
|
new GeoPosition(48, 8), new DateTime(2025, 1, 1, 0, 0, 0, DateTimeKind.Utc));
|
|
provider.Update("new", expected);
|
|
Assert.That(await pending.ConfigureAwait(false), Is.True);
|
|
Assert.That(watch.Current, Is.EqualTo(expected));
|
|
Assert.That(await provider.ReadAsync("new").ConfigureAwait(false), Is.EqualTo(expected));
|
|
}
|
|
finally
|
|
{
|
|
cancellation.Cancel();
|
|
await pending.ConfigureAwait(false);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Verifies that cancelling a watch on a missing source leaves reads reporting not found.
|
|
/// </summary>
|
|
[Test]
|
|
public async Task CancelingAnUnknownWatchDoesNotMakeTheSourceReadableAsync()
|
|
{
|
|
using var provider = new InMemoryGeoLocationProvider();
|
|
using var cancellation = new CancellationTokenSource();
|
|
await using IAsyncEnumerator<GeoLocationSample> watch =
|
|
provider.WatchAsync("new", cancellation.Token).GetAsyncEnumerator();
|
|
Task<bool> pending = watch.MoveNextAsync().AsTask();
|
|
cancellation.Cancel();
|
|
Assert.That(await pending.ConfigureAwait(false), Is.False);
|
|
await AssertMissing(provider);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Verifies that faults on missing sources are preserved until an update replaces them with a real sample.
|
|
/// </summary>
|
|
[TestCase(false)]
|
|
[TestCase(true)]
|
|
public async Task FaultingUnknownSourcePreservesTheInjectedFailureAndUpdateClearsItAsync(bool watchFirst)
|
|
{
|
|
using var provider = new InMemoryGeoLocationProvider();
|
|
using var cancellation = new CancellationTokenSource();
|
|
await using IAsyncEnumerator<GeoLocationSample> watch =
|
|
provider.WatchAsync("new", cancellation.Token).GetAsyncEnumerator();
|
|
Task<bool> pending = watchFirst ? watch.MoveNextAsync().AsTask() : Task.FromResult(false);
|
|
try
|
|
{
|
|
var failure = new InvalidOperationException("location unavailable");
|
|
provider.Fault("new", failure);
|
|
InvalidOperationException actual = await Assert.ThrowsAsync<InvalidOperationException>(async () =>
|
|
await provider.ReadAsync("new").ConfigureAwait(false));
|
|
Assert.That(actual, Is.SameAs(failure));
|
|
|
|
GeoLocationSample expected = GeoLocationSample.Unavailable(StatusCodes.BadNoDataAvailable);
|
|
provider.Update("new", expected);
|
|
Assert.That(await provider.ReadAsync("new").ConfigureAwait(false), Is.EqualTo(expected));
|
|
if (watchFirst)
|
|
{
|
|
Assert.That(await pending.ConfigureAwait(false), Is.True);
|
|
Assert.That(watch.Current.StatusCode, Is.EqualTo(StatusCodes.BadNoDataAvailable));
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
cancellation.Cancel();
|
|
await pending.ConfigureAwait(false);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Verifies that the watched source remains absent from readable geolocation state.
|
|
/// </summary>
|
|
private static async Task AssertMissing(InMemoryGeoLocationProvider provider)
|
|
{
|
|
ServiceResultException error = await Assert.ThrowsAsync<ServiceResultException>(async () =>
|
|
await provider.ReadAsync("new").ConfigureAwait(false));
|
|
Assert.That(error.StatusCode, Is.EqualTo(StatusCodes.BadNotFound));
|
|
}
|
|
}
|
|
}
|