@@ -23,9 +23,10 @@ public class SerialTests
2323 [ Setup ]
2424 public void SetupComPorts ( )
2525 {
26+ OutputHelper . WriteLine ( "Setting up tests for an ESP32..." ) ;
2627 try
2728 {
28- Debug . WriteLine ( "Please adjust for your own usage. If you need another hardware, please add the proper nuget and adjust as well" ) ;
29+ OutputHelper . WriteLine ( "Please adjust for your own usage. If you need another hardware, please add the proper nuget and adjust as well" ) ;
2930 Configuration . SetPinFunction ( 32 , DeviceFunction . COM2_RX ) ;
3031 Configuration . SetPinFunction ( 33 , DeviceFunction . COM2_TX ) ;
3132 Configuration . SetPinFunction ( 12 , DeviceFunction . COM2_RTS ) ;
@@ -36,22 +37,23 @@ public void SetupComPorts()
3637 Configuration . SetPinFunction ( 27 , DeviceFunction . COM3_RTS ) ;
3738 Configuration . SetPinFunction ( 14 , DeviceFunction . COM3_CTS ) ;
3839
39- Debug . WriteLine ( "You will need to connect:" ) ;
40- Debug . WriteLine ( " COM2 RX <-> COM3 TX" ) ;
41- Debug . WriteLine ( " COM2 TX <-> COM3 RX" ) ;
42- Debug . WriteLine ( " COM2 RTS <-> COM3 CTS" ) ;
43- Debug . WriteLine ( " COM2 CTS <-> COM3 RTS" ) ;
40+ OutputHelper . WriteLine ( "You will need to connect:" ) ;
41+ OutputHelper . WriteLine ( " COM2 RX <-> COM3 TX" ) ;
42+ OutputHelper . WriteLine ( " COM2 TX <-> COM3 RX" ) ;
43+ OutputHelper . WriteLine ( " COM2 RTS <-> COM3 CTS" ) ;
44+ OutputHelper . WriteLine ( " COM2 CTS <-> COM3 RTS" ) ;
4445 _serOne = new SerialPort ( "COM2" ) ;
4546 _serTwo = new SerialPort ( "COM3" ) ;
46- Debug . WriteLine ( "Devices created, trying to open them" ) ;
47+ OutputHelper . WriteLine ( "SerialPorts created, trying to open them" ) ;
4748 _serOne . Open ( ) ;
48- Debug . WriteLine ( "Serial One COM2 opened" ) ;
49+ OutputHelper . WriteLine ( "SerialPort One COM2 opened. " ) ;
4950 _serTwo . Open ( ) ;
50- Debug . WriteLine ( "Devices opened, will close them" ) ;
51- // Wait a bit just to make sure and close them again
51+ OutputHelper . WriteLine ( "SerialPort Two COM3 opened." ) ;
52+ OutputHelper . WriteLine ( "All SerialPorts opened, will close them" ) ;
53+ // Wait a bit just to make sure and close them all
5254 Thread . Sleep ( 100 ) ;
53- _serOne . Close ( ) ;
54- _serTwo . Close ( ) ;
55+ EnsurePortsClosed ( ) ;
56+ OutputHelper . WriteLine ( "SerialPorts Closed." ) ;
5557 }
5658 catch
5759 {
@@ -63,10 +65,10 @@ public void SetupComPorts()
6365 public void GetPortNamesTest ( )
6466 {
6567 var ports = SerialPort . GetPortNames ( ) ;
66- Debug . WriteLine ( "Available ports :" ) ;
68+ OutputHelper . WriteLine ( "Available SerialPorts :" ) ;
6769 foreach ( string port in ports )
6870 {
69- Debug . WriteLine ( $ " { port } ") ;
71+ OutputHelper . WriteLine ( $ " { port } ") ;
7072 }
7173 }
7274
0 commit comments