Beispiel #1
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!");
        }
Beispiel #2
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!");
        }