public void Close_IsIdempotent()
        {
            using (var receiver = new StandardOutputReceiver(Mock.Of <IPluginProcess>()))
            {
                receiver.Connect();

                receiver.Close();
                receiver.Close();
            }
        }
 public void Close_CanBeCalledWithoutConnectAsync()
 {
     using (var receiver = new StandardOutputReceiver(Mock.Of <IPluginProcess>()))
     {
         receiver.Close();
     }
 }
        public void Connect_ThrowsIfClosed()
        {
            using (var receiver = new StandardOutputReceiver(Mock.Of <IPluginProcess>()))
            {
                receiver.Close();

                Assert.Throws <InvalidOperationException>(() => receiver.Connect());
            }
        }
        public void Close_CancelsReading()
        {
            var process = new Mock <IPluginProcess>(MockBehavior.Strict);

            process.Setup(x => x.BeginReadLine());
            process.Setup(x => x.CancelRead());

            using (var receiver = new StandardOutputReceiver(process.Object))
            {
                receiver.Connect();
                receiver.Close();
            }

            process.Verify(x => x.CancelRead(), Times.Once);
        }