-
Notifications
You must be signed in to change notification settings - Fork 60
/
TestDiscoveryContext.cs
44 lines (38 loc) · 1.18 KB
/
TestDiscoveryContext.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
using AxoCover.Common.Runner;
using AxoCover.Runner.Settings;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
using System.Collections.Concurrent;
namespace AxoCover.Runner
{
public class TestDiscoveryContext :
IDiscoveryContext,
ITestCaseDiscoverySink,
IMessageLogger
{
private readonly ITestDiscoveryMonitor _monitor;
private readonly ConcurrentBag<TestCase> _testCases = new ConcurrentBag<TestCase>();
public IRunSettings RunSettings { get; private set; }
public TestCase[] TestCases
{
get
{
return _testCases.ToArray();
}
}
public TestDiscoveryContext(ITestDiscoveryMonitor monitor, RunSettings runSettings = null)
{
_monitor = monitor;
RunSettings = runSettings ?? new RunSettings();
}
public void SendTestCase(TestCase discoveredTest)
{
_testCases.Add(discoveredTest);
}
public void SendMessage(TestMessageLevel testMessageLevel, string message)
{
_monitor.RecordMessage(testMessageLevel.Convert(), message.PadLinesLeft(" "));
}
}
}