Skip to content

Commit

Permalink
Merge pull request #157 from Umplify/main
Browse files Browse the repository at this point in the history
Making .NET 7.0 the mainstream development
  • Loading branch information
Arash-Sabet authored Feb 18, 2023
2 parents f4c0b94 + c6901bf commit 0b48dff
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 29 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@

# Xunit Dependency Injection framework

*(The source code of the .NET 7.0 version of this library is retained in [the fork of this repo](https://github.com/Umplify/xunit-dependency-injection-NET7) while the .NET 6.0 version of this library is maintained and supported in this repo.)*

---

Xunit does not support any built-in dependency injection features, therefore developers have to come up with a solution to recruit their favourite dependency injection framework in their tests.

This library brings in Microsoft's dependency injection container to Xunit by leveraging Xunit's fixture.
Expand Down
4 changes: 2 additions & 2 deletions azure-pipeline-PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ pool:
steps:
- script: echo Build Number $(name)
- task: UseDotNet@2
displayName: 'Use .NET 6.0 sdk'
displayName: 'Use .NET 7.0 sdk'
inputs:
packageType: sdk
version: 6.0.403
version: 7.0.103
installationPath: $(Agent.ToolsDirectory)/dotnet
- script: echo Started restoring the source code
- task: DotNetCoreCLI@2
Expand Down
10 changes: 8 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
variables:
Major: 7
Minor: 0
BuildConfiguration: Release

name: $(Major).$(Minor).$(rev:r)
pr: none
trigger:
Expand All @@ -16,10 +21,10 @@ pool:
steps:
- script: echo Build Number $(name)
- task: UseDotNet@2
displayName: 'Use .NET 6.0 sdk'
displayName: 'Use .NET 7.0 sdk'
inputs:
packageType: sdk
version: 6.0.403
version: 7.0.103
installationPath: $(Agent.ToolsDirectory)/dotnet
- script: echo Started restoring the source code
- task: DotNetCoreCLI@2
Expand All @@ -37,6 +42,7 @@ steps:
arguments: '--configuration $(BuildConfiguration)'
- task: DotNetCoreCLI@2
displayName: 'Running tests in example folder'
continueOnError: true
inputs:
command: 'test'
projects: '**/examples/Xunit.Microsoft.DependencyInjection.ExampleTests'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" />
<PackageReference Include="coverlet.collector" Version="3.2.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.3" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Abstracts/TestBedFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private IConfigurationRoot GetConfigurationRoot(IEnumerable<TestAppSettings> con
{
foreach (var configurationFile in configurationFiles)
{
ConfigurationBuilder.AddJsonFile(configurationFile.Filename, optional: configurationFile.IsOptional);
ConfigurationBuilder.AddJsonFile(configurationFile.Filename!, optional: configurationFile.IsOptional);
}
ConfigurationBuilder.AddEnvironmentVariables();
return ConfigurationBuilder.Build();
Expand Down
2 changes: 1 addition & 1 deletion src/Logging/NilLoggerProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public void Dispose()

private class NilLogger : ILogger
{
public IDisposable BeginScope<TState>(TState state)
public IDisposable? BeginScope<TState>(TState state) where TState : notnull
=> new NoOpDisposable();

public bool IsEnabled(LogLevel logLevel)
Expand Down
2 changes: 1 addition & 1 deletion src/Logging/OutputLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public OutputLogger(string categoryName, ITestOutputHelper testOutputHelper)
_categoryName = categoryName;
}

public IDisposable BeginScope<TState>(TState state)
public IDisposable? BeginScope<TState>(TState state) where TState : notnull
=> new NoOpDisposable();

public bool IsEnabled(LogLevel logLevel)
Expand Down
22 changes: 11 additions & 11 deletions src/Xunit.Microsoft.DependencyInjection.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0"/>
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0"/>
<PackageReference Include="xunit.abstractions" Version="2.0.3"/>
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="6.0.0"/>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0"/>
<PackageReference Include="xunit.core" Version="2.4.2"/>
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="6.0.1"/>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="xunit.core" Version="2.4.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<None Include="..\README.md" Pack="true" PackagePath="\"/>
<None Include="..\README.md" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup>
<Folder Include="Abstracts\"/>
<Folder Include="TestsOrder\"/>
<Folder Include="Attributes\"/>
<Folder Include="Abstracts\" />
<Folder Include="TestsOrder\" />
<Folder Include="Attributes\" />
</ItemGroup>
</Project>

0 comments on commit 0b48dff

Please sign in to comment.