mirror of
https://github.com/OpenLogics/MewtocolNet.git
synced 2025-12-06 03:01:24 +00:00
Add plc series types to support FP7 and EcoLogiX
- add new checksum calculation for Mewtocol 7
This commit is contained in:
40
MewtocolTests/BCCBuilderChecks.cs
Normal file
40
MewtocolTests/BCCBuilderChecks.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using MewtocolNet;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace MewtocolTests;
|
||||
|
||||
public class BCCBuilderChecks {
|
||||
|
||||
private readonly ITestOutputHelper output;
|
||||
|
||||
public BCCBuilderChecks (ITestOutputHelper output) {
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "Test CRC Generation (CRC-8)")]
|
||||
public void BuildBCCFrameGeneration() {
|
||||
|
||||
string test = "%01#RCSX0000";
|
||||
string expect = "%01#RCSX00001D";
|
||||
|
||||
Assert.Equal(expect, test.BCC_Mew());
|
||||
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "Test CRC Generation (CRC-16/MCRF4XX)")]
|
||||
public void BuildBCC7FrameGeneration() {
|
||||
|
||||
string test = ">@EEE00$30STRD00070300000453045304530100000000660100";
|
||||
string expect = ">@EEE00$30STRD00070300000453045304530100000000660100A7A5";
|
||||
|
||||
Assert.Equal(expect, test.BCC_Mew7());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -66,16 +66,6 @@ namespace MewtocolTests {
|
||||
|
||||
}
|
||||
|
||||
[Fact(DisplayName = nameof(MewtocolHelpers.BuildBCCFrame))]
|
||||
public void BuildBCCFrameGeneration() {
|
||||
|
||||
string test = "%01#RCSX0000";
|
||||
string expect = "%01#RCSX00001D";
|
||||
|
||||
Assert.Equal(expect, test.BuildBCCFrame());
|
||||
|
||||
}
|
||||
|
||||
[Fact(DisplayName = nameof(MewtocolHelpers.ParseDTByteString))]
|
||||
public void ParseDTByteStringGeneration() {
|
||||
|
||||
@@ -87,7 +77,7 @@ namespace MewtocolTests {
|
||||
|
||||
foreach (var item in testList) {
|
||||
|
||||
Assert.Equal(item, $"%01$RD{item}".BuildBCCFrame().ParseDTByteString());
|
||||
Assert.Equal(item, $"%01$RD{item}".BCC_Mew().ParseDTByteString());
|
||||
|
||||
}
|
||||
|
||||
@@ -96,8 +86,8 @@ namespace MewtocolTests {
|
||||
[Fact(DisplayName = nameof(MewtocolHelpers.ParseRCSingleBit))]
|
||||
public void ParseRCSingleBitGeneration() {
|
||||
|
||||
Assert.True($"%01$RC1".BuildBCCFrame().ParseRCSingleBit());
|
||||
Assert.False($"%01$RC0".BuildBCCFrame().ParseRCSingleBit());
|
||||
Assert.True($"%01$RC1".BCC_Mew().ParseRCSingleBit());
|
||||
Assert.False($"%01$RC0".BCC_Mew().ParseRCSingleBit());
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user