예제 #1
0
        private void toolStripAddCom_Click(object sender, EventArgs e)
        {
            if (dlgNewSerial == null)
            {
                dlgNewSerial = new DebugViewNewSerialForm();
            }

            dlgNewSerial.InitializeUI();

            // add new serial port connection:
            if (dlgNewSerial.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    // create new reference to the serial port:
                    DebugSerialPortSource source = new DebugSerialPortSource(dlgNewSerial.PortName,
                                                                             dlgNewSerial.PortBaudRate, dlgNewSerial.PortEncoding, dlgNewSerial.PortParity,
                                                                             dlgNewSerial.PortDataBits, dlgNewSerial.PortStopBits);

                    // try to start listening and overwrite existing settings of already opened port:
                    if (DebugViewMonitor.AddSource(source, true, true))
                    {
                        MessageBox.Show(SharedStrings.DebugView_SerialPortReplaced, DialogTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                    toolStripCloseSource.Enabled = DebugViewMonitor.Sources.Count > 0;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, DialogTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
예제 #2
0
 public void TestInitialize()
 {
     numberOfMessagesReceived          = 0;
     DebugViewMonitor.ReceivedMessage += ReceivedDebugMessage;
     if (!DebugViewMonitor.Start())
     {
         throw new ApplicationException("Can not start capturing debug messages.");
     }
 }
예제 #3
0
 private void StopGivenSource(IDbgSource s)
 {
     try
     {
         DebugViewMonitor.RemoveSource(s);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, DialogTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #4
0
        public void CaptureMessageFromCustomSource()
        {
            UserDebugSource s = new UserDebugSource("Custom Broadcaster", "My custom source");

            DebugViewMonitor.AddSource(s, false, true);

            s.Write("Message1");
            s.Write("Message2\r\nMessage2a\r\n\r\nMessage2b");
            WaitForResults();

            Assert.IsTrue(numberOfMessagesReceived > 0, "Number of received debug messages should be greater than zero!");
        }
예제 #5
0
        void ReceivedDebugMessage(IList <DebugViewData> items)
        {
            DebugViewMonitor.Stop();

            // write all captured messages:
            if (items != null)
            {
                foreach (DebugViewData d in items)
                {
                    Trace.WriteLine(string.Format("{0}:{1} - {2} - {3}", d.PID, d.ProcessName, d.CreationTime, d.Message));
                }

                numberOfMessagesReceived += items.Count;
            }

            DebugViewMonitor.Start();
        }
예제 #6
0
        public void AddRemoveSources()
        {
            UserDebugSource s1 = new UserDebugSource("S1", "Dummy source 1");
            UserDebugSource s2 = new UserDebugSource("S2", "Dummy source 2");
            UserDebugSource s3 = new UserDebugSource("S3", "Dummy source 3");

            // add sources without overriding the existing ones:
            DebugViewMonitor.RemoveSources();
            DebugViewMonitor.AddSource(s1, false, false);
            DebugViewMonitor.AddSource(s2, false, false);
            DebugViewMonitor.AddSource(s3, false, false);

            IList <IDbgSource> sources = DebugViewMonitor.Sources;

            Assert.IsNotNull(sources, "Number of sources can not be null, because 3 of them has been just added.");
            Assert.IsTrue(sources.Count == 3, "Not 3 sources added!");

            // remove 2 sources:
            DebugViewMonitor.RemoveSource(s1);
            DebugViewMonitor.RemoveSource(s2);

            sources = DebugViewMonitor.Sources;
            Assert.IsNotNull(sources, "Number of sources can not be null, because there is still one added.");
            Assert.IsTrue(sources.Count == 1, "Not 1 sources added!");

            // override, so it will replace the existing element,
            // the detection is based on name:
            UserDebugSource s4 = new UserDebugSource("S3", "Dummy source 3");

            DebugViewMonitor.AddSource(s4, true, false);
            sources = DebugViewMonitor.Sources;
            Assert.IsNotNull(sources, "Number of sources can not be null, because there is still one added.");
            Assert.IsTrue(sources.Count == 1, "Not 1 source added!");

            // add once again the same instance:
            DebugViewMonitor.AddSource(s3, false, false);
            sources = DebugViewMonitor.Sources;
            Assert.IsNotNull(sources, "Number of sources can not be null, because there is still one added.");
            Assert.IsTrue(sources.Count == 1, "Not 1 sources added!");
        }
예제 #7
0
 public void TestCleanUp()
 {
     DebugViewMonitor.Stop();
     DebugViewMonitor.ReceivedMessage -= ReceivedDebugMessage;
 }