1 // Licensed to the .NET Foundation under one or more agreements. 2 // The .NET Foundation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using System.IO; 6 using Legacy.Support; 7 using Xunit; 8 9 namespace System.IO.PortsTests 10 { 11 public class PortsTest : FileCleanupTestBase 12 { 13 public static bool HasOneSerialPort => TCSupport.SufficientHardwareRequirements(TCSupport.SerialPortRequirements.OneSerialPort); 14 15 public static bool HasTwoSerialPorts => TCSupport.SufficientHardwareRequirements(TCSupport.SerialPortRequirements.TwoSerialPorts); 16 17 public static bool HasLoopback => TCSupport.SufficientHardwareRequirements(TCSupport.SerialPortRequirements.Loopback); 18 19 public static bool HasNullModem => TCSupport.SufficientHardwareRequirements(TCSupport.SerialPortRequirements.NullModem); 20 21 public static bool HasLoopbackOrNullModem => TCSupport.SufficientHardwareRequirements(TCSupport.SerialPortRequirements.LoopbackOrNullModem); 22 23 /// <summary> 24 /// Shows that we can retain a single byte in the transmit queue if flow control doesn't permit transmission 25 /// This is true for traditional PC ports, but will be false if there is additional driver/hardware buffering in the system 26 /// </summary> 27 public static bool HasSingleByteTransmitBlocking => TCSupport.HardwareTransmitBufferSize == 0; 28 29 /// <summary> 30 /// Shows that we can inhibit transmission using hardware flow control 31 /// Some kinds of virtual port or RS485 adapter can't do this 32 /// </summary> 33 public static bool HasHardwareFlowControl => TCSupport.HardwareWriteBlockingAvailable; 34 Fail(string format, params object[] args)35 public static void Fail(string format, params object[] args) 36 { 37 Assert.True(false, string.Format(format, args)); 38 } 39 } 40 } 41