UnitTest1.cs
40 lines
| 1.6 KiB
| text/x-csharp
|
CSharpLexer
/ Implab.Test / UnitTest1.cs
cin
|
r249 | using System; | ||
cin
|
r251 | using System.Diagnostics; | ||
cin
|
r249 | using System.Threading; | ||
cin
|
r252 | using Implab.Diagnostics; | ||
cin
|
r256 | using System.Linq; | ||
cin
|
r249 | using Xunit; | ||
cin
|
r253 | namespace Implab.Test { | ||
using System.Threading.Tasks; | ||||
cin
|
r252 | using static Trace<UnitTest1>; | ||
cin
|
r253 | public class UnitTest1 { | ||
cin
|
r249 | [Fact] | ||
cin
|
r253 | public async Task Test1() { | ||
var listener = new SimpleTraceListener(Console.Out); | ||||
cin
|
r256 | listener.TraceOutputOptions |= TraceOptions.ThreadId; | ||
cin
|
r253 | |||
cin
|
r252 | var source = TraceSource; | ||
source.Switch.Level = SourceLevels.All; | ||||
cin
|
r251 | |||
source.Listeners.Add(listener); | ||||
cin
|
r256 | using (LogicalOperation("Test1")){ | ||
cin
|
r253 | await Task.Yield(); | ||
cin
|
r256 | 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()))); | ||||
cin
|
r253 | } | ||
cin
|
r249 | } | ||
cin
|
r256 | |||
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()))); | ||||
} | ||||
cin
|
r249 | } | ||
} | ||||