Skip to content

Commit adae62a

Browse files
committed
refactor TestHostFixture.cs +semver:skip
1 parent e04ebf9 commit adae62a

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using MartinCostello.Logging.XUnit;
2+
3+
namespace HydraScript.IntegrationTests;
4+
5+
public class ImplicitTestOutputHelperAccessor : ITestOutputHelperAccessor
6+
{
7+
public ITestOutputHelper? OutputHelper
8+
{
9+
get => TestContext.Current.TestOutputHelper;
10+
set { }
11+
}
12+
}

tests/HydraScript.IntegrationTests/TestHostFixture.cs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
using System.IO.Abstractions;
22
using HydraScript.Infrastructure;
3-
using MartinCostello.Logging.XUnit;
43
using Microsoft.Extensions.DependencyInjection;
54
using Microsoft.Extensions.Logging;
65
using NSubstitute;
76

87
namespace HydraScript.IntegrationTests;
98

10-
public class TestHostFixture : IDisposable, ITestOutputHelperAccessor
9+
public class TestHostFixture : IDisposable
1110
{
11+
public const string ScriptFileName = "file";
1212
public record Options(
1313
string FileName = ScriptFileName + ".js",
1414
bool Dump = false,
@@ -27,17 +27,8 @@ public void Dispose()
2727
}
2828

2929
private readonly List<string> _logMessages = [];
30-
31-
public const string ScriptFileName = "file";
32-
3330
public IReadOnlyCollection<string> LogMessages => _logMessages;
3431

35-
public ITestOutputHelper? OutputHelper
36-
{
37-
get => TestContext.Current.TestOutputHelper;
38-
set { }
39-
}
40-
4132
public Runner GetRunner(Options options, Action<IServiceCollection>? configureTestServices = null)
4233
{
4334
var serviceProvider = Program.GetServiceProvider(
@@ -46,7 +37,7 @@ public Runner GetRunner(Options options, Action<IServiceCollection>? configureTe
4637
services =>
4738
{
4839
services.AddLogging(x => x.ClearProviders()
49-
.AddXUnit(this)
40+
.AddXUnit(new ImplicitTestOutputHelperAccessor())
5041
.AddFakeLogging(fakeLogOptions =>
5142
{
5243
fakeLogOptions.OutputSink = logMessage => _logMessages.Add(logMessage);

0 commit comments

Comments
 (0)