diff Implab.Test/UnitTest1.cs @ 253:34df34841225 v3 v3.0.1-beta

Implab.Diagnostics drafts
author cin
date Mon, 12 Feb 2018 17:03:37 +0300
parents 6f4630d0bcd9
children c52691faaf21
line wrap: on
line diff
--- a/Implab.Test/UnitTest1.cs	Mon Feb 12 07:24:31 2018 +0300
+++ b/Implab.Test/UnitTest1.cs	Mon Feb 12 17:03:37 2018 +0300
@@ -4,34 +4,26 @@
 using Implab.Diagnostics;
 using Xunit;
 
-namespace Implab.Test
-{
+namespace Implab.Test {
+    using System.Threading.Tasks;
     using static Trace<UnitTest1>;
-    public class UnitTest1
-    {
+    public class UnitTest1 {
         [Fact]
-        public void Test1()
-        {
-            var listener = new TextWriterTraceListener(Console.Out);
+        public async Task Test1() {
+            var listener = new SimpleTraceListener(Console.Out);
+
             var source = TraceSource;
             source.Switch.Level = SourceLevels.All;
 
             source.Listeners.Add(listener);
-            Trace.Listeners.Add(listener);
 
-            Trace.WriteLine("Hello!");
-            StartLogicalOperation();
-
-            Trace.WriteLine("Inner");
-            foreach(var x in Trace.CorrelationManager.LogicalOperationStack)
-                Trace.WriteLine($"-{x}");
-            Log("source event");
-
-            listener.IndentLevel = 1;
-
-            source.TraceData(TraceEventType.Start, 1, DateTime.Now);
-            
-            StopLogicalOperation();
+            using (var op = LogicalOperation(nameof(Test1)))
+            using (LogicalOperation("InnerOperation")){
+                await Task.Yield();
+                Log("Inner");
+                await Task.Yield();
+                Log("source event");
+            }
         }
     }
 }