示例#1
0
        public void OpenPort()
        {
            if (IsOpen)
            {
                return;
            }

            if (!m_Port.Open(TheProfile, DefaultTimeout))
            {
                OpenPortResult?.Invoke(new TimeoutException("打开端口失败"));
            }
        }
        public void TestOpenClose()
        {
            var mock = new Mock <ISerialPort>();

            using (var port = new AsyncSerialPort(mock.Object))
            {
                port.Open();

                port.Close();
            }

            mock.Verify(x => x.Open(), Times.Once);
            mock.Verify(x => x.Close(), Times.Once);
            mock.Verify(x => x.Dispose(), Times.Once);
            mock.VerifyNoOtherCalls();
        }