public void ConstructorShouldOpenPort()
        {
            var serialPort = new MockSerialPort();

            var powerSupply = new PowerSupply(serialPort);

            Assert.That(serialPort.IsOpen);
        }
        public void WritesVoltageValueCorrectToSerialPort()
        {
            var serialPort  = new MockSerialPort();
            var powerSupply = new PowerSupply(serialPort);

            powerSupply.SetVoltage(13.7);

            Assert.That(serialPort.LastWrittenLine, Is.EqualTo("SV137"));
        }
        public void WhenPowerSupplyReturnAnErrorAnErrorNumberExcaptionIsThrown()
        {
            const string ErrorReturnValue = "1";
            var          serialPort       = new MockSerialPort()
            {
                ReadLineData = ErrorReturnValue
            };
            var powerSupply = new PowerSupply(serialPort);

            Assert.Throws <ErrorNumberException>(() => powerSupply.SetVoltage(13.4));
        }