-
Notifications
You must be signed in to change notification settings - Fork 0
/
TraceSourceTest.cs
61 lines (50 loc) 路 1.93 KB
/
TraceSourceTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
锘縰sing Microsoft.VisualStudio.TestTools.UnitTesting;
using Songhay.Diagnostics;
using Songhay.Extensions;
using System;
using System.Diagnostics;
namespace SonghayCore.Framework.Tests
{
[TestClass]
public class TraceSourceTest
{
static TraceSourceTest()
{
traceSource = TraceSources.Instance.GetConfiguredTraceSource();
nullTraceSource = TraceSources.Instance.GetConfiguredTraceSource("wha?");
otherTraceSource = TraceSources.Instance.GetConfiguredTraceSource("other.TraceSourceName");
}
static readonly TraceSource traceSource;
static readonly TraceSource nullTraceSource;
static readonly TraceSource otherTraceSource;
[TestMethod]
public void ShouldHaveConfiguredTraceSources()
{
Assert.IsNotNull(traceSource);
Assert.IsNotNull(otherTraceSource);
using (var listener = new TextWriterTraceListener(Console.Out))
{
traceSource.Listeners.Add(listener);
otherTraceSource.Listeners.Add(listener);
traceSource?.TraceInformation("info!");
otherTraceSource?.TraceInformation("other info!");
traceSource.TraceVerbose("verbose!");
otherTraceSource.TraceVerbose("other verbose!");
traceSource.TraceError("warn!");
otherTraceSource.TraceError("other warn!");
traceSource.TraceError("err!");
otherTraceSource.TraceError("other err!");
listener.Flush();
}
}
[TestMethod]
public void ShouldNotHaveConfiguredTraceSource()
{
Assert.IsNull(nullTraceSource);
nullTraceSource?.TraceInformation("info!");
nullTraceSource.TraceVerbose("info!");
nullTraceSource.TraceWarning("info!");
nullTraceSource.TraceError("info!");
}
}
}