Пример #1
0
            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();
            }
Пример #2
0
            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();
            }