├── .github
└── workflows
│ └── dotnet.yml
├── .gitignore
├── CustomTypeLibrary
├── CustomTypeLibrary.csproj
└── CustomVector.cs
├── LICENSE.txt
├── README.md
├── UaClient.UnitTests
├── ITestCertificateStore.cs
├── IntegrationTests
│ └── IntegrationTests.cs
├── LICENSE.txt
├── TestCertificateStore.cs
├── TestException.cs
├── ThrowingTestCertificateStore.cs
├── UnitTests
│ ├── ArraySegmentExtensionTests.cs
│ ├── Channels
│ │ ├── BinaryDecoderTests.Equivalency.cs
│ │ ├── BinaryDecoderTests.cs
│ │ ├── BinaryEncoderTests.Equivalency.cs
│ │ ├── BinaryEncoderTests.cs
│ │ ├── CommunicationObjectTests.cs
│ │ ├── UaSecureConversationTests.Data.cs
│ │ └── UaSecureConversationTests.cs
│ ├── DataTypeIdAttributeTests.cs
│ ├── DataValueExtensionTests.cs
│ ├── DataValueTests.cs
│ ├── DictionaryStoreTests.cs
│ ├── ErrorsContainerTests.cs
│ ├── ExpandedNodeIdTests.cs
│ ├── ExtensionObjectTests.cs
│ ├── IssuedIdentityTests.cs
│ ├── LocalizedTextTests.cs
│ ├── MonitoredItemAttributeTests.cs
│ ├── NodeIdTests.cs
│ ├── ObservableQueueTests.cs
│ ├── QualifiedNameTests.cs
│ ├── ServiceExtensionsTests.cs
│ ├── ServiceResultTests.cs
│ ├── ServiceSetTests.cs
│ ├── StatusCodeTests.cs
│ ├── TypeLibraryTests.cs
│ ├── UaApplicationOptionsTests.cs
│ ├── UserNameIdentityTests.cs
│ ├── VariantTests.cs
│ ├── X509IdentityTests.cs
│ └── XmlEncodingIdAttributeTests.cs
├── Workstation.UaClient.UnitTests.csproj
├── appSettings.json
└── coverlet.runsettings
├── UaClient
├── Collections
│ ├── ErrorsContainer.cs
│ └── ObservableQueue.cs
├── Internal
│ └── System.Diagnostics.CodeAnalysis.cs
├── Key.snk
├── ServiceModel
│ └── Ua
│ │ ├── AccessLevelFlags.cs
│ │ ├── AcknowledgeableCondition.cs
│ │ ├── AlarmCondition.cs
│ │ ├── AnonymousIdentity.cs
│ │ ├── ArraySegmentExtensions.cs
│ │ ├── AttributeIds.generated.cs
│ │ ├── AttributeIds.tt
│ │ ├── AttributeServiceSet.cs
│ │ ├── BaseEvent.cs
│ │ ├── BinaryEncodingIdAttribute.cs
│ │ ├── ByteSequenceComparer.cs
│ │ ├── Channels
│ │ ├── BinaryDecoder.cs
│ │ ├── BinaryEncoder.cs
│ │ ├── BinaryEncodingProvider.cs
│ │ ├── ClientSecureChannel.cs
│ │ ├── ClientSessionChannel.cs
│ │ ├── ClientTransportChannel.cs
│ │ ├── CommunicationObject.cs
│ │ ├── EncodingContext.cs
│ │ ├── MessageTypes.cs
│ │ ├── ServiceOperation.cs
│ │ ├── StackProfile.cs
│ │ ├── StackProfiles.cs
│ │ ├── UaClientConnection.cs
│ │ ├── UaSecureConversation.cs
│ │ ├── UaSecureConversationProvider.cs
│ │ └── UaTcpConnectionProvider.cs
│ │ ├── CommunicationsState.cs
│ │ ├── Condition.cs
│ │ ├── DataTypeIdAttribute.cs
│ │ ├── DataValue.cs
│ │ ├── DataValueExtensions.cs
│ │ ├── DiagnosticFlags.cs
│ │ ├── DiagnosticInfo.cs
│ │ ├── DirectoryStore.cs
│ │ ├── DiscoveryService.cs
│ │ ├── EventFieldAttribute.cs
│ │ ├── EventHelper.cs
│ │ ├── EventNotifierFlags.cs
│ │ ├── ExpandedNodeId.cs
│ │ ├── ExtensionObject.cs
│ │ ├── ICertificateStore.cs
│ │ ├── ICommunicationObject.cs
│ │ ├── IConversation.cs
│ │ ├── IConversationProvider.cs
│ │ ├── IDecoder.cs
│ │ ├── IEncodable.cs
│ │ ├── IEncoder.cs
│ │ ├── IEncodingProvider.cs
│ │ ├── IOptionalFields.cs
│ │ ├── IRequestChannel.cs
│ │ ├── IServiceRequest.cs
│ │ ├── IServiceResponse.cs
│ │ ├── ISetDataErrorInfo.cs
│ │ ├── ITransportConnection.cs
│ │ ├── ITransportConnectionProvider.cs
│ │ ├── IUserIdentity.cs
│ │ ├── IssuedIdentity.cs
│ │ ├── LocalizedText.cs
│ │ ├── MappedEndpoint.cs
│ │ ├── MethodServiceSet.cs
│ │ ├── MonitoredItemAttribute.cs
│ │ ├── MonitoredItemBase.cs
│ │ ├── MonitoredItemCollection.cs
│ │ ├── MonitoredItemServiceSet.cs
│ │ ├── NodeId.cs
│ │ ├── NodeIds.generated.cs
│ │ ├── NodeIds.tt
│ │ ├── NodeManagementServiceSet.cs
│ │ ├── QualifiedName.cs
│ │ ├── QueryServiceSet.cs
│ │ ├── Schema
│ │ ├── AttributeIds.csv
│ │ ├── NodeIds.csv
│ │ ├── StatusCodes.csv
│ │ └── Types.xsd
│ │ ├── SecurityPolicyUris.cs
│ │ ├── ServiceExtensions.cs
│ │ ├── ServiceResult.cs
│ │ ├── ServiceResultException.cs
│ │ ├── SessionServiceSet.cs
│ │ ├── StatusCode.cs
│ │ ├── StatusCodes.generated.cs
│ │ ├── StatusCodes.tt
│ │ ├── Structure.cs
│ │ ├── SubscriptionAttribute.cs
│ │ ├── SubscriptionBase.cs
│ │ ├── SubscriptionServiceSet.cs
│ │ ├── TransportConnectionOptions.cs
│ │ ├── TransportProfileUris.cs
│ │ ├── TypeLibrary.cs
│ │ ├── Types.generated.cs
│ │ ├── Types.tt
│ │ ├── UaApplication.cs
│ │ ├── UaApplicationBuilder.cs
│ │ ├── UaApplicationOptions.cs
│ │ ├── UserNameIdentity.cs
│ │ ├── Variant.cs
│ │ ├── VariantExtensions.cs
│ │ ├── ViewServiceSet.cs
│ │ ├── X509Identity.cs
│ │ └── XmlEncodingIdAttribute.cs
├── Workstation.UaClient.csproj
└── stylecop.json
├── _config.yml
├── opc-ua-client.sln
└── robot6.jpg
/.github/workflows/dotnet.yml:
--------------------------------------------------------------------------------
1 | # This workflow will build a .NET project
2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
3 |
4 | name: .NET
5 |
6 | on:
7 | push:
8 | branches: [ "master" ]
9 | pull_request:
10 | branches: [ "master" ]
11 |
12 | jobs:
13 | build:
14 |
15 | runs-on: ubuntu-latest
16 |
17 | steps:
18 | - uses: actions/checkout@v3
19 | - name: Setup .NET
20 | uses: actions/setup-dotnet@v3
21 | with:
22 | dotnet-version: 6.0.x
23 | - name: Restore dependencies
24 | run: dotnet restore
25 | - name: Build
26 | run: dotnet build --no-restore
27 | - name: Test
28 | run: dotnet test --no-build --verbosity normal --filter FullyQualifiedName!~Workstation.UaClient.IntegrationTests
29 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | build/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studo 2015 cache/options directory
26 | .vs/
27 |
28 | # MSTest test Results
29 | [Tt]est[Rr]esult*/
30 | [Bb]uild[Ll]og.*
31 |
32 | # NUNIT
33 | *.VisualState.xml
34 | TestResult.xml
35 |
36 | # Build Results of an ATL Project
37 | [Dd]ebugPS/
38 | [Rr]eleasePS/
39 | dlldata.c
40 |
41 | *_i.c
42 | *_p.c
43 | *_i.h
44 | *.ilk
45 | *.meta
46 | *.obj
47 | *.pch
48 | *.pdb
49 | *.pgc
50 | *.pgd
51 | *.rsp
52 | *.sbr
53 | *.tlb
54 | *.tli
55 | *.tlh
56 | *.tmp
57 | *.tmp_proj
58 | *.log
59 | *.vspscc
60 | *.vssscc
61 | .builds
62 | *.pidb
63 | *.svclog
64 | *.scc
65 |
66 | # Chutzpah Test files
67 | _Chutzpah*
68 |
69 | # Visual C++ cache files
70 | ipch/
71 | *.aps
72 | *.ncb
73 | *.opensdf
74 | *.sdf
75 | *.cachefile
76 |
77 | # Visual Studio profiler
78 | *.psess
79 | *.vsp
80 | *.vspx
81 |
82 | # TFS 2012 Local Workspace
83 | $tf/
84 |
85 | # Guidance Automation Toolkit
86 | *.gpState
87 |
88 | # ReSharper is a .NET coding add-in
89 | _ReSharper*/
90 | *.[Rr]e[Ss]harper
91 | *.DotSettings.user
92 |
93 | # JustCode is a .NET coding addin-in
94 | .JustCode
95 |
96 | # TeamCity is a build add-in
97 | _TeamCity*
98 |
99 | # DotCover is a Code Coverage Tool
100 | *.dotCover
101 |
102 | # NCrunch
103 | _NCrunch_*
104 | .*crunch*.local.xml
105 |
106 | # MightyMoose
107 | *.mm.*
108 | AutoTest.Net/
109 |
110 | # Web workbench (sass)
111 | .sass-cache/
112 |
113 | # Installshield output folder
114 | [Ee]xpress/
115 |
116 | # DocProject is a documentation generator add-in
117 | DocProject/buildhelp/
118 | DocProject/Help/*.HxT
119 | DocProject/Help/*.HxC
120 | DocProject/Help/*.hhc
121 | DocProject/Help/*.hhk
122 | DocProject/Help/*.hhp
123 | DocProject/Help/Html2
124 | DocProject/Help/html
125 |
126 | # Click-Once directory
127 | publish/
128 |
129 | # Publish Web Output
130 | *.[Pp]ublish.xml
131 | *.azurePubxml
132 | # TODO: Comment the next line if you want to checkin your web deploy settings
133 | # but database connection strings (with potential passwords) will be unencrypted
134 | *.pubxml
135 | *.publishproj
136 |
137 | # NuGet Packages
138 | *.nupkg
139 | # The packages folder can be ignored because of Package Restore
140 | **/packages/*
141 | # except build/, which is used as an MSBuild target.
142 | !**/packages/build/
143 | # Uncomment if necessary however generally it will be regenerated when needed
144 | #!**/packages/repositories.config
145 | *.nuget.props
146 | *.nuget.targets
147 | *.lock.json
148 |
149 | # Windows Azure Build Output
150 | csx/
151 | *.build.csdef
152 |
153 | # Windows Store app package directory
154 | AppPackages/
155 |
156 | # Others
157 | *.[Cc]ache
158 | ClientBin/
159 | #[Ss]tyle[Cc]op.*
160 | ~$*
161 | *~
162 | *.dbmdl
163 | *.dbproj.schemaview
164 | *.pfx
165 | *.publishsettings
166 | node_modules/
167 | bower_components/
168 |
169 | # RIA/Silverlight projects
170 | Generated_Code/
171 |
172 | # Backup & report files from converting an old project file
173 | # to a newer Visual Studio version. Backup files are not needed,
174 | # because we have git ;-)
175 | _UpgradeReport_Files/
176 | Backup*/
177 | UpgradeLog*.XML
178 | UpgradeLog*.htm
179 |
180 | # SQL Server files
181 | *.mdf
182 | *.ldf
183 |
184 | # Business Intelligence projects
185 | *.rdl.data
186 | *.bim.layout
187 | *.bim_*.settings
188 |
189 | # Microsoft Fakes
190 | FakesAssemblies/
191 |
192 | # Node.js Tools for Visual Studio
193 | .ntvs_analysis.dat
194 |
195 | # Visual Studio 6 build log
196 | *.plg
197 |
198 | # Visual Studio 6 workspace options file
199 | *.opt
200 | /UaClient/Workstation.UaClient.xml
201 | project.lock.json
202 | /UaClient.UnitTests/UnitTest1 - Copy.cs
203 |
--------------------------------------------------------------------------------
/CustomTypeLibrary/CustomTypeLibrary.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/CustomTypeLibrary/CustomVector.cs:
--------------------------------------------------------------------------------
1 |
2 | using System;
3 | using Workstation.ServiceModel.Ua;
4 |
5 | [assembly: TypeLibrary()]
6 | namespace CustomTypeLibrary
7 | {
8 | [DataTypeId("nsu=http://www.unifiedautomation.com/DemoServer/;i=3002")]
9 | [BinaryEncodingId("nsu=http://www.unifiedautomation.com/DemoServer/;i=5054")]
10 | public class CustomVector : Structure
11 | {
12 | public double X { get; set; }
13 | public double Y { get; set; }
14 | public double Z { get; set; }
15 | public override void Encode(IEncoder encoder)
16 | {
17 | encoder.WriteDouble("X", X);
18 | encoder.WriteDouble("Y", Y);
19 | encoder.WriteDouble("Z", Z);
20 | }
21 | public override void Decode(IDecoder decoder)
22 | {
23 | X = decoder.ReadDouble("X");
24 | Y = decoder.ReadDouble("Y");
25 | Z = decoder.ReadDouble("Z");
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Converter Systems LLC
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/UaClient.UnitTests/ITestCertificateStore.cs:
--------------------------------------------------------------------------------
1 | using Workstation.ServiceModel.Ua;
2 |
3 | namespace Workstation.UaClient
4 | {
5 | public interface ITestCertificateStore : ICertificateStore
6 | {
7 | byte[] ServerCertificate { get; }
8 | byte[] ClientCertificate { get; }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/UaClient.UnitTests/LICENSE.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Converter Systems LLC
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/UaClient.UnitTests/TestException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Runtime.Serialization;
4 | using System.Text;
5 |
6 | namespace Workstation.UaClient
7 | {
8 | public sealed class TestException : Exception
9 | {
10 | public TestException()
11 | {
12 | }
13 |
14 | public TestException(string message) : base(message)
15 | {
16 | }
17 |
18 | public TestException(string message, Exception innerException) : base(message, innerException)
19 | {
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/UaClient.UnitTests/ThrowingTestCertificateStore.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.Logging;
2 | using Org.BouncyCastle.Crypto.Parameters;
3 | using Org.BouncyCastle.X509;
4 | using System;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 | using Workstation.ServiceModel.Ua;
8 |
9 | namespace Workstation.UaClient
10 | {
11 | public class ThrowingTestCertificateStore : ITestCertificateStore
12 | {
13 | public byte[] ServerCertificate => null;
14 |
15 | public byte[] ClientCertificate => null;
16 |
17 | public Task<(X509Certificate Certificate, RsaKeyParameters Key)> GetLocalCertificateAsync(ApplicationDescription applicationDescription, ILogger logger, CancellationToken token)
18 | => throw new NotImplementedException();
19 |
20 | public Task ValidateRemoteCertificateAsync(X509Certificate certificate, ILogger logger, CancellationToken token)
21 | => throw new NotImplementedException();
22 | }
23 | }
--------------------------------------------------------------------------------
/UaClient.UnitTests/UnitTests/ArraySegmentExtensionTests.cs:
--------------------------------------------------------------------------------
1 | using FluentAssertions;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using Workstation.ServiceModel.Ua;
7 | using Xunit;
8 |
9 | namespace Workstation.UaClient.UnitTests
10 | {
11 | public class ArraySegmentExtensionTests
12 | {
13 | [Fact]
14 | public void AsArraySegment1()
15 | {
16 | var array = new int[] { 1, 2, 3, 4, 5 };
17 |
18 | array.AsArraySegment()
19 | .Should().BeEquivalentTo(array);
20 | }
21 |
22 | [Fact]
23 | public void AsArraySegmentWithOffset()
24 | {
25 | var array = new int[] { 1, 2, 3, 4, 5 };
26 |
27 | array.AsArraySegment(1)
28 | .Should().BeEquivalentTo(array.Skip(1));
29 | }
30 |
31 | [Fact]
32 | public void AsArraySegmentWithOffsetAndCount()
33 | {
34 | var array = new int[] { 1, 2, 3, 4, 5 };
35 |
36 | array.AsArraySegment(1, 3)
37 | .Should().BeEquivalentTo(array.Skip(1).Take(3));
38 | }
39 |
40 | [Fact]
41 | public void CreateStream()
42 | {
43 | var array = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
44 |
45 | using (var stream = ArraySegmentExtensions.CreateStream(array))
46 | {
47 | var buffer = new byte[array.Length];
48 |
49 | stream.Length
50 | .Should().Be(array.Length);
51 |
52 | stream.Read(buffer, 0, buffer.Length);
53 |
54 | buffer
55 | .Should().BeEquivalentTo(array);
56 | }
57 | }
58 |
59 | [Fact]
60 | public void CreateBinaryReader()
61 | {
62 | var array = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
63 |
64 | using (var reader = ArraySegmentExtensions.CreateBinaryReader(array))
65 | {
66 | foreach (var b in array)
67 | {
68 | reader.ReadByte()
69 | .Should().Be(b);
70 | }
71 | }
72 | }
73 |
74 | [Fact]
75 | public void CreateBinaryWriter()
76 | {
77 | var array = new byte[10];
78 |
79 | using (var writer = ArraySegmentExtensions.CreateBinaryWriter(array))
80 | {
81 | for (byte b = 0; b < array.Length; b++)
82 | {
83 | writer.Write(b);
84 | }
85 |
86 | array
87 | .Should().BeEquivalentTo(new byte[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
88 | }
89 | }
90 |
91 | [Fact]
92 | public void Take()
93 | {
94 | var array = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
95 |
96 | array.AsArraySegment().Take(3)
97 | .Should().BeEquivalentTo(array.Take(3));
98 | }
99 |
100 | [Fact]
101 | public void Skip()
102 | {
103 | var array = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
104 |
105 | array.AsArraySegment().Skip(3)
106 | .Should().BeEquivalentTo(array.Skip(3));
107 | }
108 |
109 | [Fact]
110 | public void Slice()
111 | {
112 | var array = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
113 |
114 | array.AsArraySegment().Slice(3, 4)
115 | .Should().BeEquivalentTo(array.Skip(3).Take(4));
116 | }
117 |
118 | [Fact]
119 | public void TakeLast()
120 | {
121 | var array = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
122 |
123 | array.AsArraySegment().TakeLast(3)
124 | .Should().BeEquivalentTo(array.TakeLast(3));
125 | }
126 |
127 | [Fact]
128 | public void SkipLast()
129 | {
130 | var array = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
131 |
132 | array.AsArraySegment().SkipLast(3)
133 | .Should().BeEquivalentTo(array.SkipLast(3));
134 | }
135 |
136 | [Fact]
137 | public void CopyToArraySegment()
138 | {
139 | var array = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
140 | var input = array.AsArraySegment(2, 5);
141 | var output = new byte[10].AsArraySegment(4, 4);
142 |
143 | ArraySegmentExtensions.CopyTo(input, output);
144 |
145 | output
146 | .Should().BeEquivalentTo(input.SkipLast(1));
147 | }
148 |
149 | [Fact]
150 | public void CopyToArray()
151 | {
152 | var array = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
153 | var input = array.AsArraySegment(2, 5);
154 | var output = new byte[10];
155 |
156 | ArraySegmentExtensions.CopyTo(input, output);
157 |
158 | output.Take(5)
159 | .Should().BeEquivalentTo(input);
160 | }
161 |
162 | [Fact]
163 | public void ToArray()
164 | {
165 | var array = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
166 | var input = array.AsArraySegment(2, 5);
167 |
168 | var output = ArraySegmentExtensions.ToArray(input);
169 |
170 | output
171 | .Should().BeEquivalentTo(input);
172 | }
173 | }
174 | }
175 |
--------------------------------------------------------------------------------
/UaClient.UnitTests/UnitTests/DataTypeIdAttributeTests.cs:
--------------------------------------------------------------------------------
1 | using FluentAssertions;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 | using Workstation.ServiceModel.Ua;
6 | using Xunit;
7 |
8 | namespace Workstation.UaClient.UnitTests
9 | {
10 | public class DataTypeIdAttributeTests
11 | {
12 | public static IEnumerable