From f5f1e3bea929df43f58ae40fb78dc2796096eac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Wei=C3=9F?= <72068105+Sandoun@users.noreply.github.com> Date: Fri, 23 Jun 2023 15:45:14 +0200 Subject: [PATCH] Namespaces fixed --- MewtocolNet/DynamicInterface.cs | 2 +- MewtocolNet/MewtocolInterface.cs | 2 +- MewtocolNet/MewtocolInterfaceRequests.cs | 2 +- .../{Subregisters => Registers}/BRegister.cs | 2 +- .../BRegisterResult.cs | 2 +- .../{Subregisters => Registers}/NRegister.cs | 2 +- .../NRegisterResult.cs | 6 +-- .../{Subregisters => Registers}/SRegister.cs | 3 +- .../SRegisterResult.cs | 2 +- MewtocolTests/AutomatedPropertyRegisters.cs | 44 +++++++++---------- MewtocolTests/TestHelperExtensions.cs | 21 ++++----- MewtocolTests/TestLinkedLists.cs | 11 ++--- MewtocolTests/TestLivePLC.cs | 22 ++++------ MewtocolTests/TestRegisterInterface.cs | 17 ++++--- MewtocolTests/TestRegisterParsing.cs | 12 ++--- 15 files changed, 63 insertions(+), 87 deletions(-) rename MewtocolNet/{Subregisters => Registers}/BRegister.cs (99%) rename MewtocolNet/{Subregisters => Registers}/BRegisterResult.cs (90%) rename MewtocolNet/{Subregisters => Registers}/NRegister.cs (99%) rename MewtocolNet/{Subregisters => Registers}/NRegisterResult.cs (94%) rename MewtocolNet/{Subregisters => Registers}/SRegister.cs (99%) rename MewtocolNet/{Subregisters => Registers}/SRegisterResult.cs (90%) diff --git a/MewtocolNet/DynamicInterface.cs b/MewtocolNet/DynamicInterface.cs index f8726b0..f13ceff 100644 --- a/MewtocolNet/DynamicInterface.cs +++ b/MewtocolNet/DynamicInterface.cs @@ -1,5 +1,5 @@ using MewtocolNet.Logging; -using MewtocolNet.Subregisters; +using MewtocolNet.Registers; using System; using System.Collections.Generic; using System.Linq; diff --git a/MewtocolNet/MewtocolInterface.cs b/MewtocolNet/MewtocolInterface.cs index b5f28a6..81cd8ff 100644 --- a/MewtocolNet/MewtocolInterface.cs +++ b/MewtocolNet/MewtocolInterface.cs @@ -1,7 +1,7 @@ using MewtocolNet.Logging; using MewtocolNet.Queue; using MewtocolNet.RegisterAttributes; -using MewtocolNet.Subregisters; +using MewtocolNet.Registers; using System; using System.Collections; using System.Collections.Generic; diff --git a/MewtocolNet/MewtocolInterfaceRequests.cs b/MewtocolNet/MewtocolInterfaceRequests.cs index 94917db..90aab30 100644 --- a/MewtocolNet/MewtocolInterfaceRequests.cs +++ b/MewtocolNet/MewtocolInterfaceRequests.cs @@ -1,6 +1,6 @@ using MewtocolNet.Logging; using MewtocolNet.PLCEnums; -using MewtocolNet.Subregisters; +using MewtocolNet.Registers; using System; using System.Collections.Generic; using System.Globalization; diff --git a/MewtocolNet/Subregisters/BRegister.cs b/MewtocolNet/Registers/BRegister.cs similarity index 99% rename from MewtocolNet/Subregisters/BRegister.cs rename to MewtocolNet/Registers/BRegister.cs index 88b8590..d42cfd4 100644 --- a/MewtocolNet/Subregisters/BRegister.cs +++ b/MewtocolNet/Registers/BRegister.cs @@ -2,7 +2,7 @@ using System.ComponentModel; using System.Text; -namespace MewtocolNet.Subregisters { +namespace MewtocolNet.Registers { /// /// Defines a register containing a boolean diff --git a/MewtocolNet/Subregisters/BRegisterResult.cs b/MewtocolNet/Registers/BRegisterResult.cs similarity index 90% rename from MewtocolNet/Subregisters/BRegisterResult.cs rename to MewtocolNet/Registers/BRegisterResult.cs index ddc4477..8a39277 100644 --- a/MewtocolNet/Subregisters/BRegisterResult.cs +++ b/MewtocolNet/Registers/BRegisterResult.cs @@ -1,4 +1,4 @@ -namespace MewtocolNet.Subregisters { +namespace MewtocolNet.Registers { /// /// Result for a boolean register diff --git a/MewtocolNet/Subregisters/NRegister.cs b/MewtocolNet/Registers/NRegister.cs similarity index 99% rename from MewtocolNet/Subregisters/NRegister.cs rename to MewtocolNet/Registers/NRegister.cs index 1030cd6..5550e5a 100644 --- a/MewtocolNet/Subregisters/NRegister.cs +++ b/MewtocolNet/Registers/NRegister.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Text; -namespace MewtocolNet.Subregisters { +namespace MewtocolNet.Registers { /// /// Defines a register containing a number diff --git a/MewtocolNet/Subregisters/NRegisterResult.cs b/MewtocolNet/Registers/NRegisterResult.cs similarity index 94% rename from MewtocolNet/Subregisters/NRegisterResult.cs rename to MewtocolNet/Registers/NRegisterResult.cs index fa5e29d..367233a 100644 --- a/MewtocolNet/Subregisters/NRegisterResult.cs +++ b/MewtocolNet/Registers/NRegisterResult.cs @@ -1,4 +1,5 @@ -namespace MewtocolNet.Subregisters { +namespace MewtocolNet.Registers { + /// /// Result for a read/write operation /// @@ -31,7 +32,4 @@ } - - - } diff --git a/MewtocolNet/Subregisters/SRegister.cs b/MewtocolNet/Registers/SRegister.cs similarity index 99% rename from MewtocolNet/Subregisters/SRegister.cs rename to MewtocolNet/Registers/SRegister.cs index 49fa579..00e7b2a 100644 --- a/MewtocolNet/Subregisters/SRegister.cs +++ b/MewtocolNet/Registers/SRegister.cs @@ -2,7 +2,8 @@ using System.ComponentModel; using System.Text; -namespace MewtocolNet.Subregisters { +namespace MewtocolNet.Registers { + /// /// Defines a register containing a string /// diff --git a/MewtocolNet/Subregisters/SRegisterResult.cs b/MewtocolNet/Registers/SRegisterResult.cs similarity index 90% rename from MewtocolNet/Subregisters/SRegisterResult.cs rename to MewtocolNet/Registers/SRegisterResult.cs index 9ffed98..45129a6 100644 --- a/MewtocolNet/Subregisters/SRegisterResult.cs +++ b/MewtocolNet/Registers/SRegisterResult.cs @@ -1,4 +1,4 @@ -namespace MewtocolNet.Subregisters { +namespace MewtocolNet.Registers { /// /// The results of a string register operation diff --git a/MewtocolTests/AutomatedPropertyRegisters.cs b/MewtocolTests/AutomatedPropertyRegisters.cs index 5ae5d3e..cd46f3f 100644 --- a/MewtocolTests/AutomatedPropertyRegisters.cs +++ b/MewtocolTests/AutomatedPropertyRegisters.cs @@ -1,15 +1,11 @@ -using Xunit; - using MewtocolNet; -using System.Diagnostics; -using Xunit.Abstractions; -using System.Collections; using MewtocolNet.RegisterAttributes; -using Microsoft.Win32; -using MewtocolNet.Subregisters; +using MewtocolNet.Registers; +using System.Collections; +using Xunit; +using Xunit.Abstractions; -namespace MewtocolTests -{ +namespace MewtocolTests { public class AutomatedPropertyRegisters { @@ -94,7 +90,7 @@ namespace MewtocolTests public CurrentState TestEnum32 { get; private set; } } - + private void TestBasicGeneration(IRegister reg, string propName, object expectValue, int expectAddr, string expectPlcName) { Assert.NotNull(reg); @@ -111,7 +107,7 @@ namespace MewtocolTests //actual tests [Fact(DisplayName = "Boolean R generation")] - public void BooleanGen () { + public void BooleanGen() { var interf = new MewtocolInterface("192.168.0.1"); interf.WithRegisterCollection(new TestRegisterCollection()).WithPoller(); @@ -124,7 +120,7 @@ namespace MewtocolTests } [Fact(DisplayName = "Boolean input XD generation")] - public void BooleanInputGen () { + public void BooleanInputGen() { var interf = new MewtocolInterface("192.168.0.1"); interf.WithRegisterCollection(new TestRegisterCollection()).WithPoller(); @@ -137,7 +133,7 @@ namespace MewtocolTests } [Fact(DisplayName = "Int16 generation")] - public void Int16Gen () { + public void Int16Gen() { var interf = new MewtocolInterface("192.168.0.1"); interf.WithRegisterCollection(new TestRegisterCollection()).WithPoller(); @@ -150,7 +146,7 @@ namespace MewtocolTests } [Fact(DisplayName = "UInt16 generation")] - public void UInt16Gen () { + public void UInt16Gen() { var interf = new MewtocolInterface("192.168.0.1"); interf.WithRegisterCollection(new TestRegisterCollection()).WithPoller(); @@ -163,7 +159,7 @@ namespace MewtocolTests } [Fact(DisplayName = "Int32 generation")] - public void Int32Gen () { + public void Int32Gen() { var interf = new MewtocolInterface("192.168.0.1"); interf.WithRegisterCollection(new TestRegisterCollection()).WithPoller(); @@ -176,7 +172,7 @@ namespace MewtocolTests } [Fact(DisplayName = "UInt32 generation")] - public void UInt32Gen () { + public void UInt32Gen() { var interf = new MewtocolInterface("192.168.0.1"); interf.WithRegisterCollection(new TestRegisterCollection()).WithPoller(); @@ -189,7 +185,7 @@ namespace MewtocolTests } [Fact(DisplayName = "Float32 generation")] - public void Float32Gen () { + public void Float32Gen() { var interf = new MewtocolInterface("192.168.0.1"); interf.WithRegisterCollection(new TestRegisterCollection()).WithPoller(); @@ -202,7 +198,7 @@ namespace MewtocolTests } [Fact(DisplayName = "String generation")] - public void StringGen () { + public void StringGen() { var interf = new MewtocolInterface("192.168.0.1"); interf.WithRegisterCollection(new TestRegisterCollection()).WithPoller(); @@ -218,7 +214,7 @@ namespace MewtocolTests } [Fact(DisplayName = "BitArray 16bit generation")] - public void BitArray16Gen () { + public void BitArray16Gen() { var interf = new MewtocolInterface("192.168.0.1"); interf.WithRegisterCollection(new TestRegisterCollection()).WithPoller(); @@ -234,7 +230,7 @@ namespace MewtocolTests } [Fact(DisplayName = "BitArray 32bit generation")] - public void BitArray32Gen () { + public void BitArray32Gen() { var interf = new MewtocolInterface("192.168.0.1"); interf.WithRegisterCollection(new TestRegisterCollection()).WithPoller(); @@ -250,7 +246,7 @@ namespace MewtocolTests } [Fact(DisplayName = "BitArray single bool generation")] - public void BitArraySingleBool16Gen () { + public void BitArraySingleBool16Gen() { var interf = new MewtocolInterface("192.168.0.1"); interf.WithRegisterCollection(new TestRegisterCollection()).WithPoller(); @@ -265,7 +261,7 @@ namespace MewtocolTests } [Fact(DisplayName = "TimeSpan generation")] - public void TimespanGen () { + public void TimespanGen() { var interf = new MewtocolInterface("192.168.0.1"); interf.WithRegisterCollection(new TestRegisterCollection()).WithPoller(); @@ -278,7 +274,7 @@ namespace MewtocolTests } [Fact(DisplayName = "Enum16 generation")] - public void Enum16Gen () { + public void Enum16Gen() { var interf = new MewtocolInterface("192.168.0.1"); interf.WithRegisterCollection(new TestRegisterCollection()).WithPoller(); @@ -291,7 +287,7 @@ namespace MewtocolTests } [Fact(DisplayName = "Enum32 generation")] - public void Enum32Gen () { + public void Enum32Gen() { var interf = new MewtocolInterface("192.168.0.1"); interf.WithRegisterCollection(new TestRegisterCollection()).WithPoller(); diff --git a/MewtocolTests/TestHelperExtensions.cs b/MewtocolTests/TestHelperExtensions.cs index b39e65e..26ab943 100644 --- a/MewtocolTests/TestHelperExtensions.cs +++ b/MewtocolTests/TestHelperExtensions.cs @@ -1,10 +1,7 @@ -using Xunit; - using MewtocolNet; -using MewtocolNet.Registers; -using Xunit.Abstractions; -using MewtocolNet.Links; using System.Collections; +using Xunit; +using Xunit.Abstractions; namespace MewtocolTests { @@ -12,12 +9,12 @@ namespace MewtocolTests { private readonly ITestOutputHelper output; - public TestHelperExtensions (ITestOutputHelper output) { + public TestHelperExtensions(ITestOutputHelper output) { this.output = output; } [Fact(DisplayName = nameof(MewtocolHelpers.ToBitString))] - public void ToBitStringGeneration () { + public void ToBitStringGeneration() { var bitarr = new BitArray(16); bitarr[2] = true; @@ -31,7 +28,7 @@ namespace MewtocolTests { } [Fact(DisplayName = nameof(MewtocolHelpers.ToHexString))] - public void ToHexStringGeneration () { + public void ToHexStringGeneration() { var bytes = new byte[6] { 0x10, @@ -47,7 +44,7 @@ namespace MewtocolTests { } [Fact(DisplayName = nameof(MewtocolHelpers.ToHexASCIIBytes))] - public void ToHexASCIIBytesGeneration () { + public void ToHexASCIIBytesGeneration() { string test = "Hello, world!"; @@ -70,7 +67,7 @@ namespace MewtocolTests { } [Fact(DisplayName = nameof(MewtocolHelpers.BuildBCCFrame))] - public void BuildBCCFrameGeneration () { + public void BuildBCCFrameGeneration() { string test = "%01#RCSX0000"; string expect = "%01#RCSX00001D"; @@ -80,7 +77,7 @@ namespace MewtocolTests { } [Fact(DisplayName = nameof(MewtocolHelpers.ParseDTByteString))] - public void ParseDTByteStringGeneration () { + public void ParseDTByteStringGeneration() { var testList = new List() { "1112", @@ -97,7 +94,7 @@ namespace MewtocolTests { } [Fact(DisplayName = nameof(MewtocolHelpers.ParseRCSingleBit))] - public void ParseRCSingleBitGeneration () { + public void ParseRCSingleBitGeneration() { Assert.True($"%01$RC1".BuildBCCFrame().ParseRCSingleBit()); Assert.False($"%01$RC0".BuildBCCFrame().ParseRCSingleBit()); diff --git a/MewtocolTests/TestLinkedLists.cs b/MewtocolTests/TestLinkedLists.cs index 324cdf5..0f24484 100644 --- a/MewtocolTests/TestLinkedLists.cs +++ b/MewtocolTests/TestLinkedLists.cs @@ -1,22 +1,19 @@ -using Xunit; - using MewtocolNet; -using MewtocolNet.Registers; +using Xunit; using Xunit.Abstractions; -namespace MewtocolTests -{ +namespace MewtocolTests { public class TestLinkedLists { private readonly ITestOutputHelper output; - public TestLinkedLists (ITestOutputHelper output) { + public TestLinkedLists(ITestOutputHelper output) { this.output = output; } [Fact(DisplayName = "Linked error list")] - public void NumericRegisterMewtocolIdentifiers () { + public void NumericRegisterMewtocolIdentifiers() { var expectedData = new Dictionary { diff --git a/MewtocolTests/TestLivePLC.cs b/MewtocolTests/TestLivePLC.cs index 79f9bcf..b4d40f1 100644 --- a/MewtocolTests/TestLivePLC.cs +++ b/MewtocolTests/TestLivePLC.cs @@ -1,16 +1,10 @@ using MewtocolNet; using MewtocolNet.Logging; using MewtocolNet.PLCEnums; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Xunit; using Xunit.Abstractions; -namespace MewtocolTests -{ +namespace MewtocolTests { public class TestLivePLC { @@ -39,21 +33,21 @@ namespace MewtocolTests }; - public TestLivePLC (ITestOutputHelper output) { + public TestLivePLC(ITestOutputHelper output) { this.output = output; Logger.LogLevel = LogLevel.Verbose; - Logger.OnNewLogMessage((d,m) => { + Logger.OnNewLogMessage((d, m) => { output.WriteLine($"Mewtocol Logger: {d} {m}"); }); - + } [Fact(DisplayName = "Connection cycle client to PLC")] - public async void TestClientConnection () { + public async void TestClientConnection() { foreach (var plc in testData) { @@ -74,7 +68,7 @@ namespace MewtocolTests } [Fact(DisplayName = "Reading basic information from PLC")] - public async void TestClientReadPLCStatus () { + public async void TestClientReadPLCStatus() { foreach (var plc in testData) { @@ -107,9 +101,9 @@ namespace MewtocolTests public int PLCPort { get; set; } - public CpuType Type { get; set; } + public CpuType Type { get; set; } - public int ProgCapacity { get; set; } + public int ProgCapacity { get; set; } } diff --git a/MewtocolTests/TestRegisterInterface.cs b/MewtocolTests/TestRegisterInterface.cs index ec0f04f..bf11d1b 100644 --- a/MewtocolTests/TestRegisterInterface.cs +++ b/MewtocolTests/TestRegisterInterface.cs @@ -1,7 +1,6 @@ -using Xunit; - using MewtocolNet; using MewtocolNet.Registers; +using Xunit; using Xunit.Abstractions; namespace MewtocolTests { @@ -10,12 +9,12 @@ namespace MewtocolTests { private readonly ITestOutputHelper output; - public TestRegisterInterface (ITestOutputHelper output) { + public TestRegisterInterface(ITestOutputHelper output) { this.output = output; } [Fact(DisplayName = "Numeric mewtocol query building")] - public void NumericRegisterMewtocolIdentifiers () { + public void NumericRegisterMewtocolIdentifiers() { List registers = new List { new NRegister(50, _name: null), @@ -48,7 +47,7 @@ namespace MewtocolTests { } [Fact(DisplayName = "PLC register naming convention test")] - public void PLCRegisterIdentifiers () { + public void PLCRegisterIdentifiers() { List registers = new List { //numeric ones @@ -77,8 +76,8 @@ namespace MewtocolTests { "DT50", "DT60", "DDT70", - "DDT80", - "DDT90", + "DDT80", + "DDT90", "DDT100", //boolean @@ -107,7 +106,7 @@ namespace MewtocolTests { } [Fact(DisplayName = "Non allowed (Overflow address)")] - public void OverFlowRegisterAddress () { + public void OverFlowRegisterAddress() { var ex = Assert.Throws(() => { @@ -144,7 +143,7 @@ namespace MewtocolTests { } [Fact(DisplayName = "Non allowed (Wrong data type)")] - public void WrongDataTypeRegister () { + public void WrongDataTypeRegister() { var ex = Assert.Throws(() => { diff --git a/MewtocolTests/TestRegisterParsing.cs b/MewtocolTests/TestRegisterParsing.cs index 94953fd..41687f1 100644 --- a/MewtocolTests/TestRegisterParsing.cs +++ b/MewtocolTests/TestRegisterParsing.cs @@ -1,11 +1,5 @@ using MewtocolNet; -using MewtocolNet.Mewtocol; using MewtocolNet.Registers; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Xunit; using Xunit.Abstractions; @@ -15,12 +9,12 @@ public class TestRegisterParsing { private readonly ITestOutputHelper output; - public TestRegisterParsing (ITestOutputHelper output) { + public TestRegisterParsing(ITestOutputHelper output) { this.output = output; } [Fact(DisplayName = "Parsing as BRegister (Phyiscal Outputs)")] - public void TestParsingBRegisterY () { + public void TestParsingBRegisterY() { var tests = new Dictionary() { @@ -51,7 +45,7 @@ public class TestRegisterParsing { } [Fact(DisplayName = "Parsing as BRegister (Phyiscal Inputs)")] - public void TestParsingBRegisterX () { + public void TestParsingBRegisterX() { var tests = new Dictionary() {