From 65ab757aa3266580ae10a751f69b2aedcbf6dad1 Mon Sep 17 00:00:00 2001 From: Andrew Cullen Date: Mon, 16 Jan 2023 10:46:14 -0500 Subject: [PATCH] Update packages --- .../UnitTests/ArraySegmentExtensionTests.cs | 2 +- .../BinaryDecoderTests.Equivalency.cs | 29 +++++----- .../UnitTests/Channels/BinaryDecoderTests.cs | 4 +- .../BinaryEncoderTests.Equivalency.cs | 21 ++++--- .../UnitTests/Channels/BinaryEncoderTests.cs | 4 +- .../UnitTests/DictionaryStoreTests.cs | 4 +- .../UnitTests/ErrorsContainerTests.cs | 4 +- .../UnitTests/ExpandedNodeIdTests.cs | 8 +-- UaClient.UnitTests/UnitTests/NodeIdTests.cs | 17 +++--- .../UnitTests/QualifiedNameTests.cs | 8 +-- .../UnitTests/ServiceExtensionsTests.cs | 8 +-- .../UnitTests/ServiceSetTests.cs | 56 +++++++++---------- .../Workstation.UaClient.UnitTests.csproj | 20 +++---- UaClient/Workstation.UaClient.csproj | 26 ++++----- 14 files changed, 106 insertions(+), 105 deletions(-) diff --git a/UaClient.UnitTests/UnitTests/ArraySegmentExtensionTests.cs b/UaClient.UnitTests/UnitTests/ArraySegmentExtensionTests.cs index 9f5c748..9e061c2 100644 --- a/UaClient.UnitTests/UnitTests/ArraySegmentExtensionTests.cs +++ b/UaClient.UnitTests/UnitTests/ArraySegmentExtensionTests.cs @@ -84,7 +84,7 @@ public void CreateBinaryWriter() } array - .Should().BeEquivalentTo(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); + .Should().BeEquivalentTo(new byte[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }); } } diff --git a/UaClient.UnitTests/UnitTests/Channels/BinaryDecoderTests.Equivalency.cs b/UaClient.UnitTests/UnitTests/Channels/BinaryDecoderTests.Equivalency.cs index d34fb60..593d9d0 100644 --- a/UaClient.UnitTests/UnitTests/Channels/BinaryDecoderTests.Equivalency.cs +++ b/UaClient.UnitTests/UnitTests/Channels/BinaryDecoderTests.Equivalency.cs @@ -12,6 +12,7 @@ using Workstation.ServiceModel.Ua; using Workstation.ServiceModel.Ua.Channels; using Xunit; +using Newtonsoft.Json.Linq; namespace Workstation.UaClient.UnitTests.Channels { @@ -19,19 +20,19 @@ public partial class BinaryDecoderTests { private abstract class TypeMappingEquivalency : IEquivalencyStep { - public bool CanHandle(IEquivalencyValidationContext context, - IEquivalencyAssertionOptions config) - => context.Subject is TSubject && context.Expectation is TExpectation; - public bool Handle(IEquivalencyValidationContext context, IEquivalencyValidator - parent, IEquivalencyAssertionOptions config) + public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context, IEquivalencyValidator nestedValidator) { - var subject = (TSubject)context.Subject; - var expectation = (TExpectation)context.Expectation; + if (comparands.Subject is TSubject subject) + { + if (comparands.Expectation is TExpectation expectation) + { + Test(subject, expectation, context.Reason.FormattedMessage, context.Reason.Arguments); + return EquivalencyResult.AssertionCompleted; + } + } + return EquivalencyResult.ContinueWithNext; - Test(subject, expectation, context.Because, context.BecauseArgs); - - return true; } protected abstract void Test(TSubject subject, TExpectation expectation, string because, object[] becauseArgs); @@ -45,7 +46,7 @@ protected override void Test(Guid subject, Opc.Ua.Uuid expectation, string becau .Should().Be((Guid)expectation); } } - + private class VariantEquivalency : TypeMappingEquivalency { protected override void Test(Variant subject, Opc.Ua.Variant expectation, string because, object[] becauseArgs) @@ -166,7 +167,7 @@ private class XmlEquivalency : TypeMappingEquivalency protected override void Test(XElement subject, XmlElement expectation, string because, object[] becauseArgs) { var xml = ToXmlNode(subject); - + xml .Should().BeEquivalentTo(expectation, because, becauseArgs); } @@ -201,7 +202,7 @@ static BinaryDecoderTests() // NodeId AssertionOptions.AssertEquivalencyUsing(options => options.Using(new NodeIdEquivalency())); - + // ExpandedNodeId AssertionOptions.AssertEquivalencyUsing(options => options.Using(new ExpandedNodeIdEquivalency())); @@ -216,7 +217,7 @@ static BinaryDecoderTests() // TimeZoneDataType AssertionOptions.AssertEquivalencyUsing(options => options.ComparingByMembers().ExcludingMissingMembers()); - + // Matrix/Multidim array AssertionOptions.AssertEquivalencyUsing(options => options.Using(new MatrixEquivalency())); } diff --git a/UaClient.UnitTests/UnitTests/Channels/BinaryDecoderTests.cs b/UaClient.UnitTests/UnitTests/Channels/BinaryDecoderTests.cs index 6186806..7a1880a 100644 --- a/UaClient.UnitTests/UnitTests/Channels/BinaryDecoderTests.cs +++ b/UaClient.UnitTests/UnitTests/Channels/BinaryDecoderTests.cs @@ -49,8 +49,8 @@ public void CreateWithNullStream() { Stream stream = null; - stream.Invoking(s => new BinaryDecoder(s)) - .Should().Throw(); + Action act = () => new BinaryDecoder(stream); + act.Should().Throw(); } [InlineData(true)] diff --git a/UaClient.UnitTests/UnitTests/Channels/BinaryEncoderTests.Equivalency.cs b/UaClient.UnitTests/UnitTests/Channels/BinaryEncoderTests.Equivalency.cs index 8142ae3..270f460 100644 --- a/UaClient.UnitTests/UnitTests/Channels/BinaryEncoderTests.Equivalency.cs +++ b/UaClient.UnitTests/UnitTests/Channels/BinaryEncoderTests.Equivalency.cs @@ -19,19 +19,18 @@ public partial class BinaryEncoderTests { private abstract class TypeMappingEquivalency : IEquivalencyStep { - public bool CanHandle(IEquivalencyValidationContext context, - IEquivalencyAssertionOptions config) - => context.Subject is TSubject && context.Expectation is TExpectation; - public bool Handle(IEquivalencyValidationContext context, IEquivalencyValidator - parent, IEquivalencyAssertionOptions config) + public EquivalencyResult Handle(Comparands comparands, IEquivalencyValidationContext context, IEquivalencyValidator nestedValidator) { - var subject = (TSubject)context.Subject; - var expectation = (TExpectation)context.Expectation; - - Test(subject, expectation, context.Because, context.BecauseArgs); - - return true; + if (comparands.Subject is TSubject subject) + { + if (comparands.Expectation is TExpectation expectation) + { + Test(subject, expectation, context.Reason.FormattedMessage, context.Reason.Arguments); + return EquivalencyResult.AssertionCompleted; + } + } + return EquivalencyResult.ContinueWithNext; } protected abstract void Test(TSubject subject, TExpectation expectation, string because, object[] becauseArgs); diff --git a/UaClient.UnitTests/UnitTests/Channels/BinaryEncoderTests.cs b/UaClient.UnitTests/UnitTests/Channels/BinaryEncoderTests.cs index ccfbd34..43f39e7 100644 --- a/UaClient.UnitTests/UnitTests/Channels/BinaryEncoderTests.cs +++ b/UaClient.UnitTests/UnitTests/Channels/BinaryEncoderTests.cs @@ -33,8 +33,8 @@ public void CreateWithNullStream() { Stream stream = null; - stream.Invoking(s => new BinaryEncoder(s)) - .Should().Throw(); + Action act = () => new BinaryEncoder(stream); + act.Should().Throw(); } [InlineData(true)] diff --git a/UaClient.UnitTests/UnitTests/DictionaryStoreTests.cs b/UaClient.UnitTests/UnitTests/DictionaryStoreTests.cs index 96d7a02..4a1283b 100644 --- a/UaClient.UnitTests/UnitTests/DictionaryStoreTests.cs +++ b/UaClient.UnitTests/UnitTests/DictionaryStoreTests.cs @@ -29,8 +29,8 @@ public void Constructor() [Theory] public void ConstructorNull(string dir) { - dir.Invoking(d => new DirectoryStore(d)) - .Should().Throw(); + Action act = () => new DirectoryStore(dir); + act.Should().Throw(); } [Fact] diff --git a/UaClient.UnitTests/UnitTests/ErrorsContainerTests.cs b/UaClient.UnitTests/UnitTests/ErrorsContainerTests.cs index 2e72e62..4b47ee5 100644 --- a/UaClient.UnitTests/UnitTests/ErrorsContainerTests.cs +++ b/UaClient.UnitTests/UnitTests/ErrorsContainerTests.cs @@ -39,8 +39,8 @@ public void CreateNull() { Action action = null; - action.Invoking(a => new ErrorsContainer(a)) - .Should().Throw(); + Action act = () => new ErrorsContainer(action); + act.Should().Throw(); } [MemberData(nameof(TestProperties))] diff --git a/UaClient.UnitTests/UnitTests/ExpandedNodeIdTests.cs b/UaClient.UnitTests/UnitTests/ExpandedNodeIdTests.cs index 016b545..0889560 100644 --- a/UaClient.UnitTests/UnitTests/ExpandedNodeIdTests.cs +++ b/UaClient.UnitTests/UnitTests/ExpandedNodeIdTests.cs @@ -308,8 +308,8 @@ public static IEnumerable BadParseData [Theory] public void NotParsable(string s) { - s.Invoking(t => ExpandedNodeId.Parse(t)) - .Should().Throw() + Action act = () => ExpandedNodeId.Parse(s); + act.Should().Throw() .Which.HResult .Should().Be(unchecked((int)StatusCodes.BadNodeIdInvalid)); } @@ -366,8 +366,8 @@ public void ToNodeIdNull() var nodeId = default(ExpandedNodeId); var nsUris = new string[] { }; - nodeId.Invoking(n => ExpandedNodeId.ToNodeId(n, nsUris)) - .Should().Throw(); + Action act = () => ExpandedNodeId.ToNodeId(nodeId, nsUris); + act.Should().Throw(); } } } diff --git a/UaClient.UnitTests/UnitTests/NodeIdTests.cs b/UaClient.UnitTests/UnitTests/NodeIdTests.cs index 9f2bf1a..c6cfe5f 100644 --- a/UaClient.UnitTests/UnitTests/NodeIdTests.cs +++ b/UaClient.UnitTests/UnitTests/NodeIdTests.cs @@ -46,8 +46,8 @@ public void CreateFromString() public void CreateFromStringNull() { var id = default(string); - id.Invoking(i => new NodeId(i, 2)) - .Should().Throw(); + Action act = () => new NodeId(id, 2); + act.Should().Throw(); } [Fact] @@ -84,8 +84,9 @@ public void CreateFromOpaque() public void CreateFromOpaqueNull() { var id = default(byte[]); - id.Invoking(i => new NodeId(i, 2)) - .Should().Throw(); + Action act = () => new NodeId(id, 2); + + act.Should().Throw(); } [Fact] @@ -254,8 +255,8 @@ public static IEnumerable BadParseData [Theory] public void NotParsable(string s) { - s.Invoking(t => NodeId.Parse(t)) - .Should().Throw() + Action act = () => NodeId.Parse(s); + act.Should().Throw() .Which.HResult .Should().Be(unchecked((int)StatusCodes.BadNodeIdInvalid)); } @@ -302,8 +303,8 @@ public void ToExpandedNodeIdNull() var nodeId = default(NodeId); var nsUris = new string[] { }; - nodeId.Invoking(n => NodeId.ToExpandedNodeId(n, nsUris)) - .Should().Throw(); + Action act = () => NodeId.ToExpandedNodeId(nodeId, nsUris); + act.Should().Throw(); } } } diff --git a/UaClient.UnitTests/UnitTests/QualifiedNameTests.cs b/UaClient.UnitTests/UnitTests/QualifiedNameTests.cs index 9bd6679..e175a2a 100644 --- a/UaClient.UnitTests/UnitTests/QualifiedNameTests.cs +++ b/UaClient.UnitTests/UnitTests/QualifiedNameTests.cs @@ -93,7 +93,7 @@ public void Equality(QualifiedName a, QualifiedName b, bool shouldBeEqual) .Should().NotBe(b); a .Should().NotBe(5); - + // Test Equal(QualifiedName) a.Equals(b) .Should().BeFalse(); @@ -112,7 +112,7 @@ public void Equality(QualifiedName a, QualifiedName b, bool shouldBeEqual) .Should().NotBe(b.GetHashCode()); } } - + public static IEnumerable EqualityNullData => QualifiedNames.Select(id => new[] { id() }); @@ -154,8 +154,8 @@ public void Parse(string text, ushort ns, string name) [Theory] public void NotParsable(string text) { - text.Invoking(t => QualifiedName.Parse(t)) - .Should().Throw(); + Action act = () => QualifiedName.Parse(text); + act.Should().Throw(); } } } diff --git a/UaClient.UnitTests/UnitTests/ServiceExtensionsTests.cs b/UaClient.UnitTests/UnitTests/ServiceExtensionsTests.cs index f84a52d..082dc72 100644 --- a/UaClient.UnitTests/UnitTests/ServiceExtensionsTests.cs +++ b/UaClient.UnitTests/UnitTests/ServiceExtensionsTests.cs @@ -44,8 +44,8 @@ public void ToVariantArrayNull() { var input = default(object[]); - input.Invoking(i => i.ToVariantArray()) - .Should().Throw(); + Action act = () => input.ToVariantArray(); + act.Should().Throw(); } [Fact] @@ -73,8 +73,8 @@ public void ToObjectArrayNull() { var input = default(Variant[]); - input.Invoking(i => i.ToObjectArray()) - .Should().Throw(); + Action act = () => input.ToObjectArray(); + act.Should().Throw(); } [Fact] diff --git a/UaClient.UnitTests/UnitTests/ServiceSetTests.cs b/UaClient.UnitTests/UnitTests/ServiceSetTests.cs index 37eecfe..722af05 100644 --- a/UaClient.UnitTests/UnitTests/ServiceSetTests.cs +++ b/UaClient.UnitTests/UnitTests/ServiceSetTests.cs @@ -45,7 +45,7 @@ public void ReadAsyncNull() var channel = new TestRequestChannel(response); channel.Invoking(c => c.ReadAsync(null)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -71,7 +71,7 @@ public void WriteAsyncNull() var channel = new TestRequestChannel(response); channel.Invoking(c => c.WriteAsync(null)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -97,7 +97,7 @@ public void HistoryReadAsyncNull() var channel = new TestRequestChannel(response); channel.Invoking(c => c.HistoryReadAsync(null)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -123,7 +123,7 @@ public void HistoryUpdateAsyncNull() var channel = new TestRequestChannel(response); channel.Invoking(c => c.HistoryUpdateAsync(null)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -152,7 +152,7 @@ public void CallAsyncNull() var channel = new TestRequestChannel(response); channel.Invoking(c => c.CallAsync(null)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -181,7 +181,7 @@ public void CreateMonitoredItemsAsyncNull() var channel = new TestRequestChannel(response); channel.Invoking(c => c.CreateMonitoredItemsAsync(null)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -207,7 +207,7 @@ public void ModifyMonitoredItemsAsyncNull() var channel = new TestRequestChannel(response); channel.Invoking(c => c.ModifyMonitoredItemsAsync(null)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -233,7 +233,7 @@ public void SetMonitoringModeAsyncNull() var channel = new TestRequestChannel(response); channel.Invoking(c => c.SetMonitoringModeAsync(null)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -259,7 +259,7 @@ public void SetTriggeringAsyncNull() var channel = new TestRequestChannel(response); channel.Invoking(c => c.SetTriggeringAsync(null)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -285,7 +285,7 @@ public void DeleteMonitoredItemsAsyncNull() var channel = new TestRequestChannel(response); channel.Invoking(c => c.DeleteMonitoredItemsAsync(null)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -314,7 +314,7 @@ public void AddNodesAsyncNull() var channel = new TestRequestChannel(response); channel.Invoking(c => c.AddNodesAsync(null)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -340,7 +340,7 @@ public void AddReferencesAsyncNull() var channel = new TestRequestChannel(response); channel.Invoking(c => c.AddReferencesAsync(null)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -366,7 +366,7 @@ public void DeleteNodesAsyncNull() var channel = new TestRequestChannel(response); channel.Invoking(c => c.DeleteNodesAsync(null)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -392,7 +392,7 @@ public void DeleteReferencesAsyncNull() var channel = new TestRequestChannel(response); channel.Invoking(c => c.DeleteReferencesAsync(null)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -421,7 +421,7 @@ public void QueryFirstAsyncNull() var channel = new TestRequestChannel(response); channel.Invoking(c => c.QueryFirstAsync(null)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -447,7 +447,7 @@ public void QueryNextAsyncNull() var channel = new TestRequestChannel(response); channel.Invoking(c => c.QueryNextAsync(null)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -476,7 +476,7 @@ public void CreateSubscriptionAsyncNull() var channel = new TestRequestChannel(response); channel.Invoking(c => c.CreateSubscriptionAsync(null)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -502,7 +502,7 @@ public void ModifySubscriptionAsyncNull() var channel = new TestRequestChannel(response); channel.Invoking(c => c.ModifySubscriptionAsync(null)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -528,7 +528,7 @@ public void SetPublishingModeAsyncNull() var channel = new TestRequestChannel(response); channel.Invoking(c => c.SetPublishingModeAsync(null)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -554,7 +554,7 @@ public void TransferSubscriptionsAsyncNull() var channel = new TestRequestChannel(response); channel.Invoking(c => c.TransferSubscriptionsAsync(null)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -580,7 +580,7 @@ public void DeleteSubscriptionsAsyncNull() var channel = new TestRequestChannel(response); channel.Invoking(c => c.DeleteSubscriptionsAsync(null)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -609,7 +609,7 @@ public void BrowseAsyncNull() var channel = new TestRequestChannel(response); channel.Invoking(c => c.BrowseAsync(null)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -635,7 +635,7 @@ public void BrowseNextAsyncNull() var channel = new TestRequestChannel(response); channel.Invoking(c => c.BrowseNextAsync(null)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -661,7 +661,7 @@ public void TranslateBrowsePathsToNodeIdsAsyncNull() var channel = new TestRequestChannel(response); channel.Invoking(c => c.TranslateBrowsePathsToNodeIdsAsync(null)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -687,7 +687,7 @@ public void RegisterNodesAsyncNull() var channel = new TestRequestChannel(response); channel.Invoking(c => c.RegisterNodesAsync(null)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -713,7 +713,7 @@ public void UnregisterNodesAsyncNull() var channel = new TestRequestChannel(response); channel.Invoking(c => c.UnregisterNodesAsync(null)) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -815,7 +815,7 @@ public void AcknowledgeAsyncNull() var channel = new TestRequestChannel(response); channel.Invoking(c => c.AcknowledgeAsync(null, "Comment")) - .Should().Throw(); + .Should().ThrowAsync(); } [Fact] @@ -862,7 +862,7 @@ public void ConfirmAsyncNull() var channel = new TestRequestChannel(response); channel.Invoking(c => c.ConfirmAsync(null, "Comment")) - .Should().Throw(); + .Should().ThrowAsync(); } } } diff --git a/UaClient.UnitTests/Workstation.UaClient.UnitTests.csproj b/UaClient.UnitTests/Workstation.UaClient.UnitTests.csproj index cece942..85b873e 100644 --- a/UaClient.UnitTests/Workstation.UaClient.UnitTests.csproj +++ b/UaClient.UnitTests/Workstation.UaClient.UnitTests.csproj @@ -1,7 +1,7 @@  - net5.0 + net7.0-windows Workstation.UaClient.UnitTests Workstation.UaClient 2.0.0 @@ -22,18 +22,18 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all - - - - - - - - + + + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/UaClient/Workstation.UaClient.csproj b/UaClient/Workstation.UaClient.csproj index 6a9cd8f..d974970 100644 --- a/UaClient/Workstation.UaClient.csproj +++ b/UaClient/Workstation.UaClient.csproj @@ -1,10 +1,10 @@  - netstandard2.0;netcoreapp3.1 + netstandard2.0;net6.0 Workstation.UaClient Workstation - 3.1.1 + 3.2.0 Andrew Cullen Converter Systems LLC https://github.com/convertersystems/opc-ua-client @@ -12,18 +12,18 @@ A library to browse, read, write and subscribe to the live data published by the OPC UA servers on your network. opc, opc-ua, iiot https://github.com/convertersystems/opc-ua-client - Copyright © 2021 Converter Systems LLC. - 3.1.1.0 + Copyright © 2023 Converter Systems LLC. + 3.2.0.0 Workstation.UaClient ($(TargetFramework)) true - 3.1.1.0 + 3.2.0.0 True Key.snk true true LICENSE.txt - 8.0 - enable + latest + enable @@ -35,14 +35,14 @@ - - + + - + - - - + + +