Files
speckle.xunit.runner.wpf/xunit.runner.worker/TestDiscoverySink.cs
T
Dustin Campbell 96428a7a96 Improve start up performance of test runs
Before a test run, we collect all of the test cases to use in the run. Unfortuantely, we were using the same slower test discovery mechanism that we previously used when loading test assemblies. This change switches that code path to use the faster mechanism that we've already put in place.
2015-11-05 06:56:58 -08:00

43 lines
1.0 KiB
C#

using System;
using System.Threading;
using Xunit;
using Xunit.Abstractions;
namespace xunit.runner.worker
{
internal abstract class TestDiscoverySink : LongLivedMarshalByRefObject, IMessageSink, IDisposable
{
public ManualResetEvent Finished { get; }
protected TestDiscoverySink()
{
Finished = new ManualResetEvent(false);
}
public bool OnMessage(IMessageSinkMessage message)
{
var discoveryMessage = message as ITestCaseDiscoveryMessage;
if (discoveryMessage != null)
{
OnTestDiscovered(discoveryMessage);
}
if (message is IDiscoveryCompleteMessage)
{
Finished.Set();
}
return ShouldContinue;
}
protected virtual bool ShouldContinue => true;
protected abstract void OnTestDiscovered(ITestCaseDiscoveryMessage testCaseDiscovered);
public void Dispose()
{
Finished.Dispose();
}
}
}