Skip to content

Commit

Permalink
minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
pwelter34 committed May 4, 2024
1 parent 941d69e commit 90187c2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# XUnit.Hosting

XUnit host builder
6 changes: 3 additions & 3 deletions src/XUnit.Hosting/Logging/MemoryLoggerExtentions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static ILoggingBuilder AddMemoryLogger(this ILoggingBuilder builder)
{
if (builder is null)
throw new ArgumentNullException(nameof(builder));

var descriptor = ServiceDescriptor.Singleton<ILoggerProvider, MemoryLoggerProvider>();

builder.Services.TryAddEnumerable(descriptor);
Expand All @@ -38,7 +38,7 @@ public static ILoggingBuilder AddMemoryLogger(this ILoggingBuilder builder, Memo
throw new ArgumentNullException(nameof(builder));
if (settings is null)
throw new ArgumentNullException(nameof(settings));

var logger = new MemoryLoggerProvider(settings);
var descriptor = ServiceDescriptor.Singleton<ILoggerProvider>(logger);

Expand All @@ -57,7 +57,7 @@ public static ILoggingBuilder AddMemoryLogger(this ILoggingBuilder builder, Acti
{
if (configure is null)
throw new ArgumentNullException(nameof(configure));

builder.AddMemoryLogger();
builder.Services.Configure(configure);

Expand Down
2 changes: 0 additions & 2 deletions src/XUnit.Hosting/Logging/MemoryLoggerSettings.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Runtime.Serialization;

using Microsoft.Extensions.Logging;

namespace XUnit.Hosting.Logging;
Expand Down
7 changes: 3 additions & 4 deletions src/XUnit.Hosting/TestHostFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,21 @@ namespace XUnit.Hosting;
[Obsolete("Use TestApplicationFixture instead")]
public abstract class TestHostFixture : ITestHostFixture
{
private readonly IHostBuilder _builder;
private readonly Lazy<IHost> _host;

/// <summary>
/// Initializes a new instance of the <see cref="TestHostFixture"/> class.
/// </summary>
protected TestHostFixture()
{
_builder = Microsoft.Extensions.Hosting.Host
HostBuilder = Microsoft.Extensions.Hosting.Host
.CreateDefaultBuilder()
.ConfigureAppConfiguration(ConfigureApplication)
.ConfigureLogging(ConfigureLogging)
.ConfigureServices(ConfigureServices);

// trigger start only when host is used
_host = new Lazy<IHost>(_builder.Start);
_host = new Lazy<IHost>(HostBuilder.Start);
}

/// <summary>
Expand All @@ -37,7 +36,7 @@ protected TestHostFixture()
/// <value>
/// The host builder for this test.
/// </value>
protected IHostBuilder HostBuilder => _builder;
protected IHostBuilder HostBuilder { get; }

/// <summary>
/// Gets the host for this test.
Expand Down

0 comments on commit 90187c2

Please sign in to comment.