diff Implab.Test/UnitTest1.cs @ 256:c52691faaf21 v3

Removed obsolete App, ComponentContainer Extracted IAsyncComponent interface Working on RunnableComponent
author cin
date Wed, 11 Apr 2018 03:05:14 +0300
parents 34df34841225
children
line wrap: on
line diff
--- a/Implab.Test/UnitTest1.cs	Wed Apr 04 15:38:48 2018 +0300
+++ b/Implab.Test/UnitTest1.cs	Wed Apr 11 03:05:14 2018 +0300
@@ -2,6 +2,7 @@
 using System.Diagnostics;
 using System.Threading;
 using Implab.Diagnostics;
+using System.Linq;
 using Xunit;
 
 namespace Implab.Test {
@@ -11,19 +12,29 @@
         [Fact]
         public async Task Test1() {
             var listener = new SimpleTraceListener(Console.Out);
+            listener.TraceOutputOptions |= TraceOptions.ThreadId;
 
             var source = TraceSource;
             source.Switch.Level = SourceLevels.All;
 
             source.Listeners.Add(listener);
 
-            using (var op = LogicalOperation(nameof(Test1)))
-            using (LogicalOperation("InnerOperation")){
+            using (LogicalOperation("Test1")){
                 await Task.Yield();
-                Log("Inner");
-                await Task.Yield();
-                Log("source event");
+                Log(String.Join(", ", Trace.CorrelationManager.LogicalOperationStack.Cast<object>().Select(x => x.ToString())));
+                await AsyncDummy();
+                Log(String.Join(", ", Trace.CorrelationManager.LogicalOperationStack.Cast<object>().Select(x => x.ToString())));
             }
         }
+
+        async Task AsyncDummy() {
+            using(LogicalOperation("OuterDummy"))
+            using(LogicalOperation("InnerDummy")) {
+                Log(String.Join(", ", Trace.CorrelationManager.LogicalOperationStack.Cast<object>().Select(x => x.ToString())));
+                await Task.Delay(1);
+                Log(String.Join(", ", Trace.CorrelationManager.LogicalOperationStack.Cast<object>().Select(x => x.ToString())));
+            }
+            Log(String.Join(", ", Trace.CorrelationManager.LogicalOperationStack.Cast<object>().Select(x => x.ToString())));
+        }
     }
 }