Exemplo n.º 1
0
        public void SuspendResumPortOpenClose()
        {
            SuspendResumePort port = new SuspendResumePort(
                delegate { return(new SerialPort()); },
                delegate(Stream stream) { });

            port.Open();
            port.Close();
            Assert.AreEqual(1, port.Opened, "port.Open");
        }
Exemplo n.º 2
0
        public void SuspendResumPortOpenSuspendResumeClose()
        {
            SuspendResumePort port = new SuspendResumePort(
                delegate { return(new SerialPort()); },
                delegate(Stream stream) { });

            port.Open();
            port.Suspend();
            port.Resume(TimeSpan.FromSeconds(0.01));
            Thread.Sleep(500);
            port.Close();
            Assert.AreEqual(2, port.Opened, "port.Open");
        }
Exemplo n.º 3
0
        public void SuspendResumPortOpenRetryClose()
        {
            int invocations = 0;

            SuspendResumePort port = new SuspendResumePort(
                delegate
            {
                invocations++;
                if (invocations == 2)
                {
                    return(new SerialPort());
                }
                return(null);
            },
                delegate(Stream stream) { });

            port.Open();

            Thread.Sleep(3000);

            port.Close();
            Assert.AreEqual(1, port.Opened, "port.Open");
        }