DiagnosticsTest.cs
40 lines
| 963 B
| text/x-csharp
|
CSharpLexer
/ Implab.Test / DiagnosticsTest.cs
cin
|
r287 | using System; | |
using System.Threading; | |||
using System.Threading.Tasks; | |||
using Implab.Components; | |||
using Implab.Diagnostics; | |||
using Xunit; | |||
namespace Implab.Test { | |||
public class DiagnosticsTest { | |||
class Foo {} | |||
[Fact] | |||
public void TestRegistration() { | |||
var channel = TraceSourceChannel<Foo>.Default; | |||
Assert.Equal(typeof(Foo), channel.Id); | |||
Assert.Equal(typeof(Foo).FullName, channel.Source.Name); | |||
TraceSourceChannel found = null; | |||
int visited = 0; | |||
TraceRegistry.Global.Subscribe(x => { | |||
visited++; | |||
found = x as TraceSourceChannel; | |||
}, false); | |||
Assert.Equal(0, visited); | |||
TraceRegistry.Global.Subscribe(x => { | |||
visited++; | |||
found = x as TraceSourceChannel; | |||
}, true); | |||
Assert.Equal(1,visited); | |||
Assert.Equal(channel, found); | |||
} | |||
} | |||
} |