Skip to content

Commit 125be04

Browse files
authored
Upgrade project and .NET version (#44)
1 parent 6e12d93 commit 125be04

45 files changed

Lines changed: 146 additions & 971 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 27 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,65 +2,55 @@ name: Build
22

33
on:
44
push:
5-
branches: main
6-
tags: '**'
5+
branches:
6+
- main
7+
tags:
8+
- '**'
79
pull_request:
810

911
jobs:
1012
format:
1113
runs-on: ubuntu-latest
1214
steps:
1315
- name: Checkout
14-
uses: actions/checkout@v1
15-
- name: Setup .NET 6.0
16-
uses: actions/setup-dotnet@v1
16+
uses: actions/checkout@v4
17+
- name: Setup .NET 9.0
18+
uses: actions/setup-dotnet@v4
1719
with:
18-
dotnet-version: 6.0.x
19-
- name: Install dotnet-format
20-
run: dotnet tool install --global dotnet-format
20+
dotnet-version: 9.0.x
2121
- name: Format
22-
run: dotnet format --verify-no-changes MELT.sln
22+
run: dotnet format --verify-no-changes MELT.CI.slnf
2323
build:
2424
runs-on: ubuntu-latest
2525
steps:
2626
- name: Checkout
27-
uses: actions/checkout@v1
28-
- name: Setup .NET Core 2.1
29-
uses: actions/setup-dotnet@v1
27+
uses: actions/checkout@v4
28+
- name: Setup .NET 9.0
29+
uses: actions/setup-dotnet@v4
3030
with:
31-
dotnet-version: 2.1.x
32-
- name: Setup .NET Core 3.1
33-
uses: actions/setup-dotnet@v1
34-
with:
35-
dotnet-version: 3.1.x
36-
- name: Setup .NET 5.0
37-
uses: actions/setup-dotnet@v1
38-
with:
39-
dotnet-version: 5.0.x
40-
- name: Setup .NET 6.0
41-
uses: actions/setup-dotnet@v1
42-
with:
43-
dotnet-version: 6.0.x
31+
dotnet-version: 9.0.x
4432
- name: Build
45-
run: dotnet build --configuration Release
33+
run: dotnet build --configuration Release MELT.CI.slnf
4634
- name: Test
47-
run: dotnet test --no-build --configuration Release
35+
run: dotnet test --no-build --configuration Release MELT.CI.slnf
4836
pack:
4937
runs-on: ubuntu-latest
5038
needs: build
5139
if: github.event_name == 'push'
5240
steps:
5341
- name: Checkout
54-
uses: actions/checkout@v1
55-
- name: Setup .NET 6.0
56-
uses: actions/setup-dotnet@v1
42+
uses: actions/checkout@v4
43+
with:
44+
fetch-depth: 0
45+
- name: Setup .NET 9.0
46+
uses: actions/setup-dotnet@v4
5747
with:
58-
dotnet-version: 6.0.x
48+
dotnet-version: 9.0.x
5949
- name: Determine version
6050
run: echo "VERSION=$(git describe --tags --dirty)" >> $GITHUB_ENV
6151
- name: Pack
62-
run: dotnet pack --output ./artifacts --configuration Release -p:Version=$VERSION
63-
- uses: actions/upload-artifact@v1
52+
run: dotnet pack --output ./artifacts --configuration Release -p:Version=$VERSION MELT.CI.slnf
53+
- uses: actions/upload-artifact@v4
6454
with:
6555
name: artifacts
6656
path: ./artifacts
@@ -69,11 +59,11 @@ jobs:
6959
needs: pack
7060
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
7161
steps:
72-
- name: Setup .NET 6.0
73-
uses: actions/setup-dotnet@v1
62+
- name: Setup .NET 9.0
63+
uses: actions/setup-dotnet@v4
7464
with:
75-
dotnet-version: 6.0.x
76-
- uses: actions/download-artifact@v1
65+
dotnet-version: 9.0.x
66+
- uses: actions/download-artifact@v4
7767
with:
7868
name: artifacts
7969
path: ./artifacts

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
55
<WarningsNotAsErrors>612;618</WarningsNotAsErrors>
6-
<LangVersion>8.0</LangVersion>
6+
<LangVersion>default</LangVersion>
77
<Nullable>Enable</Nullable>
88
<SignAssembly>true</SignAssembly>
99
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)/keypair.snk</AssemblyOriginatorKeyFile>

