public void CallsOpenOnSerialPortForClosedPort() { var serialPort = new Mock <ISerialPort>(); var target = new BrickPiRaw(serialPort.Object); serialPort.Setup(x => x.Open()).Verifiable(); serialPort.Setup(x => x.IsOpen).Returns(false).Verifiable(); target.Open(); Assert.IsNotNull(target); serialPort.Verify(); }
public void NotCallsOpenOnSerialPortForOpenPort() { var serialPort = new Mock <ISerialPort>(); var target = new BrickPiRaw(serialPort.Object); var called = false; serialPort.Setup(x => x.Open()).Callback(() => called = true); serialPort.Setup(x => x.IsOpen).Returns(true).Verifiable(); target.Open(); Assert.IsNotNull(target); Assert.IsFalse(called); serialPort.Verify(); }