Moving structure as preparation for docs
This commit is contained in:
@@ -22,8 +22,7 @@ build-debug:
|
||||
script:
|
||||
- shopt -s globstar
|
||||
- mkdir ./artifacts
|
||||
- dotnet restore --no-cache --force
|
||||
- dotnet build -c Debug --nologo --no-restore --no-incremental
|
||||
- dotnet build -c Debug --nologo
|
||||
- mv ./**/*.nupkg ./artifacts/
|
||||
- mv ./**/*.snupkg ./artifacts/
|
||||
artifacts:
|
||||
@@ -65,7 +64,7 @@ deploy-debug:
|
||||
tags:
|
||||
- docker
|
||||
- lnx
|
||||
- 64bit
|
||||
- server
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG == null
|
||||
script:
|
||||
@@ -84,8 +83,7 @@ build-release:
|
||||
script:
|
||||
- shopt -s globstar
|
||||
- mkdir ./artifacts
|
||||
- dotnet restore --no-cache --force
|
||||
- dotnet build -c Release --nologo --no-restore --no-incremental
|
||||
- dotnet build -c Release --nologo
|
||||
- mv ./**/*.nupkg ./artifacts/
|
||||
- mv ./**/*.snupkg ./artifacts/
|
||||
artifacts:
|
||||
@@ -104,7 +102,6 @@ test-release:
|
||||
- amd64
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG != null
|
||||
coverage: /Branch coverage[\s\S].+%/
|
||||
before_script:
|
||||
- dotnet tool install dotnet-reportgenerator-globaltool --tool-path /dotnet-tools
|
||||
script:
|
||||
@@ -127,7 +124,7 @@ deploy-release:
|
||||
tags:
|
||||
- docker
|
||||
- lnx
|
||||
- 64bit
|
||||
- server
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG != null
|
||||
script:
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>
|
||||
|
||||
<PackageId>AMWD.Protocols.Modbus.Tcp</PackageId>
|
||||
<AssemblyName>amwd-modbus-tcp</AssemblyName>
|
||||
<RootNamespace>AMWD.Protocols.Modbus.Tcp</RootNamespace>
|
||||
|
||||
<Product>Modbus TCP Protocol</Product>
|
||||
<Description>Implementation of the Modbus protocol communicating via TCP.</Description>
|
||||
<PackageTags>Modbus Protocol Network TCP LAN</PackageTags>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="$(SolutionDir)/AMWD.Protocols.Modbus.Common/Extensions/ArrayExtensions.cs" Link="Extensions/ArrayExtensions.cs" />
|
||||
<Compile Include="$(SolutionDir)/AMWD.Protocols.Modbus.Common/Extensions/ReaderWriterLockSlimExtensions.cs" Link="Extensions/ReaderWriterLockSlimExtensions.cs" />
|
||||
<Compile Include="$(SolutionDir)/AMWD.Protocols.Modbus.Common/Utils/AsyncQueue.cs" Link="Utils/AsyncQueue.cs" />
|
||||
<Compile Include="$(SolutionDir)/AMWD.Protocols.Modbus.Common/Utils/RequestQueueItem.cs" Link="Utils/RequestQueueItem.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="README.md" Pack="true" PackagePath="/" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="$(SolutionDir)\AMWD.Protocols.Modbus.Common\AMWD.Protocols.Modbus.Common.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,32 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
<CollectCoverage>true</CollectCoverage>
|
||||
<CoverletOutputFormat>Cobertura</CoverletOutputFormat>
|
||||
|
||||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
|
||||
<GenerateDocumentationFile>false</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.msbuild" Version="6.0.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
|
||||
<PackageReference Include="Moq" Version="4.20.72" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.7.2" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="3.7.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="$(SolutionDir)\AMWD.Protocols.Modbus.Common\AMWD.Protocols.Modbus.Common.csproj" />
|
||||
<ProjectReference Include="$(SolutionDir)\AMWD.Protocols.Modbus.Serial\AMWD.Protocols.Modbus.Serial.csproj" />
|
||||
<ProjectReference Include="$(SolutionDir)\AMWD.Protocols.Modbus.Tcp\AMWD.Protocols.Modbus.Tcp.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,5 +0,0 @@
|
||||
global using System;
|
||||
global using System.Linq;
|
||||
global using AMWD.Protocols.Modbus.Common;
|
||||
global using AMWD.Protocols.Modbus.Common.Contracts;
|
||||
global using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
@@ -1,9 +0,0 @@
|
||||
DeviceIdentification
|
||||
VendorName: VendorName
|
||||
ProductCode: ProductCode
|
||||
MajorMinorRevision: MajorMinorRevision
|
||||
VendorUrl:
|
||||
ProductName:
|
||||
ModelName:
|
||||
UserApplicationName:
|
||||
IsIndividualAccessAllowed: False
|
||||
@@ -1,8 +0,0 @@
|
||||
Serial Client COM-42
|
||||
BaudRate: 2400
|
||||
DataBits: 7
|
||||
StopBits: 1.5
|
||||
Parity: space
|
||||
Handshake: xonxoff
|
||||
RtsEnable: true
|
||||
DriverEnabledRS485: true
|
||||
@@ -1,2 +0,0 @@
|
||||
TCP Client 127.0.0.1
|
||||
Port: 502
|
||||
@@ -1,9 +0,0 @@
|
||||
DeviceIdentification
|
||||
VendorName: VendorName
|
||||
ProductCode: ProductCode
|
||||
MajorMinorRevision: MajorMinorRevision
|
||||
VendorUrl:
|
||||
ProductName:
|
||||
ModelName:
|
||||
UserApplicationName:
|
||||
IsIndividualAccessAllowed: False
|
||||
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.8.34525.116
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AMWD.Protocols.Modbus.Common", "AMWD.Protocols.Modbus.Common\AMWD.Protocols.Modbus.Common.csproj", "{2B7689D8-9E56-4DEB-B40E-F70DB4A6F250}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AMWD.Protocols.Modbus.Common", "src\AMWD.Protocols.Modbus.Common\AMWD.Protocols.Modbus.Common.csproj", "{2B7689D8-9E56-4DEB-B40E-F70DB4A6F250}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0C43172F-63F3-455A-A5FC-CAE7492A969B}"
|
||||
EndProject
|
||||
@@ -29,15 +29,30 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{C8065AE3
|
||||
Directory.Build.props = Directory.Build.props
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AMWD.Protocols.Modbus.Tests", "AMWD.Protocols.Modbus.Tests\AMWD.Protocols.Modbus.Tests.csproj", "{146070C4-E922-4F5A-AD6F-9A899186E26E}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AMWD.Protocols.Modbus.Tests", "test\AMWD.Protocols.Modbus.Tests\AMWD.Protocols.Modbus.Tests.csproj", "{146070C4-E922-4F5A-AD6F-9A899186E26E}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AMWD.Protocols.Modbus.Tcp", "AMWD.Protocols.Modbus.Tcp\AMWD.Protocols.Modbus.Tcp.csproj", "{8C888A84-CD09-4087-B5DA-67708ABBABA2}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AMWD.Protocols.Modbus.Tcp", "src\AMWD.Protocols.Modbus.Tcp\AMWD.Protocols.Modbus.Tcp.csproj", "{8C888A84-CD09-4087-B5DA-67708ABBABA2}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AMWD.Protocols.Modbus.Serial", "AMWD.Protocols.Modbus.Serial\AMWD.Protocols.Modbus.Serial.csproj", "{D966826F-EE6C-4BC0-9185-C2A9A50FD586}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AMWD.Protocols.Modbus.Serial", "src\AMWD.Protocols.Modbus.Serial\AMWD.Protocols.Modbus.Serial.csproj", "{D966826F-EE6C-4BC0-9185-C2A9A50FD586}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CliClient", "CliClient\CliClient.csproj", "{B0E53462-B0ED-4685-8AA5-948DC160EE27}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CliClient", "tool\CliClient\CliClient.csproj", "{B0E53462-B0ED-4685-8AA5-948DC160EE27}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CliProxy", "CliProxy\CliProxy.csproj", "{AC922E80-E9B6-493D-B1D1-752527E883ED}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CliProxy", "tool\CliProxy\CliProxy.csproj", "{AC922E80-E9B6-493D-B1D1-752527E883ED}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
src\Directory.Build.props = src\Directory.Build.props
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{0C2CC421-9808-4CA2-BEA8-11493467DBCE}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
test\Directory.Build.props = test\Directory.Build.props
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tool", "tool", "{3429CE19-211E-4AFA-9629-D7E1A360B7AC}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
tool\Directory.Build.props = tool\Directory.Build.props
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -74,9 +89,15 @@ Global
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{2B7689D8-9E56-4DEB-B40E-F70DB4A6F250} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
|
||||
{A5A9AEA2-3AFF-4536-9FF9-34663DA4D0AD} = {0C43172F-63F3-455A-A5FC-CAE7492A969B}
|
||||
{2ED08B2B-1F72-4E1E-9586-1DC6BEFD7BA7} = {0C43172F-63F3-455A-A5FC-CAE7492A969B}
|
||||
{C8065AE3-BA87-49AC-8100-C85D6DF7E436} = {0C43172F-63F3-455A-A5FC-CAE7492A969B}
|
||||
{146070C4-E922-4F5A-AD6F-9A899186E26E} = {0C2CC421-9808-4CA2-BEA8-11493467DBCE}
|
||||
{8C888A84-CD09-4087-B5DA-67708ABBABA2} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
|
||||
{D966826F-EE6C-4BC0-9185-C2A9A50FD586} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
|
||||
{B0E53462-B0ED-4685-8AA5-948DC160EE27} = {3429CE19-211E-4AFA-9629-D7E1A360B7AC}
|
||||
{AC922E80-E9B6-493D-B1D1-752527E883ED} = {3429CE19-211E-4AFA-9629-D7E1A360B7AC}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {E4FD8EF0-3594-4994-BE80-5FADA5EE17B4}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
|
||||
<AssemblyName>modbus-client</AssemblyName>
|
||||
<RootNamespace>AMWD.Protocols.Modbus.CliClient</RootNamespace>
|
||||
|
||||
<Product>Modbus CLI client</Product>
|
||||
<Description>Small CLI client for Modbus communication.</Description>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<SignAssembly>false</SignAssembly>
|
||||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
|
||||
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="$(SolutionDir)/package-icon.png" />
|
||||
<None Remove="$(SolutionDir)/LICENSE.txt" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.IO.Ports" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="$(SolutionDir)\AMWD.Protocols.Modbus.Serial\AMWD.Protocols.Modbus.Serial.csproj" />
|
||||
<ProjectReference Include="$(SolutionDir)\AMWD.Protocols.Modbus.Tcp\AMWD.Protocols.Modbus.Tcp.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,34 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
|
||||
<AssemblyName>modbus-proxy</AssemblyName>
|
||||
<RootNamespace>AMWD.Protocols.Modbus.CliProxy</RootNamespace>
|
||||
|
||||
<Product>Modbus CLI proxy</Product>
|
||||
<Description>Small CLI proxy to forward messages.</Description>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<SignAssembly>false</SignAssembly>
|
||||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
|
||||
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="$(SolutionDir)/package-icon.png" />
|
||||
<None Remove="$(SolutionDir)/LICENSE.txt" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.IO.Ports" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="$(SolutionDir)\AMWD.Protocols.Modbus.Serial\AMWD.Protocols.Modbus.Serial.csproj" />
|
||||
<ProjectReference Include="$(SolutionDir)\AMWD.Protocols.Modbus.Tcp\AMWD.Protocols.Modbus.Tcp.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -3,60 +3,18 @@
|
||||
<LangVersion>12.0</LangVersion>
|
||||
<NrtRevisionFormat>{semvertag:main}{!:-dev}</NrtRevisionFormat>
|
||||
|
||||
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
|
||||
<CopyRefAssembliesToPublishDirectory>false</CopyRefAssembliesToPublishDirectory>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<RepositoryUrl>https://github.com/AM-WD/AMWD.Protocols.Modbus.git</RepositoryUrl>
|
||||
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
||||
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<IncludeSymbols>true</IncludeSymbols>
|
||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||
<EmbedUntrackedSources>false</EmbedUntrackedSources>
|
||||
|
||||
<PackageIcon>package-icon.png</PackageIcon>
|
||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
|
||||
|
||||
<Title>Modbus Protocol for .NET</Title>
|
||||
<Company>AM.WD</Company>
|
||||
<Authors>Andreas Müller</Authors>
|
||||
<Copyright>© {copyright:2018-} AM.WD</Copyright>
|
||||
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>$(SolutionDir)/AMWD.Protocols.Modbus.snk</AssemblyOriginatorKeyFile>
|
||||
<PublicKey>0024000004800000940000000602000000240000525341310004000001000100adcc4f9f5bb3ac73cb30661f6f35772b8f90a74412925764a960af06ef125bdcec05ed1d139503d5203fb72aa3fa74bab58e82ac2a6cd4b650f8cbf7086a71bc2dfc67e95b8d26d776d60856acf3121f831529b1a4dee91b34ac84f95f71a1165b7783edb591929ba2a684100c92bbed8859c7266fb507f6f55bb6f7fcac80b4</PublicKey>
|
||||
<MoqPublicKey>0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7</MoqPublicKey>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(GITLAB_CI)' == 'true'">
|
||||
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(SignAssembly)' != 'true'">
|
||||
<InternalsVisibleTo Include="AMWD.Protocols.Modbus.Tests" />
|
||||
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(SignAssembly)' == 'true'">
|
||||
<InternalsVisibleTo Include="AMWD.Protocols.Modbus.Tests" PublicKey="0024000004800000940000000602000000240000525341310004000001000100adcc4f9f5bb3ac73cb30661f6f35772b8f90a74412925764a960af06ef125bdcec05ed1d139503d5203fb72aa3fa74bab58e82ac2a6cd4b650f8cbf7086a71bc2dfc67e95b8d26d776d60856acf3121f831529b1a4dee91b34ac84f95f71a1165b7783edb591929ba2a684100c92bbed8859c7266fb507f6f55bb6f7fcac80b4" />
|
||||
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" PublicKey="0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(GITLAB_CI)' == 'true'">
|
||||
<SourceLinkGitLabHost Include="$(CI_SERVER_HOST)" Version="$(CI_SERVER_VERSION)" />
|
||||
<PackageReference Include="Microsoft.SourceLink.GitLab" Version="8.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="$(SolutionDir)/package-icon.png" Pack="true" PackagePath="/" />
|
||||
<None Include="$(SolutionDir)/LICENSE.txt" Pack="true" PackagePath="/" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AMWD.NetRevisionTask" Version="1.2.1">
|
||||
<PackageReference Include="AMWD.NetRevisionTask" Version="1.3.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>
|
||||
|
||||
<PackageId>AMWD.Protocols.Modbus.Common</PackageId>
|
||||
<AssemblyName>amwd-modbus-common</AssemblyName>
|
||||
<RootNamespace>AMWD.Protocols.Modbus.Common</RootNamespace>
|
||||
@@ -12,8 +10,4 @@
|
||||
<PackageTags>Modbus Protocol</PackageTags>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="README.md" Pack="true" PackagePath="/" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,8 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>
|
||||
|
||||
<PackageId>AMWD.Protocols.Modbus.Serial</PackageId>
|
||||
<AssemblyName>amwd-modbus-serial</AssemblyName>
|
||||
<RootNamespace>AMWD.Protocols.Modbus.Serial</RootNamespace>
|
||||
@@ -13,14 +11,10 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="$(SolutionDir)/AMWD.Protocols.Modbus.Common/Extensions/ArrayExtensions.cs" Link="Extensions/ArrayExtensions.cs" />
|
||||
<Compile Include="$(SolutionDir)/AMWD.Protocols.Modbus.Common/Extensions/ReaderWriterLockSlimExtensions.cs" Link="Extensions/ReaderWriterLockSlimExtensions.cs" />
|
||||
<Compile Include="$(SolutionDir)/AMWD.Protocols.Modbus.Common/Utils/AsyncQueue.cs" Link="Utils/AsyncQueue.cs" />
|
||||
<Compile Include="$(SolutionDir)/AMWD.Protocols.Modbus.Common/Utils/RequestQueueItem.cs" Link="Utils/RequestQueueItem.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="README.md" Pack="true" PackagePath="/" />
|
||||
<Compile Include="../AMWD.Protocols.Modbus.Common/Extensions/ArrayExtensions.cs" Link="Extensions/ArrayExtensions.cs" />
|
||||
<Compile Include="../AMWD.Protocols.Modbus.Common/Extensions/ReaderWriterLockSlimExtensions.cs" Link="Extensions/ReaderWriterLockSlimExtensions.cs" />
|
||||
<Compile Include="../AMWD.Protocols.Modbus.Common/Utils/AsyncQueue.cs" Link="Utils/AsyncQueue.cs" />
|
||||
<Compile Include="../AMWD.Protocols.Modbus.Common/Utils/RequestQueueItem.cs" Link="Utils/RequestQueueItem.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
|
||||
@@ -36,7 +30,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="$(SolutionDir)\AMWD.Protocols.Modbus.Common\AMWD.Protocols.Modbus.Common.csproj" />
|
||||
<ProjectReference Include="..\AMWD.Protocols.Modbus.Common\AMWD.Protocols.Modbus.Common.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,24 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<PackageId>AMWD.Protocols.Modbus.Tcp</PackageId>
|
||||
<AssemblyName>amwd-modbus-tcp</AssemblyName>
|
||||
<RootNamespace>AMWD.Protocols.Modbus.Tcp</RootNamespace>
|
||||
|
||||
<Product>Modbus TCP Protocol</Product>
|
||||
<Description>Implementation of the Modbus protocol communicating via TCP.</Description>
|
||||
<PackageTags>Modbus Protocol Network TCP LAN</PackageTags>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="../AMWD.Protocols.Modbus.Common/Extensions/ArrayExtensions.cs" Link="Extensions/ArrayExtensions.cs" />
|
||||
<Compile Include="../AMWD.Protocols.Modbus.Common/Extensions/ReaderWriterLockSlimExtensions.cs" Link="Extensions/ReaderWriterLockSlimExtensions.cs" />
|
||||
<Compile Include="../AMWD.Protocols.Modbus.Common/Utils/AsyncQueue.cs" Link="Utils/AsyncQueue.cs" />
|
||||
<Compile Include="../AMWD.Protocols.Modbus.Common/Utils/RequestQueueItem.cs" Link="Utils/RequestQueueItem.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AMWD.Protocols.Modbus.Common\AMWD.Protocols.Modbus.Common.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
50
src/Directory.Build.props
Normal file
50
src/Directory.Build.props
Normal file
@@ -0,0 +1,50 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>
|
||||
|
||||
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
|
||||
<CopyRefAssembliesToPublishDirectory>false</CopyRefAssembliesToPublishDirectory>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<RepositoryUrl>https://github.com/AM-WD/AMWD.Protocols.Modbus.git</RepositoryUrl>
|
||||
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
||||
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<IncludeSymbols>true</IncludeSymbols>
|
||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||
<EmbedUntrackedSources>false</EmbedUntrackedSources>
|
||||
|
||||
<PackageIcon>package-icon.png</PackageIcon>
|
||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
|
||||
<PackageProjectUrl>https://modbus.org/tech.php</PackageProjectUrl>
|
||||
|
||||
<AssemblyOriginatorKeyFile>../../AMWD.Protocols.Modbus.snk</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(GITLAB_CI)' == 'true'">
|
||||
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(GITLAB_CI)' == 'true'">
|
||||
<SourceLinkGitLabHost Include="$(CI_SERVER_HOST)" Version="$(CI_SERVER_VERSION)" />
|
||||
<PackageReference Include="Microsoft.SourceLink.GitLab" Version="8.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="../../package-icon.png" Pack="true" PackagePath="/" />
|
||||
<None Include="../../LICENSE.txt" Pack="true" PackagePath="/" />
|
||||
<None Include="README.md" Pack="true" PackagePath="/" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<InternalsVisibleTo Include="AMWD.Protocols.Modbus.Tests" PublicKey="$(PublicKey)" />
|
||||
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" PublicKey="$(MoqPublicKey)" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)\..'))" />
|
||||
</Project>
|
||||
@@ -0,0 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\AMWD.Protocols.Modbus.Serial\AMWD.Protocols.Modbus.Serial.csproj" />
|
||||
<ProjectReference Include="..\..\src\AMWD.Protocols.Modbus.Tcp\AMWD.Protocols.Modbus.Tcp.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,8 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Moq;
|
||||
using AMWD.Protocols.Modbus.Common.Contracts;
|
||||
|
||||
namespace AMWD.Protocols.Modbus.Tests.Common.Contracts
|
||||
{
|
||||
@@ -111,10 +110,10 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Contracts
|
||||
IModbusConnection connection = null;
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => new ModbusClientBaseWrapper(connection));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => new ModbusClientBaseWrapper(connection));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(true)]
|
||||
[DataRow(false)]
|
||||
public void ShouldAlsoDisposeConnection(bool disposeConnection)
|
||||
@@ -159,7 +158,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Contracts
|
||||
client.Dispose();
|
||||
|
||||
// Act + Assert
|
||||
await Assert.ThrowsExceptionAsync<ObjectDisposedException>(() => client.ReadCoilsAsync(UNIT_ID, START_ADDRESS, READ_COUNT));
|
||||
await Assert.ThrowsExactlyAsync<ObjectDisposedException>(() => client.ReadCoilsAsync(UNIT_ID, START_ADDRESS, READ_COUNT));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -170,7 +169,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Contracts
|
||||
client.Protocol = null;
|
||||
|
||||
// Act + Assert
|
||||
await Assert.ThrowsExceptionAsync<ArgumentNullException>(() => client.ReadCoilsAsync(UNIT_ID, START_ADDRESS, READ_COUNT));
|
||||
await Assert.ThrowsExactlyAsync<ArgumentNullException>(() => client.ReadCoilsAsync(UNIT_ID, START_ADDRESS, READ_COUNT));
|
||||
}
|
||||
|
||||
#endregion Common/Connection/Assertions
|
||||
@@ -47,7 +47,7 @@
|
||||
HoldingRegister[] registers = null;
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => registers.GetSingle(0));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => registers.GetSingle(0));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -60,10 +60,10 @@
|
||||
};
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => registers.GetSingle(0));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => registers.GetSingle(0));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(1)]
|
||||
[DataRow(-1)]
|
||||
public void ShouldThrowArgumentOutOfRangeOnGetSingle(int startIndex)
|
||||
@@ -76,7 +76,7 @@
|
||||
};
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => registers.GetSingle(startIndex));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => registers.GetSingle(startIndex));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -90,7 +90,7 @@
|
||||
};
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => registers.GetSingle(0));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => registers.GetSingle(0));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -139,7 +139,7 @@
|
||||
HoldingRegister[] registers = null;
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => registers.GetDouble(0));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => registers.GetDouble(0));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -154,10 +154,10 @@
|
||||
};
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => registers.GetDouble(0));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => registers.GetDouble(0));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(1)]
|
||||
[DataRow(-1)]
|
||||
public void ShouldThrowArgumentOutOfRangeOnGetDouble(int startIndex)
|
||||
@@ -172,7 +172,7 @@
|
||||
};
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => registers.GetDouble(startIndex));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => registers.GetDouble(startIndex));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -188,7 +188,7 @@
|
||||
};
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => registers.GetDouble(0));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => registers.GetDouble(0));
|
||||
}
|
||||
|
||||
#endregion Modbus to value
|
||||
@@ -36,7 +36,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Extensions
|
||||
Coil coil = null;
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => coil.GetBoolean());
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => coil.GetBoolean());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -98,7 +98,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Extensions
|
||||
HoldingRegister[] list = null;
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => list.GetString(2));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => list.GetString(2));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -108,10 +108,10 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Extensions
|
||||
var registers = Array.Empty<HoldingRegister>();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => registers.GetString(2));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => registers.GetString(2));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(1)]
|
||||
[DataRow(-1)]
|
||||
public void ShouldThrowArgumentOutOfRangeOnString(int startIndex)
|
||||
@@ -124,7 +124,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Extensions
|
||||
};
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => registers.GetString(2, startIndex));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => registers.GetString(2, startIndex));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -138,7 +138,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Extensions
|
||||
};
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => registers.GetString(2));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => registers.GetString(2));
|
||||
}
|
||||
|
||||
#endregion Modbus to value
|
||||
@@ -263,7 +263,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Extensions
|
||||
string str = null;
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => str.ToRegisters(100).ToArray());
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => str.ToRegisters(100).ToArray());
|
||||
}
|
||||
|
||||
#endregion Value to Modbus
|
||||
@@ -38,7 +38,7 @@
|
||||
HoldingRegister register = null;
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => register.GetSByte());
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => register.GetSByte());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -48,7 +48,7 @@
|
||||
var obj = new Coil();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => obj.GetSByte());
|
||||
Assert.ThrowsExactly<ArgumentException>(() => obj.GetSByte());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -84,7 +84,7 @@
|
||||
HoldingRegister register = null;
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => register.GetInt16());
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => register.GetInt16());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -94,7 +94,7 @@
|
||||
var obj = new Coil();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => obj.GetInt16());
|
||||
Assert.ThrowsExactly<ArgumentException>(() => obj.GetInt16());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -139,7 +139,7 @@
|
||||
HoldingRegister[] registers = null;
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => registers.GetInt32(0));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => registers.GetInt32(0));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -152,10 +152,10 @@
|
||||
};
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => registers.GetInt32(0));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => registers.GetInt32(0));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(1)]
|
||||
[DataRow(-1)]
|
||||
public void ShouldThrowArgumentOutOfRangeOnGetInt32(int startIndex)
|
||||
@@ -168,7 +168,7 @@
|
||||
};
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => registers.GetInt32(startIndex));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => registers.GetInt32(startIndex));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -182,7 +182,7 @@
|
||||
};
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => registers.GetInt32(0));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => registers.GetInt32(0));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -231,7 +231,7 @@
|
||||
HoldingRegister[] registers = null;
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => registers.GetInt64(0));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => registers.GetInt64(0));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -246,10 +246,10 @@
|
||||
};
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => registers.GetInt64(0));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => registers.GetInt64(0));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(1)]
|
||||
[DataRow(-1)]
|
||||
public void ShouldThrowArgumentOutOfRangeOnGetInt64(int startIndex)
|
||||
@@ -264,7 +264,7 @@
|
||||
};
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => registers.GetInt64(startIndex));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => registers.GetInt64(startIndex));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -280,7 +280,7 @@
|
||||
};
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => registers.GetInt64(0));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => registers.GetInt64(0));
|
||||
}
|
||||
|
||||
#endregion Modbus to value
|
||||
@@ -38,7 +38,7 @@
|
||||
HoldingRegister register = null;
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => register.GetByte());
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => register.GetByte());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -48,7 +48,7 @@
|
||||
var obj = new Coil();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => obj.GetByte());
|
||||
Assert.ThrowsExactly<ArgumentException>(() => obj.GetByte());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -84,7 +84,7 @@
|
||||
HoldingRegister register = null;
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => register.GetUInt16());
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => register.GetUInt16());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -94,7 +94,7 @@
|
||||
var obj = new Coil();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => obj.GetUInt16());
|
||||
Assert.ThrowsExactly<ArgumentException>(() => obj.GetUInt16());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -139,7 +139,7 @@
|
||||
HoldingRegister[] registers = null;
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => registers.GetUInt32(0));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => registers.GetUInt32(0));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -152,10 +152,10 @@
|
||||
};
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => registers.GetUInt32(1));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => registers.GetUInt32(1));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(1)]
|
||||
[DataRow(-1)]
|
||||
public void ShouldThrowArgumentOutOfRangeOnGetUInt32(int startIndex)
|
||||
@@ -168,7 +168,7 @@
|
||||
};
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => registers.GetUInt32(startIndex));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => registers.GetUInt32(startIndex));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -182,7 +182,7 @@
|
||||
};
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => registers.GetUInt32(0));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => registers.GetUInt32(0));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -231,7 +231,7 @@
|
||||
HoldingRegister[] registers = null;
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => registers.GetUInt64(0));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => registers.GetUInt64(0));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -246,10 +246,10 @@
|
||||
};
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => registers.GetUInt64(0));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => registers.GetUInt64(0));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(1)]
|
||||
[DataRow(-1)]
|
||||
public void ShouldThrowArgumentOutOfRangeOnGetUInt64(int startIndex)
|
||||
@@ -264,7 +264,7 @@
|
||||
};
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => registers.GetUInt64(startIndex));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => registers.GetUInt64(startIndex));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -280,7 +280,7 @@
|
||||
};
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => registers.GetUInt64(0));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => registers.GetUInt64(0));
|
||||
}
|
||||
|
||||
#endregion Modbus to value
|
||||
@@ -87,7 +87,7 @@
|
||||
Assert.IsFalse(success);
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0xFF)]
|
||||
[DataRow(0x00)]
|
||||
public void ShouldPrintPrettyString(int highByte)
|
||||
@@ -87,7 +87,7 @@
|
||||
Assert.IsFalse(success);
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0xFF)]
|
||||
[DataRow(0x00)]
|
||||
public void ShouldPrintPrettyString(int highByte)
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using AMWD.Protocols.Modbus.Common.Models;
|
||||
using System.Reflection;
|
||||
using AMWD.Protocols.Modbus.Common.Models;
|
||||
|
||||
namespace AMWD.Protocols.Modbus.Tests.Common.Models
|
||||
{
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text;
|
||||
using AMWD.Protocols.Modbus.Common.Protocols;
|
||||
|
||||
namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
@@ -29,7 +28,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
CollectionAssert.AreEqual(expectedBytes, bytes.ToArray());
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0)]
|
||||
[DataRow(2001)]
|
||||
public void ShouldThrowOutOfRangeForCountOnSerializeReadCoils(int count)
|
||||
@@ -38,7 +37,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadCoils(UNIT_ID, 19, (ushort)count));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadCoils(UNIT_ID, 19, (ushort)count));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -48,7 +47,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadCoils(UNIT_ID, ushort.MaxValue, 2));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadCoils(UNIT_ID, ushort.MaxValue, 2));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -92,7 +91,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.DeserializeReadCoils(responseBytes));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.DeserializeReadCoils(responseBytes));
|
||||
}
|
||||
|
||||
#endregion Read Coils
|
||||
@@ -117,7 +116,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
CollectionAssert.AreEqual(expectedBytes, bytes.ToArray());
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0)]
|
||||
[DataRow(2001)]
|
||||
public void ShouldThrowOutOfRangeForCountOnSerializeReadDiscreteInputs(int count)
|
||||
@@ -126,7 +125,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadDiscreteInputs(UNIT_ID, 19, (ushort)count));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadDiscreteInputs(UNIT_ID, 19, (ushort)count));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -136,7 +135,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadDiscreteInputs(UNIT_ID, ushort.MaxValue, 2));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadDiscreteInputs(UNIT_ID, ushort.MaxValue, 2));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -180,7 +179,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.DeserializeReadDiscreteInputs(responseBytes));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.DeserializeReadDiscreteInputs(responseBytes));
|
||||
}
|
||||
|
||||
#endregion Read Discrete Inputs
|
||||
@@ -205,7 +204,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
CollectionAssert.AreEqual(expectedBytes, bytes.ToArray());
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0)]
|
||||
[DataRow(2001)]
|
||||
public void ShouldThrowOutOfRangeForCountOnSerializeReadHoldingRegisters(int count)
|
||||
@@ -214,7 +213,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadHoldingRegisters(UNIT_ID, 19, (ushort)count));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadHoldingRegisters(UNIT_ID, 19, (ushort)count));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -224,7 +223,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadHoldingRegisters(UNIT_ID, ushort.MaxValue, 2));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadHoldingRegisters(UNIT_ID, ushort.MaxValue, 2));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -262,7 +261,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.DeserializeReadHoldingRegisters(responseBytes));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.DeserializeReadHoldingRegisters(responseBytes));
|
||||
}
|
||||
|
||||
#endregion Read Holding Registers
|
||||
@@ -287,7 +286,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
CollectionAssert.AreEqual(expectedBytes, bytes.ToArray());
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0)]
|
||||
[DataRow(2001)]
|
||||
public void ShouldThrowOutOfRangeForCountOnSerializeReadInputRegisters(int count)
|
||||
@@ -296,7 +295,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadInputRegisters(UNIT_ID, 19, (ushort)count));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadInputRegisters(UNIT_ID, 19, (ushort)count));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -306,7 +305,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadInputRegisters(UNIT_ID, ushort.MaxValue, 2));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadInputRegisters(UNIT_ID, ushort.MaxValue, 2));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -344,14 +343,14 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.DeserializeReadInputRegisters(responseBytes));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.DeserializeReadInputRegisters(responseBytes));
|
||||
}
|
||||
|
||||
#endregion Read Input Registers
|
||||
|
||||
#region Read Device Identification
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(ModbusDeviceIdentificationCategory.Basic)]
|
||||
[DataRow(ModbusDeviceIdentificationCategory.Regular)]
|
||||
[DataRow(ModbusDeviceIdentificationCategory.Extended)]
|
||||
@@ -380,10 +379,10 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadDeviceIdentification(UNIT_ID, (ModbusDeviceIdentificationCategory)10, ModbusDeviceIdentificationObject.ProductCode));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadDeviceIdentification(UNIT_ID, (ModbusDeviceIdentificationCategory)10, ModbusDeviceIdentificationObject.ProductCode));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(false)]
|
||||
[DataRow(true)]
|
||||
public void ShouldDeserializeReadDeviceIdentification(bool moreAndIndividual)
|
||||
@@ -420,7 +419,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.DeserializeReadDeviceIdentification(responseBytes));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.DeserializeReadDeviceIdentification(responseBytes));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -434,7 +433,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.DeserializeReadDeviceIdentification(responseBytes));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.DeserializeReadDeviceIdentification(responseBytes));
|
||||
}
|
||||
|
||||
#endregion Read Device Identification
|
||||
@@ -467,7 +466,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => protocol.SerializeWriteSingleCoil(UNIT_ID, null));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => protocol.SerializeWriteSingleCoil(UNIT_ID, null));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -519,7 +518,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => protocol.SerializeWriteSingleHoldingRegister(UNIT_ID, null));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => protocol.SerializeWriteSingleHoldingRegister(UNIT_ID, null));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -578,10 +577,10 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, null));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, null));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0)]
|
||||
[DataRow(1969)]
|
||||
public void ShouldThrowOutOfRangeForCountOnSerializeWriteMultipleCoils(int count)
|
||||
@@ -594,7 +593,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, coils));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, coils));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -609,7 +608,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, coils));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, coils));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -624,7 +623,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, coils));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, coils));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -679,10 +678,10 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, null));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, null));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0)]
|
||||
[DataRow(124)]
|
||||
public void ShouldThrowOutOfRangeForCountOnSerializeWriteMultipleHoldingRegisters(int count)
|
||||
@@ -695,7 +694,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, registers));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, registers));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -710,7 +709,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, registers));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, registers));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -725,7 +724,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, registers));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, registers));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -792,7 +791,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
Assert.IsFalse(complete);
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0x01)]
|
||||
[DataRow(0x02)]
|
||||
[DataRow(0x03)]
|
||||
@@ -809,7 +808,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
protocol.ValidateResponse(Encoding.ASCII.GetBytes(request), Encoding.ASCII.GetBytes(response));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0x05)]
|
||||
[DataRow(0x06)]
|
||||
[DataRow(0x0F)]
|
||||
@@ -836,7 +835,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.ValidateResponse(Encoding.ASCII.GetBytes(request), Encoding.ASCII.GetBytes(response)));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.ValidateResponse(Encoding.ASCII.GetBytes(request), Encoding.ASCII.GetBytes(response)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -848,7 +847,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.ValidateResponse(Encoding.ASCII.GetBytes(request), Encoding.ASCII.GetBytes(response)));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.ValidateResponse(Encoding.ASCII.GetBytes(request), Encoding.ASCII.GetBytes(response)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -861,7 +860,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.ValidateResponse(Encoding.ASCII.GetBytes(request), Encoding.ASCII.GetBytes(response)));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.ValidateResponse(Encoding.ASCII.GetBytes(request), Encoding.ASCII.GetBytes(response)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -873,7 +872,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.ValidateResponse(Encoding.ASCII.GetBytes(request), Encoding.ASCII.GetBytes(response)));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.ValidateResponse(Encoding.ASCII.GetBytes(request), Encoding.ASCII.GetBytes(response)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -886,7 +885,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.ValidateResponse(Encoding.ASCII.GetBytes(request), Encoding.ASCII.GetBytes(response)));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.ValidateResponse(Encoding.ASCII.GetBytes(request), Encoding.ASCII.GetBytes(response)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -899,10 +898,10 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.ValidateResponse(Encoding.ASCII.GetBytes(request), Encoding.ASCII.GetBytes(response)));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.ValidateResponse(Encoding.ASCII.GetBytes(request), Encoding.ASCII.GetBytes(response)));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0x01)]
|
||||
[DataRow(0x02)]
|
||||
[DataRow(0x03)]
|
||||
@@ -916,10 +915,10 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.ValidateResponse(Encoding.ASCII.GetBytes(request), Encoding.ASCII.GetBytes(response)));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.ValidateResponse(Encoding.ASCII.GetBytes(request), Encoding.ASCII.GetBytes(response)));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0x05)]
|
||||
[DataRow(0x06)]
|
||||
[DataRow(0x0F)]
|
||||
@@ -933,7 +932,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new AsciiProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.ValidateResponse(Encoding.ASCII.GetBytes(request), Encoding.ASCII.GetBytes(response)));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.ValidateResponse(Encoding.ASCII.GetBytes(request), Encoding.ASCII.GetBytes(response)));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -949,7 +948,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
Assert.AreEqual("F7", lrc);
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(null)]
|
||||
[DataRow("")]
|
||||
[DataRow(" ")]
|
||||
@@ -959,10 +958,10 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
// Arrange
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => AsciiProtocol.LRC(msg));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => AsciiProtocol.LRC(msg));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(-1)]
|
||||
[DataRow(4)]
|
||||
public void ShouldThrowArgumentOutOfRangeExceptionForStartOnLrc(int start)
|
||||
@@ -971,10 +970,10 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
string msg = "0207";
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => AsciiProtocol.LRC(msg, start));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => AsciiProtocol.LRC(msg, start));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0)]
|
||||
[DataRow(5)]
|
||||
public void ShouldThrowArgumentOutOfRangeExceptionForLengthOnLrc(int length)
|
||||
@@ -983,7 +982,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
string msg = "0207";
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => AsciiProtocol.LRC(msg, 0, length));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => AsciiProtocol.LRC(msg, 0, length));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -993,7 +992,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
string msg = "0207";
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => AsciiProtocol.LRC(msg));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => AsciiProtocol.LRC(msg));
|
||||
}
|
||||
|
||||
#endregion Validation
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Reflection;
|
||||
using AMWD.Protocols.Modbus.Common.Protocols;
|
||||
|
||||
namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
@@ -52,7 +51,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
// CRC check will be ignored
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0)]
|
||||
[DataRow(2001)]
|
||||
public void ShouldThrowOutOfRangeForCountOnSerializeReadCoils(int count)
|
||||
@@ -61,7 +60,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadCoils(UNIT_ID, 19, (ushort)count));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadCoils(UNIT_ID, 19, (ushort)count));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -71,7 +70,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadCoils(UNIT_ID, ushort.MaxValue, 2));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadCoils(UNIT_ID, ushort.MaxValue, 2));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -106,7 +105,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.DeserializeReadCoils([0x00, 0x01, 0x00, 0x00, 0x00, 0x08, UNIT_ID, 0x01, 0x02, 0xCD, 0x6B, 0x05, 0x00, 0x00]));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.DeserializeReadCoils([0x00, 0x01, 0x00, 0x00, 0x00, 0x08, UNIT_ID, 0x01, 0x02, 0xCD, 0x6B, 0x05, 0x00, 0x00]));
|
||||
}
|
||||
|
||||
#endregion Read Coils
|
||||
@@ -154,7 +153,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
// CRC check will be ignored
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0)]
|
||||
[DataRow(2001)]
|
||||
public void ShouldThrowOutOfRangeForCountOnSerializeReadDiscreteInputs(int count)
|
||||
@@ -163,7 +162,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadDiscreteInputs(UNIT_ID, 19, (ushort)count));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadDiscreteInputs(UNIT_ID, 19, (ushort)count));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -173,7 +172,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadDiscreteInputs(UNIT_ID, ushort.MaxValue, 2));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadDiscreteInputs(UNIT_ID, ushort.MaxValue, 2));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -208,7 +207,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.DeserializeReadDiscreteInputs([0x00, 0x01, 0x00, 0x00, 0x00, 0x08, UNIT_ID, 0x02, 0x02, 0xCD, 0x6B, 0x05, 0x00, 0x00]));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.DeserializeReadDiscreteInputs([0x00, 0x01, 0x00, 0x00, 0x00, 0x08, UNIT_ID, 0x02, 0x02, 0xCD, 0x6B, 0x05, 0x00, 0x00]));
|
||||
}
|
||||
|
||||
#endregion Read Discrete Inputs
|
||||
@@ -256,7 +255,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
// CRC check will be ignored
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0)]
|
||||
[DataRow(126)]
|
||||
public void ShouldThrowOutOfRangeForCountOnSerializeReadHoldingRegisters(int count)
|
||||
@@ -265,7 +264,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadHoldingRegisters(UNIT_ID, 19, (ushort)count));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadHoldingRegisters(UNIT_ID, 19, (ushort)count));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -275,7 +274,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadHoldingRegisters(UNIT_ID, ushort.MaxValue, 2));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadHoldingRegisters(UNIT_ID, ushort.MaxValue, 2));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -305,7 +304,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.DeserializeReadHoldingRegisters([0x00, 0x01, 0x00, 0x00, 0x00, 0x08, UNIT_ID, 0x03, 0x04, 0x02, 0x2B, 0x00, 0x00]));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.DeserializeReadHoldingRegisters([0x00, 0x01, 0x00, 0x00, 0x00, 0x08, UNIT_ID, 0x03, 0x04, 0x02, 0x2B, 0x00, 0x00]));
|
||||
}
|
||||
|
||||
#endregion Read Holding Registers
|
||||
@@ -353,7 +352,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
// CRC check will be ignored
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0)]
|
||||
[DataRow(126)]
|
||||
public void ShouldThrowOutOfRangeForCountOnSerializeReadInputRegisters(int count)
|
||||
@@ -362,7 +361,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadInputRegisters(UNIT_ID, 19, (ushort)count));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadInputRegisters(UNIT_ID, 19, (ushort)count));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -372,7 +371,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadInputRegisters(UNIT_ID, ushort.MaxValue, 2));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadInputRegisters(UNIT_ID, ushort.MaxValue, 2));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -402,14 +401,14 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.DeserializeReadInputRegisters([0x00, 0x01, 0x00, 0x00, 0x00, 0x08, UNIT_ID, 0x04, 0x04, 0x02, 0x2B, 0x00, 0x00]));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.DeserializeReadInputRegisters([0x00, 0x01, 0x00, 0x00, 0x00, 0x08, UNIT_ID, 0x04, 0x04, 0x02, 0x2B, 0x00, 0x00]));
|
||||
}
|
||||
|
||||
#endregion Read Input Registers
|
||||
|
||||
#region Read Device Identification
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(ModbusDeviceIdentificationCategory.Basic)]
|
||||
[DataRow(ModbusDeviceIdentificationCategory.Regular)]
|
||||
[DataRow(ModbusDeviceIdentificationCategory.Extended)]
|
||||
@@ -463,10 +462,10 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadDeviceIdentification(UNIT_ID, (ModbusDeviceIdentificationCategory)10, ModbusDeviceIdentificationObject.ProductCode));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadDeviceIdentification(UNIT_ID, (ModbusDeviceIdentificationCategory)10, ModbusDeviceIdentificationObject.ProductCode));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(false)]
|
||||
[DataRow(true)]
|
||||
public void ShouldDeserializeReadDeviceIdentification(bool moreAndIndividual)
|
||||
@@ -497,7 +496,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.DeserializeReadDeviceIdentification(response));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.DeserializeReadDeviceIdentification(response));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -508,7 +507,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.DeserializeReadDeviceIdentification(response));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.DeserializeReadDeviceIdentification(response));
|
||||
}
|
||||
|
||||
#endregion Read Device Identification
|
||||
@@ -565,7 +564,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => protocol.SerializeWriteSingleCoil(UNIT_ID, null));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => protocol.SerializeWriteSingleCoil(UNIT_ID, null));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -638,7 +637,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => protocol.SerializeWriteSingleHoldingRegister(UNIT_ID, null));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => protocol.SerializeWriteSingleHoldingRegister(UNIT_ID, null));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -724,10 +723,10 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, null));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, null));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0)]
|
||||
[DataRow(1969)]
|
||||
public void ShouldThrowOutOfRangeForCountOnSerializeWriteMultipleCoils(int count)
|
||||
@@ -740,7 +739,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, coils));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, coils));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -755,7 +754,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, coils));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, coils));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -770,7 +769,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, coils));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, coils));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -855,10 +854,10 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, null));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, null));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0)]
|
||||
[DataRow(124)]
|
||||
public void ShouldThrowOutOfRangeForCountOnSerializeWriteMultipleHoldingRegisters(int count)
|
||||
@@ -871,7 +870,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, registers));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, registers));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -886,7 +885,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, registers));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, registers));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -901,7 +900,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, registers));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, registers));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -991,7 +990,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
protocol.ValidateResponse(request, response);
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0x00, 0x00)]
|
||||
[DataRow(0x01, 0x01)]
|
||||
public void ShouldThrowForTransactionIdOnValidateResponse(int hi, int lo)
|
||||
@@ -1003,10 +1002,10 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0x00, 0x01)]
|
||||
[DataRow(0x01, 0x00)]
|
||||
public void ShouldThrowForProtocolIdOnValidateResponse(int hi, int lo)
|
||||
@@ -1018,7 +1017,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1031,7 +1030,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1044,7 +1043,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1057,7 +1056,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1070,10 +1069,10 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0x59, 0x6C)]
|
||||
[DataRow(0x58, 0x6B)]
|
||||
public void ShouldThrowForCrcOnValidateResponse(int hi, int lo)
|
||||
@@ -1084,7 +1083,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuOverTcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
}
|
||||
|
||||
#endregion Validation
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text;
|
||||
using AMWD.Protocols.Modbus.Common.Protocols;
|
||||
|
||||
namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
@@ -40,7 +39,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
// CRC check will be ignored
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0)]
|
||||
[DataRow(2001)]
|
||||
public void ShouldThrowOutOfRangeForCountOnSerializeReadCoils(int count)
|
||||
@@ -49,7 +48,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadCoils(UNIT_ID, 19, (ushort)count));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadCoils(UNIT_ID, 19, (ushort)count));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -59,7 +58,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadCoils(UNIT_ID, ushort.MaxValue, 2));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadCoils(UNIT_ID, ushort.MaxValue, 2));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -94,7 +93,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.DeserializeReadCoils([UNIT_ID, 0x01, 0x02, 0xCD, 0x6B, 0x05, 0x00, 0x00]));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.DeserializeReadCoils([UNIT_ID, 0x01, 0x02, 0xCD, 0x6B, 0x05, 0x00, 0x00]));
|
||||
}
|
||||
|
||||
#endregion Read Coils
|
||||
@@ -130,7 +129,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
// CRC check will be ignored
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0)]
|
||||
[DataRow(2001)]
|
||||
public void ShouldThrowOutOfRangeForCountOnSerializeReadDiscreteInputs(int count)
|
||||
@@ -139,7 +138,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadDiscreteInputs(UNIT_ID, 19, (ushort)count));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadDiscreteInputs(UNIT_ID, 19, (ushort)count));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -149,7 +148,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadDiscreteInputs(UNIT_ID, ushort.MaxValue, 2));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadDiscreteInputs(UNIT_ID, ushort.MaxValue, 2));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -184,7 +183,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.DeserializeReadDiscreteInputs([UNIT_ID, 0x02, 0x02, 0xCD, 0x6B, 0x05, 0x00, 0x00]));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.DeserializeReadDiscreteInputs([UNIT_ID, 0x02, 0x02, 0xCD, 0x6B, 0x05, 0x00, 0x00]));
|
||||
}
|
||||
|
||||
#endregion Read Discrete Inputs
|
||||
@@ -220,7 +219,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
// CRC check will be ignored
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0)]
|
||||
[DataRow(126)]
|
||||
public void ShouldThrowOutOfRangeForCountOnSerializeReadHoldingRegisters(int count)
|
||||
@@ -229,7 +228,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadHoldingRegisters(UNIT_ID, 19, (ushort)count));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadHoldingRegisters(UNIT_ID, 19, (ushort)count));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -239,7 +238,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadHoldingRegisters(UNIT_ID, ushort.MaxValue, 2));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadHoldingRegisters(UNIT_ID, ushort.MaxValue, 2));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -269,7 +268,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.DeserializeReadHoldingRegisters([UNIT_ID, 0x03, 0x04, 0x02, 0x2B, 0x00, 0x00]));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.DeserializeReadHoldingRegisters([UNIT_ID, 0x03, 0x04, 0x02, 0x2B, 0x00, 0x00]));
|
||||
}
|
||||
|
||||
#endregion Read Holding Registers
|
||||
@@ -305,7 +304,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
// CRC check will be ignored
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0)]
|
||||
[DataRow(126)]
|
||||
public void ShouldThrowOutOfRangeForCountOnSerializeReadInputRegisters(int count)
|
||||
@@ -314,7 +313,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadInputRegisters(UNIT_ID, 19, (ushort)count));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadInputRegisters(UNIT_ID, 19, (ushort)count));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -324,7 +323,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadInputRegisters(UNIT_ID, ushort.MaxValue, 2));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadInputRegisters(UNIT_ID, ushort.MaxValue, 2));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -354,14 +353,14 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.DeserializeReadInputRegisters([UNIT_ID, 0x04, 0x04, 0x02, 0x2B, 0x00, 0x00]));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.DeserializeReadInputRegisters([UNIT_ID, 0x04, 0x04, 0x02, 0x2B, 0x00, 0x00]));
|
||||
}
|
||||
|
||||
#endregion Read Input Registers
|
||||
|
||||
#region Read Device Identification
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(ModbusDeviceIdentificationCategory.Basic)]
|
||||
[DataRow(ModbusDeviceIdentificationCategory.Regular)]
|
||||
[DataRow(ModbusDeviceIdentificationCategory.Extended)]
|
||||
@@ -403,10 +402,10 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadDeviceIdentification(UNIT_ID, (ModbusDeviceIdentificationCategory)10, ModbusDeviceIdentificationObject.ProductCode));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadDeviceIdentification(UNIT_ID, (ModbusDeviceIdentificationCategory)10, ModbusDeviceIdentificationObject.ProductCode));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(false)]
|
||||
[DataRow(true)]
|
||||
public void ShouldDeserializeReadDeviceIdentification(bool moreAndIndividual)
|
||||
@@ -437,7 +436,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.DeserializeReadDeviceIdentification(response));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.DeserializeReadDeviceIdentification(response));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -448,7 +447,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.DeserializeReadDeviceIdentification(response));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.DeserializeReadDeviceIdentification(response));
|
||||
}
|
||||
|
||||
#endregion Read Device Identification
|
||||
@@ -493,7 +492,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => protocol.SerializeWriteSingleCoil(UNIT_ID, null));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => protocol.SerializeWriteSingleCoil(UNIT_ID, null));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -554,7 +553,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => protocol.SerializeWriteSingleHoldingRegister(UNIT_ID, null));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => protocol.SerializeWriteSingleHoldingRegister(UNIT_ID, null));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -628,10 +627,10 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, null));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, null));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0)]
|
||||
[DataRow(1969)]
|
||||
public void ShouldThrowOutOfRangeForCountOnSerializeWriteMultipleCoils(int count)
|
||||
@@ -644,7 +643,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, coils));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, coils));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -659,7 +658,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, coils));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, coils));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -674,7 +673,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, coils));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, coils));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -747,10 +746,10 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, null));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, null));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0)]
|
||||
[DataRow(124)]
|
||||
public void ShouldThrowOutOfRangeForCountOnSerializeWriteMultipleHoldingRegisters(int count)
|
||||
@@ -763,7 +762,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, registers));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, registers));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -778,7 +777,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, registers));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, registers));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -793,7 +792,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, registers));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, registers));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -857,7 +856,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
Assert.IsTrue(complete);
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0x01)] // Read Coils
|
||||
[DataRow(0x02)] // Read Discrete Inputs
|
||||
[DataRow(0x03)] // Read Holding Registers
|
||||
@@ -875,7 +874,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
Assert.IsFalse(complete);
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0x01)] // Read Coils
|
||||
[DataRow(0x02)] // Read Discrete Inputs
|
||||
[DataRow(0x03)] // Read Holding Registers
|
||||
@@ -893,7 +892,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
Assert.IsTrue(complete);
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0x05)] // Write Single Coil
|
||||
[DataRow(0x06)] // Write Single Register
|
||||
[DataRow(0x0F)] // Write Multiple Coils
|
||||
@@ -911,7 +910,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
Assert.IsFalse(complete);
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0x05)] // Write Single Coil
|
||||
[DataRow(0x06)] // Write Single Register
|
||||
[DataRow(0x0F)] // Write Multiple Coils
|
||||
@@ -999,7 +998,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
Assert.IsTrue(complete);
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0x01)]
|
||||
[DataRow(0x02)]
|
||||
[DataRow(0x03)]
|
||||
@@ -1016,7 +1015,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
protocol.ValidateResponse(request, response);
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0x05)]
|
||||
[DataRow(0x06)]
|
||||
[DataRow(0x0F)]
|
||||
@@ -1043,10 +1042,10 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0x57, 0x6C)]
|
||||
[DataRow(0x58, 0x6B)]
|
||||
public void ShouldThrowForCrcOnValidateResponse(int hi, int lo)
|
||||
@@ -1057,7 +1056,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1070,7 +1069,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1083,10 +1082,10 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0x01)]
|
||||
[DataRow(0x02)]
|
||||
[DataRow(0x03)]
|
||||
@@ -1100,10 +1099,10 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0x05)]
|
||||
[DataRow(0x06)]
|
||||
[DataRow(0x0F)]
|
||||
@@ -1117,7 +1116,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new RtuProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1137,7 +1136,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
Assert.AreEqual(0x12, crc[1]);
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(null)]
|
||||
[DataRow(new byte[0])]
|
||||
public void ShuldThrowArgumentNullExceptionForBytesOnCrc16(byte[] bytes)
|
||||
@@ -1145,10 +1144,10 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
// Arrange
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => RtuProtocol.CRC16(bytes));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => RtuProtocol.CRC16(bytes));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(-1)]
|
||||
[DataRow(10)]
|
||||
public void ShouldThrowArgumentOutOfRangeForStartOnCrc16(int start)
|
||||
@@ -1157,10 +1156,10 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
byte[] bytes = Encoding.UTF8.GetBytes("0123456789");
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => RtuProtocol.CRC16(bytes, start));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => RtuProtocol.CRC16(bytes, start));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0)]
|
||||
[DataRow(11)]
|
||||
public void ShouldThrowArgumentOutOfRangeForLengthOnCrc16(int length)
|
||||
@@ -1169,7 +1168,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
byte[] bytes = Encoding.UTF8.GetBytes("0123456789");
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => RtuProtocol.CRC16(bytes, 0, length));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => RtuProtocol.CRC16(bytes, 0, length));
|
||||
}
|
||||
|
||||
#endregion Validation
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Reflection;
|
||||
using AMWD.Protocols.Modbus.Common.Protocols;
|
||||
|
||||
namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
@@ -50,7 +49,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
Assert.AreEqual(0x13, bytes[11]);
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0)]
|
||||
[DataRow(2001)]
|
||||
public void ShouldThrowOutOfRangeForCountOnSerializeReadCoils(int count)
|
||||
@@ -59,7 +58,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadCoils(UNIT_ID, 19, (ushort)count));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadCoils(UNIT_ID, 19, (ushort)count));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -69,7 +68,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadCoils(UNIT_ID, ushort.MaxValue, 2));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadCoils(UNIT_ID, ushort.MaxValue, 2));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -104,7 +103,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.DeserializeReadCoils([0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x2A, 0x01, 0x02, 0xCD, 0x6B, 0x05]));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.DeserializeReadCoils([0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x2A, 0x01, 0x02, 0xCD, 0x6B, 0x05]));
|
||||
}
|
||||
|
||||
#endregion Read Coils
|
||||
@@ -150,7 +149,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
Assert.AreEqual(0x10, bytes[11]);
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0)]
|
||||
[DataRow(2001)]
|
||||
public void ShouldThrowOutOfRangeForCountOnSerializeReadDiscreteInputs(int count)
|
||||
@@ -159,7 +158,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadDiscreteInputs(UNIT_ID, 19, (ushort)count));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadDiscreteInputs(UNIT_ID, 19, (ushort)count));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -169,7 +168,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadDiscreteInputs(UNIT_ID, ushort.MaxValue, 2));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadDiscreteInputs(UNIT_ID, ushort.MaxValue, 2));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -204,7 +203,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.DeserializeReadDiscreteInputs([0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x2A, 0x02, 0x03, 0xCD, 0x6B]));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.DeserializeReadDiscreteInputs([0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x2A, 0x02, 0x03, 0xCD, 0x6B]));
|
||||
}
|
||||
|
||||
#endregion Read Discrete Inputs
|
||||
@@ -250,7 +249,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
Assert.AreEqual(0x02, bytes[11]);
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0)]
|
||||
[DataRow(126)]
|
||||
public void ShouldThrowOutOfRangeForCountOnSerializeReadHoldingRegisters(int count)
|
||||
@@ -259,7 +258,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadHoldingRegisters(UNIT_ID, 19, (ushort)count));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadHoldingRegisters(UNIT_ID, 19, (ushort)count));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -269,7 +268,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadHoldingRegisters(UNIT_ID, ushort.MaxValue, 2));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadHoldingRegisters(UNIT_ID, ushort.MaxValue, 2));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -299,7 +298,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.DeserializeReadHoldingRegisters([0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x2A, 0x03, 0x04, 0x02, 0x2B]));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.DeserializeReadHoldingRegisters([0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x2A, 0x03, 0x04, 0x02, 0x2B]));
|
||||
}
|
||||
|
||||
#endregion Read Holding Registers
|
||||
@@ -345,7 +344,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
Assert.AreEqual(0x03, bytes[11]);
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0)]
|
||||
[DataRow(126)]
|
||||
public void ShouldThrowOutOfRangeForCountOnSerializeReadInputRegisters(int count)
|
||||
@@ -354,7 +353,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadInputRegisters(UNIT_ID, 19, (ushort)count));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadInputRegisters(UNIT_ID, 19, (ushort)count));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -364,7 +363,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadInputRegisters(UNIT_ID, ushort.MaxValue, 2));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadInputRegisters(UNIT_ID, ushort.MaxValue, 2));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -394,14 +393,14 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.DeserializeReadInputRegisters([0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x2A, 0x04, 0x04, 0x02, 0x2B]));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.DeserializeReadInputRegisters([0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x2A, 0x04, 0x04, 0x02, 0x2B]));
|
||||
}
|
||||
|
||||
#endregion Read Input Registers
|
||||
|
||||
#region Read Device Identification
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(ModbusDeviceIdentificationCategory.Basic)]
|
||||
[DataRow(ModbusDeviceIdentificationCategory.Regular)]
|
||||
[DataRow(ModbusDeviceIdentificationCategory.Extended)]
|
||||
@@ -453,10 +452,10 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeReadDeviceIdentification(UNIT_ID, (ModbusDeviceIdentificationCategory)10, ModbusDeviceIdentificationObject.ProductCode));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeReadDeviceIdentification(UNIT_ID, (ModbusDeviceIdentificationCategory)10, ModbusDeviceIdentificationObject.ProductCode));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(false)]
|
||||
[DataRow(true)]
|
||||
public void ShouldDeserializeReadDeviceIdentification(bool moreAndIndividual)
|
||||
@@ -487,7 +486,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.DeserializeReadDeviceIdentification(response));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.DeserializeReadDeviceIdentification(response));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -498,7 +497,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.DeserializeReadDeviceIdentification(response));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.DeserializeReadDeviceIdentification(response));
|
||||
}
|
||||
|
||||
#endregion Read Device Identification
|
||||
@@ -553,7 +552,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => protocol.SerializeWriteSingleCoil(UNIT_ID, null));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => protocol.SerializeWriteSingleCoil(UNIT_ID, null));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -624,7 +623,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => protocol.SerializeWriteSingleHoldingRegister(UNIT_ID, null));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => protocol.SerializeWriteSingleHoldingRegister(UNIT_ID, null));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -708,10 +707,10 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, null));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, null));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0)]
|
||||
[DataRow(1969)]
|
||||
public void ShouldThrowOutOfRangeForCountOnSerializeWriteMultipleCoils(int count)
|
||||
@@ -724,7 +723,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, coils));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, coils));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -739,7 +738,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, coils));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, coils));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -754,7 +753,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, coils));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => protocol.SerializeWriteMultipleCoils(UNIT_ID, coils));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -837,10 +836,10 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, null));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, null));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0)]
|
||||
[DataRow(124)]
|
||||
public void ShouldThrowOutOfRangeForCountOnSerializeWriteMultipleHoldingRegisters(int count)
|
||||
@@ -853,7 +852,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, registers));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, registers));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -868,7 +867,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, registers));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, registers));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -883,7 +882,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, registers));
|
||||
Assert.ThrowsExactly<ArgumentException>(() => protocol.SerializeWriteMultipleHoldingRegisters(UNIT_ID, registers));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -971,7 +970,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
protocol.ValidateResponse(request, response);
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0x00, 0x00)]
|
||||
[DataRow(0x01, 0x01)]
|
||||
public void ShouldThrowForTransactionIdOnValidateResponse(int hi, int lo)
|
||||
@@ -982,10 +981,10 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0x00, 0x01)]
|
||||
[DataRow(0x01, 0x00)]
|
||||
public void ShouldThrowForProtocolIdOnValidateResponse(int hi, int lo)
|
||||
@@ -996,7 +995,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1008,7 +1007,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1020,7 +1019,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1032,7 +1031,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1044,7 +1043,7 @@ namespace AMWD.Protocols.Modbus.Tests.Common.Protocols
|
||||
var protocol = new TcpProtocol();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
Assert.ThrowsExactly<ModbusException>(() => protocol.ValidateResponse(request, response));
|
||||
}
|
||||
|
||||
#endregion Validation
|
||||
@@ -1,12 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Ports;
|
||||
using System.IO.Ports;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AMWD.Protocols.Modbus.Common.Contracts;
|
||||
using AMWD.Protocols.Modbus.Common.Protocols;
|
||||
using AMWD.Protocols.Modbus.Serial;
|
||||
using AMWD.Protocols.Modbus.Serial.Utils;
|
||||
using Moq;
|
||||
|
||||
namespace AMWD.Protocols.Modbus.Tests.Serial
|
||||
{
|
||||
@@ -149,10 +148,10 @@ namespace AMWD.Protocols.Modbus.Tests.Serial
|
||||
// Arrange
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => new ModbusRtuProxy(null, "some-port"));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => new ModbusRtuProxy(null, "some-port"));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(null)]
|
||||
[DataRow("")]
|
||||
[DataRow(" ")]
|
||||
@@ -163,10 +162,10 @@ namespace AMWD.Protocols.Modbus.Tests.Serial
|
||||
var clientMock = new Mock<ModbusClientBase>(connection.Object);
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => new ModbusRtuProxy(clientMock.Object, portName));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => new ModbusRtuProxy(clientMock.Object, portName));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(null)]
|
||||
[DataRow("")]
|
||||
[DataRow(" ")]
|
||||
@@ -177,7 +176,7 @@ namespace AMWD.Protocols.Modbus.Tests.Serial
|
||||
_serialPortMock.Setup(m => m.PortName).Returns(portName);
|
||||
|
||||
// Act + Assert
|
||||
await Assert.ThrowsExceptionAsync<ArgumentNullException>(() => proxy.StartAsync());
|
||||
await Assert.ThrowsExactlyAsync<ArgumentNullException>(() => proxy.StartAsync());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.IO.Ports;
|
||||
using AMWD.Protocols.Modbus.Common.Contracts;
|
||||
using AMWD.Protocols.Modbus.Serial;
|
||||
using Moq;
|
||||
|
||||
namespace AMWD.Protocols.Modbus.Tests.Serial
|
||||
{
|
||||
@@ -1,13 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using System.IO.Ports;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AMWD.Protocols.Modbus.Common.Contracts;
|
||||
using AMWD.Protocols.Modbus.Serial;
|
||||
using AMWD.Protocols.Modbus.Serial.Enums;
|
||||
using AMWD.Protocols.Modbus.Serial.Utils;
|
||||
using Moq;
|
||||
|
||||
namespace AMWD.Protocols.Modbus.Tests.Serial
|
||||
{
|
||||
@@ -90,7 +89,7 @@ namespace AMWD.Protocols.Modbus.Tests.Serial
|
||||
connection.Dispose();
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(null)]
|
||||
[DataRow("")]
|
||||
[DataRow(" ")]
|
||||
@@ -99,7 +98,7 @@ namespace AMWD.Protocols.Modbus.Tests.Serial
|
||||
// Arrange
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => new ModbusSerialClient(portName));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => new ModbusSerialClient(portName));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -110,10 +109,10 @@ namespace AMWD.Protocols.Modbus.Tests.Serial
|
||||
connection.Dispose();
|
||||
|
||||
// Act + Assert
|
||||
await Assert.ThrowsExceptionAsync<ObjectDisposedException>(() => connection.InvokeAsync(null, null));
|
||||
await Assert.ThrowsExactlyAsync<ObjectDisposedException>(() => connection.InvokeAsync(null, null));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(null)]
|
||||
[DataRow(new byte[0])]
|
||||
public async Task ShouldThrowArgumentNullExceptionForMissingRequestOnInvokeAsync(byte[] request)
|
||||
@@ -122,7 +121,7 @@ namespace AMWD.Protocols.Modbus.Tests.Serial
|
||||
var connection = GetConnection();
|
||||
|
||||
// Act + Assert
|
||||
await Assert.ThrowsExceptionAsync<ArgumentNullException>(() => connection.InvokeAsync(request, null));
|
||||
await Assert.ThrowsExactlyAsync<ArgumentNullException>(() => connection.InvokeAsync(request, null));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -133,7 +132,7 @@ namespace AMWD.Protocols.Modbus.Tests.Serial
|
||||
var connection = GetConnection();
|
||||
|
||||
// Act + Assert
|
||||
await Assert.ThrowsExceptionAsync<ArgumentNullException>(() => connection.InvokeAsync(request, null));
|
||||
await Assert.ThrowsExactlyAsync<ArgumentNullException>(() => connection.InvokeAsync(request, null));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -345,7 +344,7 @@ namespace AMWD.Protocols.Modbus.Tests.Serial
|
||||
var connection = GetConnection();
|
||||
|
||||
// Act + Assert
|
||||
await Assert.ThrowsExceptionAsync<EndOfStreamException>(() => connection.InvokeAsync(request, validation));
|
||||
await Assert.ThrowsExactlyAsync<EndOfStreamException>(() => connection.InvokeAsync(request, validation));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -439,7 +438,7 @@ namespace AMWD.Protocols.Modbus.Tests.Serial
|
||||
.Returns(Task.Delay(100));
|
||||
|
||||
// Act + Assert
|
||||
await Assert.ThrowsExceptionAsync<TaskCanceledException>(async () =>
|
||||
await Assert.ThrowsExactlyAsync<TaskCanceledException>(async () =>
|
||||
{
|
||||
var task = connection.InvokeAsync(request, validation);
|
||||
connection.Dispose();
|
||||
@@ -461,7 +460,7 @@ namespace AMWD.Protocols.Modbus.Tests.Serial
|
||||
.Returns(Task.Delay(100));
|
||||
|
||||
// Act + Assert
|
||||
await Assert.ThrowsExceptionAsync<TaskCanceledException>(async () =>
|
||||
await Assert.ThrowsExactlyAsync<TaskCanceledException>(async () =>
|
||||
{
|
||||
var task = connection.InvokeAsync(request, validation, cts.Token);
|
||||
cts.Cancel();
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using AMWD.Protocols.Modbus.Tcp;
|
||||
using Moq;
|
||||
using AMWD.Protocols.Modbus.Common.Contracts;
|
||||
using AMWD.Protocols.Modbus.Tcp;
|
||||
|
||||
namespace AMWD.Protocols.Modbus.Tests.Tcp
|
||||
{
|
||||
@@ -1,13 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AMWD.Protocols.Modbus.Common.Contracts;
|
||||
using AMWD.Protocols.Modbus.Tcp;
|
||||
using AMWD.Protocols.Modbus.Tcp.Utils;
|
||||
using Moq;
|
||||
|
||||
namespace AMWD.Protocols.Modbus.Tests.Tcp
|
||||
{
|
||||
@@ -76,7 +75,7 @@ namespace AMWD.Protocols.Modbus.Tests.Tcp
|
||||
_networkStreamMock.VerifyNoOtherCalls();
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(null)]
|
||||
[DataRow("")]
|
||||
[DataRow(" ")]
|
||||
@@ -86,10 +85,10 @@ namespace AMWD.Protocols.Modbus.Tests.Tcp
|
||||
var connection = GetTcpConnection();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => connection.Hostname = hostname);
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => connection.Hostname = hostname);
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(0)]
|
||||
[DataRow(65536)]
|
||||
public void ShouldThrowArgumentOutOfRangeExceptionForInvalidPort(int port)
|
||||
@@ -98,7 +97,7 @@ namespace AMWD.Protocols.Modbus.Tests.Tcp
|
||||
var connection = GetTcpConnection();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => connection.Port = port);
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => connection.Port = port);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -120,10 +119,10 @@ namespace AMWD.Protocols.Modbus.Tests.Tcp
|
||||
connection.Dispose();
|
||||
|
||||
// Act + Assert
|
||||
await Assert.ThrowsExceptionAsync<ObjectDisposedException>(() => connection.InvokeAsync(null, null));
|
||||
await Assert.ThrowsExactlyAsync<ObjectDisposedException>(() => connection.InvokeAsync(null, null));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow(null)]
|
||||
[DataRow(new byte[0])]
|
||||
public async Task ShouldThrowArgumentNullExceptionForMissingRequestOnInvokeAsync(byte[] request)
|
||||
@@ -132,7 +131,7 @@ namespace AMWD.Protocols.Modbus.Tests.Tcp
|
||||
var connection = GetConnection();
|
||||
|
||||
// Act + Assert
|
||||
await Assert.ThrowsExceptionAsync<ArgumentNullException>(() => connection.InvokeAsync(request, null));
|
||||
await Assert.ThrowsExactlyAsync<ArgumentNullException>(() => connection.InvokeAsync(request, null));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -143,7 +142,7 @@ namespace AMWD.Protocols.Modbus.Tests.Tcp
|
||||
var connection = GetConnection();
|
||||
|
||||
// Act + Assert
|
||||
await Assert.ThrowsExceptionAsync<ArgumentNullException>(() => connection.InvokeAsync(request, null));
|
||||
await Assert.ThrowsExactlyAsync<ArgumentNullException>(() => connection.InvokeAsync(request, null));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -229,7 +228,7 @@ namespace AMWD.Protocols.Modbus.Tests.Tcp
|
||||
var connection = GetConnection();
|
||||
|
||||
// Act + Assert
|
||||
await Assert.ThrowsExceptionAsync<EndOfStreamException>(() => connection.InvokeAsync(request, validation));
|
||||
await Assert.ThrowsExactlyAsync<EndOfStreamException>(() => connection.InvokeAsync(request, validation));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -246,7 +245,7 @@ namespace AMWD.Protocols.Modbus.Tests.Tcp
|
||||
connection.GetType().GetField("_hostname", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(connection, "");
|
||||
|
||||
// Act + Assert
|
||||
await Assert.ThrowsExceptionAsync<ApplicationException>(() => connection.InvokeAsync(request, validation));
|
||||
await Assert.ThrowsExactlyAsync<ApplicationException>(() => connection.InvokeAsync(request, validation));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -342,7 +341,7 @@ namespace AMWD.Protocols.Modbus.Tests.Tcp
|
||||
.Returns(new ValueTask(Task.Delay(100)));
|
||||
|
||||
// Act + Assert
|
||||
await Assert.ThrowsExceptionAsync<TaskCanceledException>(async () =>
|
||||
await Assert.ThrowsExactlyAsync<TaskCanceledException>(async () =>
|
||||
{
|
||||
var task = connection.InvokeAsync(request, validation);
|
||||
connection.Dispose();
|
||||
@@ -364,7 +363,7 @@ namespace AMWD.Protocols.Modbus.Tests.Tcp
|
||||
.Returns(new ValueTask(Task.Delay(100)));
|
||||
|
||||
// Act + Assert
|
||||
await Assert.ThrowsExceptionAsync<TaskCanceledException>(async () =>
|
||||
await Assert.ThrowsExactlyAsync<TaskCanceledException>(async () =>
|
||||
{
|
||||
var task = connection.InvokeAsync(request, validation, cts.Token);
|
||||
cts.Cancel();
|
||||
@@ -1,12 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AMWD.Protocols.Modbus.Common.Contracts;
|
||||
using AMWD.Protocols.Modbus.Tcp;
|
||||
using AMWD.Protocols.Modbus.Tcp.Utils;
|
||||
using Moq;
|
||||
|
||||
namespace AMWD.Protocols.Modbus.Tests.Tcp
|
||||
{
|
||||
@@ -183,7 +182,7 @@ namespace AMWD.Protocols.Modbus.Tests.Tcp
|
||||
// Arrange
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentNullException>(() => new ModbusTcpProxy(null, IPAddress.Loopback));
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => new ModbusTcpProxy(null, IPAddress.Loopback));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -237,7 +236,7 @@ namespace AMWD.Protocols.Modbus.Tests.Tcp
|
||||
using var proxy = GetProxy();
|
||||
|
||||
// Act + Assert
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(() => proxy.ReadWriteTimeout = TimeSpan.FromSeconds(-3));
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => proxy.ReadWriteTimeout = TimeSpan.FromSeconds(-3));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user