Skip to content

Commit 23bf9b8

Browse files
committed
Cleanup tests
1 parent 3dec062 commit 23bf9b8

File tree

2 files changed

+27
-42
lines changed

2 files changed

+27
-42
lines changed

test/ZNetCS.AspNetCore.Authentication.BasicTests/EmptyWebApplicationFactory.cs

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,35 +24,28 @@ namespace ZNetCS.AspNetCore.Authentication.BasicTests;
2424
internal class EmptyWebApplicationFactory : WebApplicationFactory<EmptyStartup>
2525
{
2626
/// <inheritdoc/>
27-
protected override IHostBuilder CreateHostBuilder()
28-
{
29-
return Host.CreateDefaultBuilder()
30-
.ConfigureWebHostDefaults(
31-
builder =>
32-
{
33-
builder.ConfigureServices(s => { s.AddMvc(); })
34-
.Configure(
35-
app =>
36-
{
37-
app.UseRouting();
38-
app.UseAuthentication();
39-
app.UseAuthorization();
40-
app.UseEndpoints(o => o.MapControllers());
41-
})
42-
.ConfigureLogging(
43-
(_, logging) =>
44-
{
45-
logging
46-
.AddFilter("Default", LogLevel.Debug)
47-
.AddDebug();
48-
});
49-
});
50-
}
27+
protected override IHostBuilder CreateHostBuilder() => Host.CreateDefaultBuilder().ConfigureWebHostDefaults(_ => { });
5128

5229
/// <inheritdoc />
5330
protected override void ConfigureWebHost(IWebHostBuilder builder)
5431
{
5532
builder.UseContentRoot(GetPath() ?? string.Empty);
33+
builder.ConfigureServices(s => { s.AddMvc(); });
34+
builder.Configure(
35+
app =>
36+
{
37+
app.UseRouting();
38+
app.UseAuthentication();
39+
app.UseAuthorization();
40+
app.UseEndpoints(o => o.MapControllers());
41+
});
42+
builder.ConfigureLogging(
43+
(_, logging) =>
44+
{
45+
logging
46+
.AddFilter("Default", LogLevel.Debug)
47+
.AddDebug();
48+
});
5649
}
5750

5851
/// <summary>

test/ZNetCS.AspNetCore.Authentication.BasicTests/StartupWebApplicationFactory.cs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace ZNetCS.AspNetCore.Authentication.BasicTests;
88

9-
#region Usings
9+
#region Usings
1010

1111
using System.IO;
1212
using System.Reflection;
@@ -24,28 +24,20 @@ namespace ZNetCS.AspNetCore.Authentication.BasicTests;
2424
internal class StartupWebApplicationFactory : WebApplicationFactory<Startup>
2525
{
2626
/// <inheritdoc/>
27-
protected override IHostBuilder CreateHostBuilder()
28-
{
29-
return Host.CreateDefaultBuilder()
30-
.ConfigureWebHostDefaults(
31-
builder =>
32-
{
33-
builder
34-
.UseStartup<Startup>()
35-
.ConfigureLogging(
36-
(_, logging) =>
37-
{
38-
logging
39-
.AddFilter("Default", LogLevel.Debug)
40-
.AddDebug();
41-
});
42-
});
43-
}
27+
protected override IHostBuilder CreateHostBuilder() => Host.CreateDefaultBuilder().ConfigureWebHostDefaults(_ => { });
4428

4529
/// <inheritdoc />
4630
protected override void ConfigureWebHost(IWebHostBuilder builder)
4731
{
4832
builder.UseContentRoot(GetPath() ?? string.Empty);
33+
builder.UseStartup<Startup>();
34+
builder.ConfigureLogging(
35+
(_, logging) =>
36+
{
37+
logging
38+
.AddFilter("Default", LogLevel.Debug)
39+
.AddDebug();
40+
});
4941
}
5042

5143
/// <summary>

0 commit comments

Comments
 (0)