Skip to content

Commit

Permalink
Update packages
Browse files Browse the repository at this point in the history
  • Loading branch information
awcullen committed Jan 16, 2023
1 parent c9e05d8 commit 65ab757
Show file tree
Hide file tree
Showing 14 changed files with 106 additions and 105 deletions.
2 changes: 1 addition & 1 deletion UaClient.UnitTests/UnitTests/ArraySegmentExtensionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,27 @@
using Workstation.ServiceModel.Ua;
using Workstation.ServiceModel.Ua.Channels;
using Xunit;
using Newtonsoft.Json.Linq;

namespace Workstation.UaClient.UnitTests.Channels
{
public partial class BinaryDecoderTests
{
private abstract class TypeMappingEquivalency<TSubject, TExpectation> : 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);
Expand All @@ -45,7 +46,7 @@ protected override void Test(Guid subject, Opc.Ua.Uuid expectation, string becau
.Should().Be((Guid)expectation);
}
}

private class VariantEquivalency : TypeMappingEquivalency<Variant, Opc.Ua.Variant>
{
protected override void Test(Variant subject, Opc.Ua.Variant expectation, string because, object[] becauseArgs)
Expand Down Expand Up @@ -166,7 +167,7 @@ private class XmlEquivalency : TypeMappingEquivalency<XElement, XmlElement>
protected override void Test(XElement subject, XmlElement expectation, string because, object[] becauseArgs)
{
var xml = ToXmlNode(subject);

xml
.Should().BeEquivalentTo(expectation, because, becauseArgs);
}
Expand Down Expand Up @@ -201,7 +202,7 @@ static BinaryDecoderTests()

// NodeId
AssertionOptions.AssertEquivalencyUsing(options => options.Using(new NodeIdEquivalency()));

// ExpandedNodeId
AssertionOptions.AssertEquivalencyUsing(options => options.Using(new ExpandedNodeIdEquivalency()));

Expand All @@ -216,7 +217,7 @@ static BinaryDecoderTests()

// TimeZoneDataType
AssertionOptions.AssertEquivalencyUsing(options => options.ComparingByMembers<TimeZoneDataType>().ExcludingMissingMembers());

// Matrix/Multidim array
AssertionOptions.AssertEquivalencyUsing(options => options.Using(new MatrixEquivalency()));
}
Expand Down
4 changes: 2 additions & 2 deletions UaClient.UnitTests/UnitTests/Channels/BinaryDecoderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public void CreateWithNullStream()
{
Stream stream = null;

stream.Invoking(s => new BinaryDecoder(s))
.Should().Throw<ArgumentNullException>();
Action act = () => new BinaryDecoder(stream);
act.Should().Throw<ArgumentNullException>();
}

[InlineData(true)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,18 @@ public partial class BinaryEncoderTests
{
private abstract class TypeMappingEquivalency<TSubject, TExpectation> : 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);
Expand Down
4 changes: 2 additions & 2 deletions UaClient.UnitTests/UnitTests/Channels/BinaryEncoderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public void CreateWithNullStream()
{
Stream stream = null;

stream.Invoking(s => new BinaryEncoder(s))
.Should().Throw<ArgumentNullException>();
Action act = () => new BinaryEncoder(stream);
act.Should().Throw<ArgumentNullException>();
}

[InlineData(true)]
Expand Down
4 changes: 2 additions & 2 deletions UaClient.UnitTests/UnitTests/DictionaryStoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public void Constructor()
[Theory]
public void ConstructorNull(string dir)
{
dir.Invoking(d => new DirectoryStore(d))
.Should().Throw<ArgumentNullException>();
Action act = () => new DirectoryStore(dir);
act.Should().Throw<ArgumentNullException>();
}

[Fact]
Expand Down
4 changes: 2 additions & 2 deletions UaClient.UnitTests/UnitTests/ErrorsContainerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public void CreateNull()
{
Action<string> action = null;

action.Invoking(a => new ErrorsContainer<int>(a))
.Should().Throw<ArgumentNullException>();
Action act = () => new ErrorsContainer<int>(action);
act.Should().Throw<ArgumentNullException>();
}

[MemberData(nameof(TestProperties))]
Expand Down
8 changes: 4 additions & 4 deletions UaClient.UnitTests/UnitTests/ExpandedNodeIdTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ public static IEnumerable<object[]> BadParseData
[Theory]
public void NotParsable(string s)
{
s.Invoking(t => ExpandedNodeId.Parse(t))
.Should().Throw<ServiceResultException>()
Action act = () => ExpandedNodeId.Parse(s);
act.Should().Throw<ServiceResultException>()
.Which.HResult
.Should().Be(unchecked((int)StatusCodes.BadNodeIdInvalid));
}
Expand Down Expand Up @@ -366,8 +366,8 @@ public void ToNodeIdNull()
var nodeId = default(ExpandedNodeId);
var nsUris = new string[] { };

nodeId.Invoking(n => ExpandedNodeId.ToNodeId(n, nsUris))
.Should().Throw<ArgumentNullException>();
Action act = () => ExpandedNodeId.ToNodeId(nodeId, nsUris);
act.Should().Throw<ArgumentNullException>();
}
}
}
17 changes: 9 additions & 8 deletions UaClient.UnitTests/UnitTests/NodeIdTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public void CreateFromString()
public void CreateFromStringNull()
{
var id = default(string);
id.Invoking(i => new NodeId(i, 2))
.Should().Throw<ArgumentNullException>();
Action act = () => new NodeId(id, 2);
act.Should().Throw<ArgumentNullException>();
}

