File tree 2 files changed +47
-0
lines changed
Valley.Net.Protocols.MeterBus.Test
2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . Diagnostics ;
4
+ using System . IO ;
5
+ using System . IO . Ports ;
6
+ using System . Net ;
7
+ using System . Threading ;
8
+ using System . Threading . Tasks ;
9
+ using Microsoft . VisualStudio . TestTools . UnitTesting ;
10
+ using Valley . Net . Bindings . Serial ;
11
+ using Valley . Net . Protocols . MeterBus . EN13757_2 ;
12
+ using Valley . Net . Protocols . MeterBus . EN13757_3 ;
13
+
14
+ namespace Valley . Net . Protocols . MeterBus . Test
15
+ {
16
+ [ TestClass ]
17
+ public sealed class SerialTests
18
+ {
19
+ private const int TIMEOUT_IN_SECONDS = 3 ;
20
+
21
+ [ TestMethod ]
22
+ public async Task Meter_Should_Respond_With_Ack_When_Sending_SND_NKE ( )
23
+ {
24
+ var resetEvent = new AutoResetEvent ( false ) ;
25
+
26
+ var port = new SerialPort ( ) ;
27
+ port . BaudRate = 1200 ;
28
+
29
+ var endpoint = new SerialBinding ( port , ( x , y ) =>
30
+ {
31
+ return null ;
32
+ } , new MeterbusFrameSerializer ( ) ) ;
33
+
34
+ endpoint . PacketReceived += ( sender , e ) => resetEvent . Set ( ) ;
35
+
36
+ await endpoint . ConnectAsync ( ) ;
37
+
38
+ await endpoint . SendAsync ( new ShortFrame ( ( byte ) ControlMask . SND_NKE , 0x0a ) ) ;
39
+
40
+ Assert . IsTrue ( resetEvent . WaitOne ( TimeSpan . FromSeconds ( TIMEOUT_IN_SECONDS ) ) ) ;
41
+
42
+ await endpoint . DisconnectAsync ( ) ;
43
+ }
44
+ }
45
+ }
Original file line number Diff line number Diff line change 9
9
<ItemGroup >
10
10
<PackageReference Include =" MSTest.TestAdapter" Version =" 2.0.0" />
11
11
<PackageReference Include =" MSTest.TestFramework" Version =" 2.0.0" />
12
+ <PackageReference Include =" System.IO.Ports" Version =" 4.6.0" />
12
13
<PackageReference Include =" Valley.Net.Bindings" Version =" 1.0.2" />
14
+ <PackageReference Include =" Valley.Net.Bindings.Serial" Version =" 1.0.0" />
13
15
</ItemGroup >
14
16
15
17
<ItemGroup >
You can’t perform that action at this time.
0 commit comments