Esempio n. 1
0
        public void Hello_TestSearchGlobalWithoutName(string name)
        {
            var devices = Enumerable.Range(0, 10).SelectMany(x => Majoro.Hello()).ToList();

            var count = devices.Count(x => x != null && x.Name == name);

            // 9 = 90%
            Assert.InRange <int>(count, 9, 10);
        }
Esempio n. 2
0
        public void Hello_TestDeviceAvailable(string name)
        {
            var devices = Enumerable.Range(0, 20).Select(x => Majoro.Hello(name)).ToList();

            var count = devices.Count(x => x != null && x.Name == name);

            // 19 = 95%
            Assert.InRange <int>(count, 19, 20);
        }
Esempio n. 3
0
        [InlineData(5)]  // Relay
        public void WriteHighAndLow_Test(int pin)
        {
            var device = Majoro.Hello("Bilbo");
            var majoro = new Majoro(device.SerialPort);

            majoro.Connect();

            var count = Enumerable.Range(0, 50).Count(x => majoro.WriteHigh(pin) && majoro.WriteLow(pin));

            majoro.Disconnect();

            Assert.Equal(50, count);
        }
Esempio n. 4
0
        public void Ping_Test()
        {
            var device = Majoro.Hello("Bilbo");
            var majoro = new Majoro(device.SerialPort);

            majoro.Connect();

            var count = Enumerable.Range(0, 20).Count(x => majoro.Ping());

            majoro.Disconnect();

            Assert.Equal(20, count);
        }
Esempio n. 5
0
        private Majoro findConnection(string name)
        {
            int    numberOfRetries = 10;
            string serialPort      = null;

            Logger.Information(string.Format("Searching for {0}", name));
            for (int i = 0; i < numberOfRetries && serialPort == null; i++)
            {
                Logger.Debug(string.Format("Try {0} / {1}", i + 1, numberOfRetries));
                serialPort = Majoro.Hello(name)?.SerialPort;
            }

            if (serialPort == null)
            {
                throwDeviceNotFoundException(name);
            }

            return(new Majoro(serialPort));
        }
Esempio n. 6
0
 public void Hello_TestNoDeviceAvailable(string name)
 {
     Assert.Null(Majoro.Hello(name));
 }