view Implab.Test/UnitTest1.cs @ 255:b00441e04738 v3

Adde workaround to the behaviour of the logical operations stack in conjuction with async/await methods
author cin
date Wed, 04 Apr 2018 15:38:48 +0300
parents 34df34841225
children c52691faaf21
line wrap: on
line source

using System;
using System.Diagnostics;
using System.Threading;
using Implab.Diagnostics;
using Xunit;

namespace Implab.Test {
    using System.Threading.Tasks;
    using static Trace<UnitTest1>;
    public class UnitTest1 {
        [Fact]
        public async Task Test1() {
            var listener = new SimpleTraceListener(Console.Out);

            var source = TraceSource;
            source.Switch.Level = SourceLevels.All;

            source.Listeners.Add(listener);

            using (var op = LogicalOperation(nameof(Test1)))
            using (LogicalOperation("InnerOperation")){
                await Task.Yield();
                Log("Inner");
                await Task.Yield();
                Log("source event");
            }
        }
    }
}