[Fact]
Expand Down Expand Up @@ -84,8 +84,9 @@ public void CreateFromOpaque()
public void CreateFromOpaqueNull()
{
var id = default(byte[]);
id.Invoking(i => new NodeId(i, 2))
.Should().Throw<ArgumentNullException>();
Action act = () => new NodeId(id, 2);

act.Should().Throw<ArgumentNullException>();
}

[Fact]
Expand Down Expand Up @@ -254,8 +255,8 @@ public static IEnumerable<object[]> BadParseData
[Theory]
public void NotParsable(string s)
{
s.Invoking(t => NodeId.Parse(t))
.Should().Throw<ServiceResultException>()
Action act = () => NodeId.Parse(s);
act.Should().Throw<ServiceResultException>()
.Which.HResult
.Should().Be(unchecked((int)StatusCodes.BadNodeIdInvalid));
}
Expand Down Expand Up @@ -302,8 +303,8 @@ public void ToExpandedNodeIdNull()
var nodeId = default(NodeId);
var nsUris = new string[] { };

nodeId.Invoking(n => NodeId.ToExpandedNodeId(n, nsUris))
.Should().Throw<ArgumentNullException>();
Action act = () => NodeId.ToExpandedNodeId(nodeId, nsUris);
act.Should().Throw<ArgumentNullException>();
}
}
}
8 changes: 4 additions & 4 deletions UaClient.UnitTests/UnitTests/QualifiedNameTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -112,7 +112,7 @@ public void Equality(QualifiedName a, QualifiedName b, bool shouldBeEqual)
.Should().NotBe(b.GetHashCode());
}
}

public static IEnumerable<object[]> EqualityNullData =>
QualifiedNames.Select(id => new[] { id() });

Expand Down Expand Up @@ -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<ArgumentException>();
Action act = () => QualifiedName.Parse(text);
act.Should().Throw<ArgumentException>();
}
}
}
8 changes: 4 additions & 4 deletions UaClient.UnitTests/UnitTests/ServiceExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public void ToVariantArrayNull()
{
var input = default(object[]);

input.Invoking(i => i.ToVariantArray())
.Should().Throw<ArgumentNullException>();
Action act = () => input.ToVariantArray();
act.Should().Throw<ArgumentNullException>();
}

[Fact]
Expand Down Expand Up @@ -73,8 +73,8 @@ public void ToObjectArrayNull()
{
var input = default(Variant[]);

input.Invoking(i => i.ToObjectArray())
.Should().Throw<ArgumentNullException>();
Action act = () => input.ToObjectArray();
act.Should().Throw<ArgumentNullException>();
}

[Fact]
Expand Down
Loading

0 comments on commit 65ab757

Please sign in to comment.