MELT.CI.slnf

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"solution": {
3+
"path": "MELT.sln",
4+
"projects": [
5+
"samples\\current\\NLog\\SampleWebApplicationNLog.IntegrationTests\\SampleWebApplicationNLog.IntegrationTests.csproj",
6+
"samples\\current\\NLog\\SampleWebApplicationNLog\\SampleWebApplicationNLog.csproj",
7+
"samples\\current\\SampleLibrary.Tests\\SampleLibrary.Tests.csproj",
8+
"samples\\current\\SampleLibrary\\SampleLibrary.csproj",
9+
"samples\\current\\SampleWebApplication.IntegrationTests\\SampleWebApplication.IntegrationTests.csproj",
10+
"samples\\current\\SampleWebApplication\\SampleWebApplication.csproj",
11+
"samples\\current\\serilog\\SampleWebApplicationSerilog.IntegrationTests\\SampleWebApplicationSerilog.IntegrationTests.csproj",
12+
"samples\\current\\serilog\\SampleWebApplicationSerilogAlternate.IntegrationTests\\SampleWebApplicationSerilogAlternate.IntegrationTests.csproj",
13+
"samples\\current\\serilog\\SampleWebApplicationSerilogAlternate\\SampleWebApplicationSerilogAlternate.csproj",
14+
"samples\\current\\serilog\\SampleWebApplicationSerilog\\SampleWebApplicationSerilog.csproj",
15+
"samples\\legacy\\SampleLibrary.HandRolledTests\\SampleLibrary.HandRolledTests.csproj",
16+
"samples\\legacy\\SampleLibrary.LegacyTests\\SampleLibrary.LegacyTests.csproj",
17+
"samples\\xunit-2.4.2\\SampleLibraryX.Tests\\SampleLibraryX.Tests.csproj",
18+
"samples\\xunit-2.4.2\\SampleLibraryX\\SampleLibraryX.csproj",
19+
"src\\MELT.AspNetCore\\MELT.AspNetCore.csproj",
20+
"src\\MELT.Serilog.AspNetCore\\MELT.Serilog.AspNetCore.csproj",
21+
"src\\MELT.Serilog\\MELT.Serilog.csproj",
22+
"src\\MELT.Xunit\\MELT.Xunit.csproj",
23+
"src\\MELT\\MELT.csproj",
24+
"test\\MELT.Tests\\MELT.Tests.csproj",
25+
"test\\MELT.Xunit.Tests\\MELT.Xunit.Tests.csproj"
26+
]
27+
}
28+
}

MELT.sln

