diff --git a/examples/Xunit.Microsoft.DependencyInjection.ExampleTests/Services/Calculator.cs b/examples/Xunit.Microsoft.DependencyInjection.ExampleTests/Services/Calculator.cs index ce4f2a0..c14c526 100644 --- a/examples/Xunit.Microsoft.DependencyInjection.ExampleTests/Services/Calculator.cs +++ b/examples/Xunit.Microsoft.DependencyInjection.ExampleTests/Services/Calculator.cs @@ -3,13 +3,10 @@ namespace Xunit.Microsoft.DependencyInjection.ExampleTests.Services; -public class Calculator : ICalculator +public class Calculator(ILogger logger, IOptions option) : ICalculator { - private readonly Options _option; - private readonly ILogger _logger; - - public Calculator(ILogger logger, IOptions option) - => (_logger, _option) = (logger, option.Value); + private readonly Options _option = option.Value; + private readonly ILogger _logger = logger; public Task AddAsync(int x, int y) { diff --git a/examples/Xunit.Microsoft.DependencyInjection.ExampleTests/Xunit.Microsoft.DependencyInjection.ExampleTests.csproj b/examples/Xunit.Microsoft.DependencyInjection.ExampleTests/Xunit.Microsoft.DependencyInjection.ExampleTests.csproj index 44b4ed5..652a152 100644 --- a/examples/Xunit.Microsoft.DependencyInjection.ExampleTests/Xunit.Microsoft.DependencyInjection.ExampleTests.csproj +++ b/examples/Xunit.Microsoft.DependencyInjection.ExampleTests/Xunit.Microsoft.DependencyInjection.ExampleTests.csproj @@ -27,7 +27,6 @@ - diff --git a/src/Abstracts/TestBed.cs b/src/Abstracts/TestBed.cs index 61170e5..67d8713 100644 --- a/src/Abstracts/TestBed.cs +++ b/src/Abstracts/TestBed.cs @@ -1,16 +1,13 @@ namespace Xunit.Microsoft.DependencyInjection.Abstracts; -public class TestBed : IDisposable, IClassFixture, IAsyncDisposable +public class TestBed(ITestOutputHelper testOutputHelper, TFixture fixture) : IDisposable, IClassFixture, IAsyncDisposable where TFixture : class { - protected readonly ITestOutputHelper _testOutputHelper; - protected readonly TFixture _fixture; + protected readonly ITestOutputHelper _testOutputHelper = testOutputHelper; + protected readonly TFixture _fixture = fixture; private bool _disposedValue; private bool _disposedAsync; - public TestBed(ITestOutputHelper testOutputHelper, TFixture fixture) - => (_testOutputHelper, _fixture) = (testOutputHelper, fixture); - protected virtual void Dispose(bool disposing) { if (!_disposedValue) diff --git a/src/Attributes/TestOrderAttribute.cs b/src/Attributes/TestOrderAttribute.cs index 8c8aa63..49976c1 100644 --- a/src/Attributes/TestOrderAttribute.cs +++ b/src/Attributes/TestOrderAttribute.cs @@ -1,10 +1,7 @@ namespace Xunit.Microsoft.DependencyInjection.Attributes; [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] -public class TestOrderAttribute : Attribute +public class TestOrderAttribute(int priority) : Attribute { - public TestOrderAttribute(int priority) - => Priority = priority; - - public int Priority { get; } + public int Priority { get; } = priority; } diff --git a/src/Logging/OutputLogger.cs b/src/Logging/OutputLogger.cs index 99543db..b6d3a72 100644 --- a/src/Logging/OutputLogger.cs +++ b/src/Logging/OutputLogger.cs @@ -1,21 +1,15 @@ namespace Xunit.Microsoft.DependencyInjection.Logging; -public class OutputLogger : ILogger +public class OutputLogger(string categoryName, ITestOutputHelper testOutputHelper) : ILogger { - private readonly ITestOutputHelper _testOutputHelper; - private readonly string _categoryName; + private readonly ITestOutputHelper _testOutputHelper = testOutputHelper; + private readonly string _categoryName = categoryName; public OutputLogger(ITestOutputHelper testOutputHelper) : this("Tests", testOutputHelper) { } - public OutputLogger(string categoryName, ITestOutputHelper testOutputHelper) - { - _testOutputHelper = testOutputHelper; - _categoryName = categoryName; - } - public IDisposable? BeginScope(TState state) where TState : notnull => new NoOpDisposable(); diff --git a/src/Logging/OutputLoggerProvider.cs b/src/Logging/OutputLoggerProvider.cs index 5eb5d94..6a02b0e 100644 --- a/src/Logging/OutputLoggerProvider.cs +++ b/src/Logging/OutputLoggerProvider.cs @@ -1,11 +1,8 @@ namespace Xunit.Microsoft.DependencyInjection.Logging; -public class OutputLoggerProvider : ILoggerProvider +public class OutputLoggerProvider(ITestOutputHelper testOutputHelper) : ILoggerProvider { - private readonly ITestOutputHelper _testOutputHelper; - - public OutputLoggerProvider(ITestOutputHelper testOutputHelper) - => _testOutputHelper = testOutputHelper; + private readonly ITestOutputHelper _testOutputHelper = testOutputHelper; public ILogger CreateLogger(string categoryName) => new OutputLogger(categoryName, _testOutputHelper);