Dreamine.FullKit.Tests
1.0.0.0
Dreamine.FullKit.Tests 기능을 검증하는 자동화 테스트 프로젝트입니다.
Toggle main menu visibility
로딩중...
검색중...
일치하는것 없음
MitsubishiMcProtocolTests.cs
이 파일의 문서화 페이지로 가기
1
using
Dreamine.PLC.Abstractions.Devices;
2
using
Dreamine.PLC.Mitsubishi.MC.Devices;
3
using
Dreamine.PLC.Mitsubishi.MC.Options;
4
using
Dreamine.PLC.Mitsubishi.MC.Protocol;
5
6
namespace
Dreamine.FullKit.Tests.PLC
;
7
16
public
sealed
class
MitsubishiMcProtocolTests
17
{
26
[Fact]
27
public
void
DeviceCodeMapper_MapsSupportedDeviceTypes
()
28
{
29
var mapper =
new
MitsubishiMcDeviceCodeMapper();
30
31
Assert.Equal(MitsubishiMcDeviceCode.D, mapper.Map(PlcDeviceType.D).Value);
32
Assert.Equal(MitsubishiMcDeviceCode.M, mapper.Map(PlcDeviceType.M).Value);
33
Assert.False(mapper.Map(PlcDeviceType.Unknown).IsSuccess);
34
}
35
44
[Fact]
45
public
void
FrameBuilder_BuildsBinary3EReadFrame
()
46
{
47
var options =
new
MitsubishiMcConnectionOptions();
48
var result =
new
MitsubishiMcBinary3EFrameBuilder()
49
.BuildBatchReadFrame(options,
new
PlcAddress(PlcDeviceType.D, 100), 2, isBitAccess:
false
);
50
51
Assert.True(result.IsSuccess);
52
Assert.Equal(0x00, result.Value![0]);
53
Assert.Equal(0x50, result.Value[1]);
54
Assert.Contains((
byte
)MitsubishiMcDeviceCode.D, result.Value);
55
}
56
65
[Fact]
66
public
void
ResponseParser_ParsesWordAndBitResponses
()
67
{
68
var parser =
new
MitsubishiMcBinary3EResponseParser();
69
var wordFrame =
BuildResponse
(0x00, 0x00, 0x34, 0x12, 0xFE, 0xFF);
70
var bitFrame =
BuildResponse
(0x00, 0x00, 0x11);
71
72
Assert.Equal(
new
short
[] { 0x1234, -2 }, parser.ParseReadWords(wordFrame, 2).Value);
73
Assert.Equal(
new
[] {
true
,
true
}, parser.ParseReadBits(bitFrame, 2).Value);
74
}
75
84
[Fact]
85
public
void
EndianHelpers_RejectOutOfRangeUInt24
()
86
{
87
var bytes =
new
List<byte>();
88
89
MitsubishiMcEndian.WriteUInt16LittleEndian(bytes, 0x1234);
90
91
Assert.Equal(
new
byte
[] { 0x34, 0x12 }, bytes);
92
Assert.Throws<ArgumentOutOfRangeException>(() => MitsubishiMcEndian.WriteUInt24LittleEndian(bytes, -1));
93
}
94
119
private
static
byte
[]
BuildResponse
(params
byte
[] data)
120
{
121
var length = data.Length;
122
return
new
byte
[]
123
{
124
0x00, 0xD0, 0, 0, 0, 0, 0,
125
(byte)length, (
byte
)(length >> 8)
126
}.Concat(data).ToArray();
127
}
128
}
Dreamine.FullKit.Tests.PLC
Definition
ComponentFormatterTests.cs:7
Dreamine.FullKit.Tests.PLC.MitsubishiMcProtocolTests
Definition
MitsubishiMcProtocolTests.cs:17
Dreamine.FullKit.Tests.PLC.MitsubishiMcProtocolTests.DeviceCodeMapper_MapsSupportedDeviceTypes
void DeviceCodeMapper_MapsSupportedDeviceTypes()
Definition
MitsubishiMcProtocolTests.cs:27
Dreamine.FullKit.Tests.PLC.MitsubishiMcProtocolTests.ResponseParser_ParsesWordAndBitResponses
void ResponseParser_ParsesWordAndBitResponses()
Definition
MitsubishiMcProtocolTests.cs:66
Dreamine.FullKit.Tests.PLC.MitsubishiMcProtocolTests.BuildResponse
static byte[] BuildResponse(params byte[] data)
Definition
MitsubishiMcProtocolTests.cs:119
Dreamine.FullKit.Tests.PLC.MitsubishiMcProtocolTests.FrameBuilder_BuildsBinary3EReadFrame
void FrameBuilder_BuildsBinary3EReadFrame()
Definition
MitsubishiMcProtocolTests.cs:45
Dreamine.FullKit.Tests.PLC.MitsubishiMcProtocolTests.EndianHelpers_RejectOutOfRangeUInt24
void EndianHelpers_RejectOutOfRangeUInt24()
Definition
MitsubishiMcProtocolTests.cs:85
PLC
MitsubishiMcProtocolTests.cs
다음에 의해 생성됨 :
1.17.0