Beispiel #1
0
        public void NetTrace_Default_Config()
        {
            _NetTraceSink  sink;
            NetTracePacket packet;

            try
            {
                sink = new _NetTraceSink();
                Config.SetConfig(null);
                NetTrace.Start();
                NetTrace.Enable("subsystem", 10);

                NetTraceSink.Start(new NetTraceSinkDelegate(sink.OnReceive));

                NetTrace.Write("subsystem", 10, "event", "summary", "details");
                sink.Wait(1);
                packet = sink.Dequeue();

                Assert.AreEqual("subsystem", packet.Subsystem);
                Assert.AreEqual(10, packet.Detail);
                Assert.AreEqual("event", packet.Event);
                Assert.AreEqual("summary", packet.Summary);
                Assert.AreEqual("details", packet.Details);
            }
            finally
            {
                NetTrace.Stop();
            }
        }
Beispiel #2
0
        public void NetTrace_Setting_Config()
        {
            _NetTraceSink  sink;
            NetTracePacket packet;

            try
            {
                sink = new _NetTraceSink();
                Config.SetConfig(@"

Diagnostics.TraceEP        = 231.222.0.77:44411
Diagnostics.TraceAdapter   = $(ip-address)
Diagnostics.TraceEnable[0] = 255:subsystem
");

                NetTrace.Start();
                NetTraceSink.Start(new NetTraceSinkDelegate(sink.OnReceive));

                NetTrace.Write("subsystem", 255, "event", "summary", "details");
                sink.Wait(1);
                packet = sink.Dequeue();

                Assert.AreEqual("subsystem", packet.Subsystem);
                Assert.AreEqual(255, packet.Detail);
                Assert.AreEqual("event", packet.Event);
                Assert.AreEqual("summary", packet.Summary);
                Assert.AreEqual("details", packet.Details);
                Assert.AreEqual(44411, packet.SourceEP.Port);
            }
            finally
            {
                NetTrace.Stop();
            }
        }