Exemple #1
0
        public ConnectionString GetConnectionString(ConnectionType type)
        {
            SerialConnectionString cs = null;

            switch (type)
            {
            case ConnectionType.Any:
                cs = GetConnectionStrings().FirstOrDefault();
                break;

            case ConnectionType.Network:
            case ConnectionType.Serial:
                cs = GetConnectionStrings().FirstOrDefault(x => x.Type == type);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }

            if (cs != null)
            {
                return(cs.ConnectionString);
            }

            Skip.If(true);

            return(null);
        }
Exemple #2
0
        public IDataStreamFactory GetConnection(ConnectionType type = ConnectionType.Any, BaudRates baudRate = BaudRates.Baud57600)
        {
            SerialConnectionString cs = null;

            switch (type)
            {
            case ConnectionType.Any:
                cs = GetConnectionStrings().FirstOrDefault();
                break;

            case ConnectionType.Network:
            case ConnectionType.Serial:
                cs = GetConnectionStrings().FirstOrDefault(x => x.Type == type);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }

            if (cs != null)
            {
                return(cs.Connect());
            }

            Skip.If(true);

            return(null);
        }
Exemple #3
0
 public SerialPortTests()
 {
     serial = TestSettings.Instance.GetConnectionStrings().FirstOrDefault(x => x.Type == ConnectionType.Serial);
     Skip.If(serial == null);
 }