Lines changed: 14 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleLibrary.LegacyTests",
5757
EndProject
5858
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleLibrary.HandRolledTests", "samples\legacy\SampleLibrary.HandRolledTests\SampleLibrary.HandRolledTests.csproj", "{3AF86936-883E-4688-B894-9AD226346056}"
5959
EndProject
60-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleWebApplication3_1.LegacyIntegrationTests", "samples\legacy\SampleWebApplication3_1.LegacyIntegrationTests\SampleWebApplication3_1.LegacyIntegrationTests.csproj", "{D9095000-1F72-41D5-96CE-8FF8E1F177F8}"
61-
EndProject
6260
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleWebApplication2_1", "samples\2.1\SampleWebApplication2_1\SampleWebApplication2_1.csproj", "{AA0655FF-BBA0-47ED-B7C6-85CFFD3E491D}"
6361
EndProject
6462
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleWebApplication2_1.IntegrationTests", "samples\2.1\SampleWebApplication2_1.IntegrationTests\SampleWebApplication2_1.IntegrationTests.csproj", "{A4CFAADC-BFE3-4ED0-8F44-944F0E65A83B}"
@@ -69,22 +67,16 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleWebApplicationNLog",
6967
EndProject
7068
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleWebApplicationNLog.IntegrationTests", "samples\current\NLog\SampleWebApplicationNLog.IntegrationTests\SampleWebApplicationNLog.IntegrationTests.csproj", "{F8FE8604-86EE-42CE-91FA-1ACBDA83F9A2}"
7169
EndProject
72-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "3.1", "3.1", "{E77E65BC-8A95-4113-BB22-BE56D6226157}"
73-
EndProject
74-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleWebApplication3_1", "samples\3.1\SampleWebApplication3_1\SampleWebApplication3_1.csproj", "{8C899E89-0F38-4696-B9DB-311BFB6D1E33}"
75-
EndProject
76-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleWebApplication3_1.IntegrationTests", "samples\3.1\SampleWebApplication3_1.IntegrationTests\SampleWebApplication3_1.IntegrationTests.csproj", "{E37446E1-7760-4AD0-B703-B635454E5B3C}"
77-
EndProject
78-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleWebApplication", "samples\current\SampleWebApplication\SampleWebApplication.csproj", "{975360DF-04D6-41AB-84EE-3AE5D7A5B2DA}"
79-
EndProject
80-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleWebApplication.IntegrationTests", "samples\current\SampleWebApplication.IntegrationTests\SampleWebApplication.IntegrationTests.csproj", "{008667F2-0263-4A13-B9F2-BA10D948EBDB}"
81-
EndProject
8270
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "xunit-2.4.2", "xunit-2.4.2", "{ABCE4D92-5106-4849-BCD2-88472585C07F}"
8371
EndProject
8472
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleLibraryX", "samples\xunit-2.4.2\SampleLibraryX\SampleLibraryX.csproj", "{97C0C780-AF0B-4103-9315-002899C32BE8}"
8573
EndProject
8674
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleLibraryX.Tests", "samples\xunit-2.4.2\SampleLibraryX.Tests\SampleLibraryX.Tests.csproj", "{8990E486-C322-4741-97D0-94AA7D9F3323}"
8775
EndProject
76+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleWebApplication", "samples\current\SampleWebApplication\SampleWebApplication.csproj", "{38A0B1F0-26FC-42CE-AD6D-5165C95B927E}"
77+
EndProject
78+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleWebApplication.IntegrationTests", "samples\current\SampleWebApplication.IntegrationTests\SampleWebApplication.IntegrationTests.csproj", "{2CF731D4-58CD-4173-82BA-D4A2018A5165}"
79+
EndProject
8880
Global
8981
GlobalSection(SolutionConfigurationPlatforms) = preSolution
9082
Debug|Any CPU = Debug|Any CPU
@@ -151,10 +143,6 @@ Global
151143
{3AF86936-883E-4688-B894-9AD226346056}.Debug|Any CPU.Build.0 = Debug|Any CPU
152144
{3AF86936-883E-4688-B894-9AD226346056}.Release|Any CPU.ActiveCfg = Release|Any CPU
153145
{3AF86936-883E-4688-B894-9AD226346056}.Release|Any CPU.Build.0 = Release|Any CPU
154-
{D9095000-1F72-41D5-96CE-8FF8E1F177F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
155-
{D9095000-1F72-41D5-96CE-8FF8E1F177F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
156-
{D9095000-1F72-41D5-96CE-8FF8E1F177F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
157-
{D9095000-1F72-41D5-96CE-8FF8E1F177F8}.Release|Any CPU.Build.0 = Release|Any CPU
158146
{AA0655FF-BBA0-47ED-B7C6-85CFFD3E491D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
159147
{AA0655FF-BBA0-47ED-B7C6-85CFFD3E491D}.Debug|Any CPU.Build.0 = Debug|Any CPU
160148
{AA0655FF-BBA0-47ED-B7C6-85CFFD3E491D}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -171,22 +159,6 @@ Global
171159
{F8FE8604-86EE-42CE-91FA-1ACBDA83F9A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
172160
{F8FE8604-86EE-42CE-91FA-1ACBDA83F9A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
173161
{F8FE8604-86EE-42CE-91FA-1ACBDA83F9A2}.Release|Any CPU.Build.0 = Release|Any CPU
174-
{8C899E89-0F38-4696-B9DB-311BFB6D1E33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
175-
{8C899E89-0F38-4696-B9DB-311BFB6D1E33}.Debug|Any CPU.Build.0 = Debug|Any CPU
176-
{8C899E89-0F38-4696-B9DB-311BFB6D1E33}.Release|Any CPU.ActiveCfg = Release|Any CPU
177-
{8C899E89-0F38-4696-B9DB-311BFB6D1E33}.Release|Any CPU.Build.0 = Release|Any CPU
178-
{E37446E1-7760-4AD0-B703-B635454E5B3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
179-
{E37446E1-7760-4AD0-B703-B635454E5B3C}.Debug|Any CPU.Build.0 = Debug|Any CPU
180-
{E37446E1-7760-4AD0-B703-B635454E5B3C}.Release|Any CPU.ActiveCfg = Release|Any CPU
181-
{E37446E1-7760-4AD0-B703-B635454E5B3C}.Release|Any CPU.Build.0 = Release|Any CPU
182-
{975360DF-04D6-41AB-84EE-3AE5D7A5B2DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
183-
{975360DF-04D6-41AB-84EE-3AE5D7A5B2DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
184-
{975360DF-04D6-41AB-84EE-3AE5D7A5B2DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
185-
{975360DF-04D6-41AB-84EE-3AE5D7A5B2DA}.Release|Any CPU.Build.0 = Release|Any CPU
186-
{008667F2-0263-4A13-B9F2-BA10D948EBDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
187-
{008667F2-0263-4A13-B9F2-BA10D948EBDB}.Debug|Any CPU.Build.0 = Debug|Any CPU
188-
{008667F2-0263-4A13-B9F2-BA10D948EBDB}.Release|Any CPU.ActiveCfg = Release|Any CPU
189-
{008667F2-0263-4A13-B9F2-BA10D948EBDB}.Release|Any CPU.Build.0 = Release|Any CPU
190162
{97C0C780-AF0B-4103-9315-002899C32BE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
191163
{97C0C780-AF0B-4103-9315-002899C32BE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
192164
{97C0C780-AF0B-4103-9315-002899C32BE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -195,6 +167,14 @@ Global
195167
{8990E486-C322-4741-97D0-94AA7D9F3323}.Debug|Any CPU.Build.0 = Debug|Any CPU
196168
{8990E486-C322-4741-97D0-94AA7D9F3323}.Release|Any CPU.ActiveCfg = Release|Any CPU
197169
{8990E486-C322-4741-97D0-94AA7D9F3323}.Release|Any CPU.Build.0 = Release|Any CPU
170+
{38A0B1F0-26FC-42CE-AD6D-5165C95B927E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
171+
{38A0B1F0-26FC-42CE-AD6D-5165C95B927E}.Debug|Any CPU.Build.0 = Debug|Any CPU
172+
{38A0B1F0-26FC-42CE-AD6D-5165C95B927E}.Release|Any CPU.ActiveCfg = Release|Any CPU
173+
{38A0B1F0-26FC-42CE-AD6D-5165C95B927E}.Release|Any CPU.Build.0 = Release|Any CPU
174+
{2CF731D4-58CD-4173-82BA-D4A2018A5165}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
175+
{2CF731D4-58CD-4173-82BA-D4A2018A5165}.Debug|Any CPU.Build.0 = Debug|Any CPU
176+
{2CF731D4-58CD-4173-82BA-D4A2018A5165}.Release|Any CPU.ActiveCfg = Release|Any CPU
177+
{2CF731D4-58CD-4173-82BA-D4A2018A5165}.Release|Any CPU.Build.0 = Release|Any CPU
198178
EndGlobalSection
199179
GlobalSection(SolutionProperties) = preSolution
200180
HideSolutionNode = FALSE
@@ -219,20 +199,16 @@ Global
219199
{97F8FA44-188A-4DAF-B5A8-F8A2C70F7833} = {C4E22338-78A9-4E60-BCFE-36AE33B3803A}
220200
{83DA6150-46F6-4BDC-AE7F-8C8F877442BA} = {6A9FF42F-4F1A-48E6-8288-1F35AF1242DD}
221201
{3AF86936-883E-4688-B894-9AD226346056} = {6A9FF42F-4F1A-48E6-8288-1F35AF1242DD}
222-
{D9095000-1F72-41D5-96CE-8FF8E1F177F8} = {6A9FF42F-4F1A-48E6-8288-1F35AF1242DD}
223202
{AA0655FF-BBA0-47ED-B7C6-85CFFD3E491D} = {A504AB4E-DD04-4249-810F-211C3DD3F4AD}
224203
{A4CFAADC-BFE3-4ED0-8F44-944F0E65A83B} = {A504AB4E-DD04-4249-810F-211C3DD3F4AD}
225204
{657E6E3B-D172-417A-9094-C215580E5AD9} = {F08BF453-6A58-486F-8D06-FF08A82D386B}
226205
{283E94A6-CD98-46DD-BF88-0207D0004885} = {657E6E3B-D172-417A-9094-C215580E5AD9}
227206
{F8FE8604-86EE-42CE-91FA-1ACBDA83F9A2} = {657E6E3B-D172-417A-9094-C215580E5AD9}
228-
{E77E65BC-8A95-4113-BB22-BE56D6226157} = {B33EF166-2895-47CF-BF2C-740C271A250E}
229-
{8C899E89-0F38-4696-B9DB-311BFB6D1E33} = {E77E65BC-8A95-4113-BB22-BE56D6226157}
230-
{E37446E1-7760-4AD0-B703-B635454E5B3C} = {E77E65BC-8A95-4113-BB22-BE56D6226157}
231-
{975360DF-04D6-41AB-84EE-3AE5D7A5B2DA} = {F08BF453-6A58-486F-8D06-FF08A82D386B}
232-
{008667F2-0263-4A13-B9F2-BA10D948EBDB} = {F08BF453-6A58-486F-8D06-FF08A82D386B}
233207
{ABCE4D92-5106-4849-BCD2-88472585C07F} = {B33EF166-2895-47CF-BF2C-740C271A250E}
234208
{97C0C780-AF0B-4103-9315-002899C32BE8} = {ABCE4D92-5106-4849-BCD2-88472585C07F}
235209
{8990E486-C322-4741-97D0-94AA7D9F3323} = {ABCE4D92-5106-4849-BCD2-88472585C07F}
210+
{38A0B1F0-26FC-42CE-AD6D-5165C95B927E} = {F08BF453-6A58-486F-8D06-FF08A82D386B}
211+
{2CF731D4-58CD-4173-82BA-D4A2018A5165} = {F08BF453-6A58-486F-8D06-FF08A82D386B}
236212
EndGlobalSection
237213
GlobalSection(ExtensibilityGlobals) = postSolution
238214
SolutionGuid = {954CCC12-511A-4435-AE51-C19A527D4654}

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# MELT
22

33
<!-- markdownlint-disable no-inline-html -->
4-
<img align="right" width="256" height="256" src="logo_large.png">
4+
<img align="right" width="256" height="256" src="logo_large.png" alt="A stylized 3D tree with golden-yellow spherical foliage on a wooden stump against a purple background">
55
<!-- markdownlint-enable no-inline-html -->
66

77
_Testing Library for Microsoft Extensions Logging._
@@ -24,10 +24,12 @@ It is a repackaging with a sweetened API and some omissions of [Microsoft.Extens
2424
It is licensed under [Apache License 2.0](https://github.com/alefranz/MELT/blob/main/LICENSE).
2525
Most of the code is copyrighted by the .NET Foundation as mentioned in the files headers.
2626

27-
If you like this project please don't forget to *star* it on [GitHub](https//github.com/alefranz/MELT) or let me know with a [tweet](https://twitter.com/AleFranz).
27+
If you like this project please don't forget to **star** it on [GitHub](https://github.com/alefranz/MELT) or let me know with a [tweet](https://twitter.com/AleFranz).
2828

2929
You can find an explanation on the advantages of using this library and the importance of testing logs on the blog post "[How to test logging when using Microsoft.Extensions.Logging](https://alessio.franceschelli.me/posts/dotnet/how-to-test-logging-when-using-microsoft-extensions-logging/)".
3030

31+
This project supports all currently supported versions of .NET and ASP.NET Core, [including full framework](samples/2.1/SampleWebApplication2_1.IntegrationTests/). Please refer to the documentation for examples and compatibility details.
32+
3133
> If you are upgrading to version 0.5, you can _optionally_ migrate to the new syntax. See [Upgrade from 0.4 and below](#upgrade-from-04-and-below) for more info.
3234
3335
<!-- omit in toc -->

samples/2.1/SampleWebApplication2_1.IntegrationTests/LoggingTest.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
using System;
12
using System.Threading.Tasks;
2-
using MELT;
33
using Microsoft.AspNetCore.Hosting;
44
using Microsoft.AspNetCore.Mvc.Testing;
5+
using Microsoft.AspNetCore.TestHost;
56
using Xunit;
67

78
namespace SampleWebApplication2_1.IntegrationTests
@@ -13,14 +14,15 @@ public class LoggingTest : IClassFixture<WebApplicationFactory<Startup>>
1314
public LoggingTest(WebApplicationFactory<Startup> factory)
1415
{
1516
_factory = factory.WithWebHostBuilder(
16-
builder => builder.UseTestLogging(
17-
options => options.FilterByNamespace(nameof(SampleWebApplication2_1))));
17+
builder => builder
18+
.UseSolutionRelativeContentRoot(Environment.CurrentDirectory)
19+
.UseTestLogging(options => options.FilterByNamespace(nameof(SampleWebApplication2_1))));
1820
}
1921

2022
[Fact]
2123
public async Task ShouldLogHelloWorld()
2224
{
23-
// Arrange
25+
// Arrange
2426

2527
// Act
2628
await _factory.CreateDefaultClient().GetAsync("/");
@@ -34,7 +36,7 @@ public async Task ShouldLogHelloWorld()
3436
[Fact]
3537
public async Task ShouldLogWithWorldAsPlace()
3638
{
37-
// Arrange
39+
// Arrange
3840

3941
// Act
4042
await _factory.CreateDefaultClient().GetAsync("/");
@@ -48,7 +50,7 @@ public async Task ShouldLogWithWorldAsPlace()
4850
[Fact]
4951
public async Task ShouldUseScope()
5052
{
51-
// Arrange
53+
// Arrange
5254

5355
// Act
5456
await _factory.CreateDefaultClient().GetAsync("/");
@@ -63,7 +65,7 @@ public async Task ShouldUseScope()
6365
[Fact]
6466
public async Task ShouldUseScopeWithParameter()
6567
{
66-
// Arrange
68+
// Arrange
6769

6870
// Act
6971
await _factory.CreateDefaultClient().GetAsync("/");
@@ -78,7 +80,7 @@ public async Task ShouldUseScopeWithParameter()
7880
[Fact]
7981
public async Task ShouldBeginScope()
8082
{
81-
// Arrange
83+
// Arrange
8284

8385
// Act
8486
await _factory.CreateDefaultClient().GetAsync("/");
@@ -92,7 +94,7 @@ public async Task ShouldBeginScope()
9294
[Fact]
9395
public async Task ShouldBeginScopeWithParameter()
9496
{
95-
// Arrange
97+
// Arrange
9698

9799
// Act
98100
await _factory.CreateDefaultClient().GetAsync("/");

samples/2.1/SampleWebApplication2_1.IntegrationTests/LoggingTestWithInjectedFactory.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
using System;
12
using System.Threading.Tasks;
23
using Microsoft.AspNetCore.Hosting;
34
using Microsoft.AspNetCore.Mvc.Testing;
5+
using Microsoft.AspNetCore.TestHost;
46
using Xunit;
57

68
namespace SampleWebApplication2_1.IntegrationTests
@@ -52,7 +54,9 @@ public class CustomWebApplicationFactory<TStartup> : WebApplicationFactory<TStar
5254
{
5355
protected override void ConfigureWebHost(IWebHostBuilder builder)
5456
{
55-
builder.UseTestLogging(options => options.FilterByNamespace(nameof(SampleWebApplication2_1)));
57+
builder
58+
.UseSolutionRelativeContentRoot(Environment.CurrentDirectory)
59+
.UseTestLogging(options => options.FilterByNamespace(nameof(SampleWebApplication2_1)));
5660
}
5761
}
5862
}

0 commit comments

Comments
 (0)