Reacting to new Hosting API

This commit is contained in:
John Luo 2015-12-16 18:37:37 -08:00
parent e384b7d4d0
commit c476f91152
35 changed files with 578 additions and 355 deletions

View File

@ -1,9 +1,9 @@
using System;
using Microsoft.AspNet.Builder;
using Microsoft.Data.Entity;
using System.Linq; using System.Linq;
using Microsoft.Extensions.DependencyInjection;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.Data.Entity;
using Microsoft.Extensions.DependencyInjection;
namespace DatabaseErrorPageSample namespace DatabaseErrorPageSample
{ {
@ -26,6 +26,16 @@ namespace DatabaseErrorPageSample
return Task.FromResult(0); return Task.FromResult(0);
}); });
} }
public static void Main(string[] args)
{
var application = new WebApplicationBuilder()
.UseConfiguration(WebApplicationConfiguration.GetDefault(args))
.UseStartup<Startup>()
.Build();
application.Run();
}
} }
public class MyContext : DbContext public class MyContext : DbContext

View File

@ -0,0 +1,3 @@
{
"server": "Microsoft.AspNet.Server.Kestrel"
}

View File

@ -1,15 +1,15 @@
{ {
"webroot": "wwwroot",
"dependencies": { "dependencies": {
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-*", "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-*",
"EntityFramework.MicrosoftSqlServer": "7.0.0-*", "EntityFramework.MicrosoftSqlServer": "7.0.0-*",
"EntityFramework.Commands": "7.0.0-*", "EntityFramework.Commands": "7.0.0-*",
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-*" "Microsoft.AspNet.Server.Kestrel": "1.0.0-*"
}, },
"compilationOptions": {
"emitEntryPoint": true
},
"commands": { "commands": {
"ef": "EntityFramework.Commands", "web": "DatabaseErrorPageSample"
"web": "Microsoft.AspNet.Server.Kestrel"
}, },
"frameworks": { "frameworks": {
"dnx451": { }, "dnx451": { },

View File

@ -1,5 +1,6 @@
using System; using System;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
namespace DeveloperExceptionPageSample namespace DeveloperExceptionPageSample
{ {
@ -17,5 +18,15 @@ namespace DeveloperExceptionPageSample
"New Line 3")); "New Line 3"));
}); });
} }
public static void Main(string[] args)
{
var application = new WebApplicationBuilder()
.UseConfiguration(WebApplicationConfiguration.GetDefault(args))
.UseStartup<Startup>()
.Build();
application.Run();
}
} }
} }

View File

@ -0,0 +1,3 @@
{
"server": "Microsoft.AspNet.Server.Kestrel"
}

View File

@ -1,11 +1,14 @@
{ {
"webroot" : "wwwroot",
"dependencies": { "dependencies": {
"Microsoft.AspNet.Diagnostics": "1.0.0-*", "Microsoft.AspNet.Diagnostics": "1.0.0-*",
"Microsoft.AspNet.Server.WebListener": "1.0.0-*", "Microsoft.AspNet.Server.Kestrel": "1.0.0-*"
"Microsoft.AspNet.Server.IIS": "1.0.0-*" },
"compilationOptions": {
"emitEntryPoint": true
},
"commands": {
"web": "DeveloperExceptionPageSample"
}, },
"commands": { "web": "Microsoft.AspNet.Hosting server=Microsoft.AspNet.Server.WebListener server.urls=http://localhost:5001" },
"frameworks": { "frameworks": {
"dnx451": {}, "dnx451": {},
"dnxcore50": {} "dnxcore50": {}

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" forwardWindowsAuthToken="false" startupTimeLimit="3600" />
</system.webServer>
</configuration>

View File

@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@ -27,5 +28,15 @@ namespace ElmPageSample
app.UseMiddleware<HelloWorldMiddleware>(); app.UseMiddleware<HelloWorldMiddleware>();
} }
public static void Main(string[] args)
{
var application = new WebApplicationBuilder()
.UseConfiguration(WebApplicationConfiguration.GetDefault(args))
.UseStartup<Startup>()
.Build();
application.Run();
}
} }
} }

View File

@ -0,0 +1,3 @@
{
"server": "Microsoft.AspNet.Server.Kestrel"
}

View File

@ -1,16 +1,17 @@
{ {
"webroot": "wwwroot", "exclude": "wwwroot/**/*.*",
"exclude": "wwwroot/**/*.*", "dependencies": {
"dependencies": { "Microsoft.AspNet.Diagnostics.Elm": "1.0.0-*",
"Microsoft.AspNet.Diagnostics.Elm": "1.0.0-*", "Microsoft.AspNet.Server.Kestrel": "1.0.0-*"
"Microsoft.AspNet.Server.IIS": "1.0.0-*", },
"Microsoft.AspNet.Server.WebListener": "1.0.0-*" "compilationOptions": {
}, "emitEntryPoint": true
"commands": { },
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000" "commands": {
}, "web": "ElmPageSample"
"frameworks": { },
"dnx451" : { }, "frameworks": {
"dnxcore50" : { } "dnx451": { },
} "dnxcore50": { }
}
} }

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" forwardWindowsAuthToken="false" startupTimeLimit="3600" />
</system.webServer>
</configuration>

View File

@ -2,6 +2,7 @@ using System;
using System.Text.Encodings.Web; using System.Text.Encodings.Web;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Diagnostics; using Microsoft.AspNet.Diagnostics;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Features; using Microsoft.AspNet.Http.Features;
@ -54,5 +55,15 @@ namespace ExceptionHandlerSample
await context.Response.WriteAsync("</body></html>\r\n"); await context.Response.WriteAsync("</body></html>\r\n");
}); });
} }
public static void Main(string[] args)
{
var application = new WebApplicationBuilder()
.UseConfiguration(WebApplicationConfiguration.GetDefault(args))
.UseStartup<Startup>()
.Build();
application.Run();
}
} }
} }

View File

@ -0,0 +1,3 @@
{
"server": "Microsoft.AspNet.Server.Kestrel"
}

View File

@ -1,17 +1,18 @@
{ {
"webroot": "wwwroot", "exclude": "wwwroot/**/*.*",
"exclude": "wwwroot/**/*.*", "dependencies": {
"dependencies": { "Microsoft.AspNet.Diagnostics": "1.0.0-*",
"Microsoft.AspNet.Diagnostics": "1.0.0-*", "Microsoft.AspNet.Server.Kestrel": "1.0.0-*",
"Microsoft.AspNet.Server.IIS": "1.0.0-*", "Microsoft.AspNet.StaticFiles": "1.0.0-*"
"Microsoft.AspNet.Server.WebListener": "1.0.0-*", },
"Microsoft.AspNet.StaticFiles": "1.0.0-*" "compilationOptions": {
}, "emitEntryPoint": true
"commands": { },
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000" "commands": {
}, "web": "ExceptionHandlerSample"
"frameworks": { },
"dnx451" : { }, "frameworks": {
"dnxcore50" : { } "dnx451": { },
} "dnxcore50": { }
}
} }

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" forwardWindowsAuthToken="false" startupTimeLimit="3600" />
</system.webServer>
</configuration>

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DiagnosticAdapter; using Microsoft.Extensions.DiagnosticAdapter;
@ -82,6 +83,16 @@ namespace MiddlewareAnaysisSample
// Note there's always a default 404 middleware at the end of the pipeline. // Note there's always a default 404 middleware at the end of the pipeline.
} }
public static void Main(string[] args)
{
var application = new WebApplicationBuilder()
.UseConfiguration(WebApplicationConfiguration.GetDefault(args))
.UseStartup<Startup>()
.Build();
application.Run();
}
public class TestDiagnosticListener public class TestDiagnosticListener
{ {
[DiagnosticName("Microsoft.AspNet.MiddlewareAnalysis.MiddlewareStarting")] [DiagnosticName("Microsoft.AspNet.MiddlewareAnalysis.MiddlewareStarting")]

View File

@ -0,0 +1,3 @@
{
"server": "Microsoft.AspNet.Server.Kestrel"
}

View File

@ -4,13 +4,14 @@
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-*", "Microsoft.AspNet.IISPlatformHandler": "1.0.0-*",
"Microsoft.AspNet.MiddlewareAnalysis": "1.0.0-*", "Microsoft.AspNet.MiddlewareAnalysis": "1.0.0-*",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-*", "Microsoft.AspNet.Server.Kestrel": "1.0.0-*",
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
"Microsoft.Extensions.DiagnosticAdapter": "1.0.0-*", "Microsoft.Extensions.DiagnosticAdapter": "1.0.0-*",
"Microsoft.Extensions.Logging.Console": "1.0.0-*" "Microsoft.Extensions.Logging.Console": "1.0.0-*"
}, },
"compilationOptions": {
"emitEntryPoint": true
},
"commands": { "commands": {
"web": "Microsoft.AspNet.Server.Kestrel", "web": "MiddlewareAnalysisSample"
"weblistener": "Microsoft.AspNet.Server.WebListener"
}, },
"frameworks": { "frameworks": {
"dnx451": { }, "dnx451": { },

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" forwardWindowsAuthToken="false" startupTimeLimit="3600" />
</system.webServer>
</configuration>

View File

@ -1,8 +1,6 @@
using System; using System.Threading.Tasks;
using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Diagnostics; using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http;
namespace RuntimeInfoPageSample namespace RuntimeInfoPageSample
{ {
@ -20,5 +18,15 @@ namespace RuntimeInfoPageSample
return Task.FromResult(0); return Task.FromResult(0);
}); });
} }
public static void Main(string[] args)
{
var application = new WebApplicationBuilder()
.UseConfiguration(WebApplicationConfiguration.GetDefault(args))
.UseStartup<Startup>()
.Build();
application.Run();
}
} }
} }

View File

@ -0,0 +1,3 @@
{
"server": "Microsoft.AspNet.Server.Kestrel"
}

View File

@ -1,12 +1,17 @@
{ {
"webroot" : "wwwroot", "exclude": "wwwroot/**/*.*",
"exclude": "wwwroot/**/*.*", "dependencies": {
"dependencies": { "Microsoft.AspNet.Diagnostics": "",
"Microsoft.AspNet.Diagnostics": "", "Microsoft.AspNet.Server.Kestrel": "1.0.0-*"
"Microsoft.AspNet.Server.IIS": "1.0.0-*" },
}, "compilationOptions": {
"frameworks" : { "emitEntryPoint": true
"dnx451" : { }, },
"dnxcore50" : { } "commands": {
} "web": "RuntimeInfoPageSample"
},
"frameworks": {
"dnx451": { },
"dnxcore50": { }
}
} }

View File

@ -8,6 +8,7 @@ using System.Text.Encodings.Web;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Diagnostics; using Microsoft.AspNet.Diagnostics;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Features; using Microsoft.AspNet.Http.Features;
@ -100,5 +101,15 @@ namespace StatusCodePagesSample
await context.Response.WriteAsync(builder.ToString()); await context.Response.WriteAsync(builder.ToString());
}); });
} }
public static void Main(string[] args)
{
var application = new WebApplicationBuilder()
.UseConfiguration(WebApplicationConfiguration.GetDefault(args))
.UseStartup<Startup>()
.Build();
application.Run();
}
} }
} }

View File

@ -0,0 +1,4 @@
{
"server": "Microsoft.AspNet.Server.Kestrel",
"server.urls": "http://localhost:5001/base"
}

View File

@ -1,24 +1,25 @@
{ {
"webroot": "wwwroot", "version": "1.0.0-*",
"version": "1.0.0-*", "exclude": [
"exclude": [ "wwwroot"
"wwwroot" ],
], "packExclude": [
"packExclude": [ "node_modules",
"node_modules", "bower_components",
"bower_components", "**.kproj",
"**.kproj", "**.user",
"**.user", "**.vspscc"
"**.vspscc" ],
], "compilationOptions": {
"commands": { "web": "Microsoft.AspNet.Hosting server=Microsoft.AspNet.Server.WebListener server.urls=http://localhost:5001/base" }, "emitEntryPoint": true
"dependencies": { },
"Microsoft.AspNet.Diagnostics": "1.0.0-*", "commands": { "web": "StatusCodePagesSample" },
"Microsoft.AspNet.Server.IIS": "1.0.0-*", "dependencies": {
"Microsoft.AspNet.Server.WebListener": "1.0.0-*" "Microsoft.AspNet.Diagnostics": "1.0.0-*",
}, "Microsoft.AspNet.Server.Kestrel": "1.0.0-*"
"frameworks" : { },
"dnx451" : { }, "frameworks": {
"dnxcore50" : { } "dnx451": { },
} "dnxcore50": { }
}
} }

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" forwardWindowsAuthToken="false" startupTimeLimit="3600" />
</system.webServer>
</configuration>

View File

@ -1,5 +1,5 @@
using Microsoft.AspNet; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Hosting;
namespace WelcomePageSample namespace WelcomePageSample
{ {
@ -9,5 +9,15 @@ namespace WelcomePageSample
{ {
app.UseWelcomePage(); app.UseWelcomePage();
} }
public static void Main(string[] args)
{
var application = new WebApplicationBuilder()
.UseConfiguration(WebApplicationConfiguration.GetDefault(args))
.UseStartup<Startup>()
.Build();
application.Run();
}
} }
} }

View File

@ -0,0 +1,3 @@
{
"server": "Microsoft.AspNet.Server.Kestrel"
}

View File

@ -1,13 +1,14 @@
{ {
"webroot": "wwwroot", "dependencies": {
"dependencies": { "Microsoft.AspNet.Diagnostics": "",
"Microsoft.AspNet.Diagnostics": "", "Microsoft.AspNet.Server.Kestrel": "1.0.0-*"
"Microsoft.AspNet.Server.WebListener": "1.0.0-*", },
"Microsoft.AspNet.Server.IIS": "1.0.0-*" "compilationOptions": {
}, "emitEntryPoint": true
"commands": { "web": "Microsoft.AspNet.Hosting server=Microsoft.AspNet.Server.WebListener server.urls=http://localhost:5001" }, },
"frameworks": { "commands": { "web": "WelcomePageSample" },
"dnx451": { }, "frameworks": {
"dnxcore50": { } "dnx451": { },
} "dnxcore50": { }
}
} }

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" forwardWindowsAuthToken="false" startupTimeLimit="3600" />
</system.webServer>
</configuration>

View File

@ -12,6 +12,7 @@ using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Diagnostics.Entity.FunctionalTests.Helpers; using Microsoft.AspNet.Diagnostics.Entity.FunctionalTests.Helpers;
using Microsoft.AspNet.Diagnostics.Entity.Tests.Helpers; using Microsoft.AspNet.Diagnostics.Entity.Tests.Helpers;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.TestHost; using Microsoft.AspNet.TestHost;
using Microsoft.AspNet.Testing.xunit; using Microsoft.AspNet.Testing.xunit;
@ -28,9 +29,10 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
[Fact] [Fact]
public async Task Successful_requests_pass_thru() public async Task Successful_requests_pass_thru()
{ {
TestServer server = TestServer.Create(app => app var builder = new WebApplicationBuilder().Configure(app => app
.UseDatabaseErrorPage() .UseDatabaseErrorPage()
.UseMiddleware<SuccessMiddleware>()); .UseMiddleware<SuccessMiddleware>());
var server = new TestServer(builder);
HttpResponseMessage response = await server.CreateClient().GetAsync("http://localhost/"); HttpResponseMessage response = await server.CreateClient().GetAsync("http://localhost/");
@ -53,9 +55,10 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
[Fact] [Fact]
public async Task Non_database_exceptions_pass_thru() public async Task Non_database_exceptions_pass_thru()
{ {
TestServer server = TestServer.Create(app => app var builder = new WebApplicationBuilder().Configure(app => app
.UseDatabaseErrorPage() .UseDatabaseErrorPage()
.UseMiddleware<ExceptionMiddleware>()); .UseMiddleware<ExceptionMiddleware>());
var server = new TestServer(builder);
var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () =>
await server.CreateClient().GetAsync("http://localhost/")); await server.CreateClient().GetAsync("http://localhost/"));
@ -252,25 +255,27 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
using (var database = SqlServerTestStore.CreateScratch()) using (var database = SqlServerTestStore.CreateScratch())
{ {
var server = TestServer.Create(app => var builder = new WebApplicationBuilder()
{ .Configure(app =>
app.UseDatabaseErrorPage(options =>
{ {
options.EnableAll(); app.UseDatabaseErrorPage(options =>
options.MigrationsEndPointPath = new PathString(migrationsEndpoint); {
options.EnableAll();
options.MigrationsEndPointPath = new PathString(migrationsEndpoint);
});
app.UseMiddleware<PendingMigrationsMiddleware>();
})
.ConfigureServices(services =>
{
services.AddEntityFramework().AddSqlServer();
services.AddScoped<BloggingContextWithMigrations>();
var optionsBuilder = new DbContextOptionsBuilder();
optionsBuilder.UseSqlServer(database.ConnectionString);
services.AddSingleton<DbContextOptions>(optionsBuilder.Options);
}); });
var server = new TestServer(builder);
app.UseMiddleware<PendingMigrationsMiddleware>();
},
services =>
{
services.AddEntityFramework().AddSqlServer();
services.AddScoped<BloggingContextWithMigrations>();
var optionsBuilder = new DbContextOptionsBuilder();
optionsBuilder.UseSqlServer(database.ConnectionString);
services.AddSingleton<DbContextOptions>(optionsBuilder.Options);
});
HttpResponseMessage response = await server.CreateClient().GetAsync("http://localhost/"); HttpResponseMessage response = await server.CreateClient().GetAsync("http://localhost/");
@ -289,26 +294,29 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
{ {
var logProvider = new TestLoggerProvider(); var logProvider = new TestLoggerProvider();
var server = TestServer.Create(app => var builder = new WebApplicationBuilder()
{ .Configure(app =>
app.UseDatabaseErrorPage();
app.UseMiddleware<ContextNotRegisteredInServicesMiddleware>();
app.ApplicationServices.GetService<ILoggerFactory>().AddProvider(logProvider);
},
services =>
{
services.AddEntityFramework().AddSqlServer();
var optionsBuilder = new DbContextOptionsBuilder();
if (!PlatformHelper.IsMono)
{ {
optionsBuilder.UseSqlServer(database.ConnectionString); app.UseDatabaseErrorPage();
} app.UseMiddleware<ContextNotRegisteredInServicesMiddleware>();
else app.ApplicationServices.GetService<ILoggerFactory>().AddProvider(logProvider);
})
.ConfigureServices(
services =>
{ {
optionsBuilder.UseInMemoryDatabase(); services.AddEntityFramework().AddSqlServer();
} var optionsBuilder = new DbContextOptionsBuilder();
services.AddSingleton<DbContextOptions>(optionsBuilder.Options); if (!PlatformHelper.IsMono)
}); {
optionsBuilder.UseSqlServer(database.ConnectionString);
}
else
{
optionsBuilder.UseInMemoryDatabase();
}
services.AddSingleton<DbContextOptions>(optionsBuilder.Options);
});
var server = new TestServer(builder);
var ex = await Assert.ThrowsAsync<SqlException>(async () => var ex = await Assert.ThrowsAsync<SqlException>(async () =>
await server.CreateClient().GetAsync("http://localhost/")); await server.CreateClient().GetAsync("http://localhost/"));
@ -404,35 +412,37 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
{ {
using (var database = SqlServerTestStore.CreateScratch()) using (var database = SqlServerTestStore.CreateScratch())
{ {
return TestServer.Create(app => var builder = new WebApplicationBuilder()
{ .Configure(app =>
app.UseDatabaseErrorPage();
app.UseMiddleware<TMiddleware>();
if (logProvider != null)
{ {
app.ApplicationServices.GetService<ILoggerFactory>().AddProvider(logProvider); app.UseDatabaseErrorPage();
}
},
services =>
{
services.AddEntityFramework()
.AddSqlServer();
services.AddScoped<TContext>(); app.UseMiddleware<TMiddleware>();
var optionsBuilder = new DbContextOptionsBuilder(); if (logProvider != null)
if (!PlatformHelper.IsMono) {
app.ApplicationServices.GetService<ILoggerFactory>().AddProvider(logProvider);
}
})
.ConfigureServices(services =>
{ {
optionsBuilder.UseSqlServer(database.ConnectionString); services.AddEntityFramework()
} .AddSqlServer();
else
{ services.AddScoped<TContext>();
optionsBuilder.UseInMemoryDatabase();
} var optionsBuilder = new DbContextOptionsBuilder();
services.AddSingleton(optionsBuilder.Options); if (!PlatformHelper.IsMono)
}); {
optionsBuilder.UseSqlServer(database.ConnectionString);
}
else
{
optionsBuilder.UseInMemoryDatabase();
}
services.AddSingleton(optionsBuilder.Options);
});
return new TestServer(builder);
} }
} }

View File

@ -9,6 +9,7 @@ using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Diagnostics.Entity.Tests.Helpers; using Microsoft.AspNet.Diagnostics.Entity.Tests.Helpers;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.TestHost; using Microsoft.AspNet.TestHost;
using Microsoft.AspNet.Testing.xunit; using Microsoft.AspNet.Testing.xunit;
@ -26,9 +27,10 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
[Fact] [Fact]
public async Task Non_migration_requests_pass_thru() public async Task Non_migration_requests_pass_thru()
{ {
TestServer server = TestServer.Create(app => app var builder = new WebApplicationBuilder().Configure(app => app
.UseMigrationsEndPoint() .UseMigrationsEndPoint()
.UseMiddleware<SuccessMiddleware>()); .UseMiddleware<SuccessMiddleware>());
var server = new TestServer(builder);
HttpResponseMessage response = await server.CreateClient().GetAsync("http://localhost/"); HttpResponseMessage response = await server.CreateClient().GetAsync("http://localhost/");
@ -71,23 +73,25 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
var path = useCustomPath ? new PathString("/EndPoints/ApplyMyMigrations") : MigrationsEndPointOptions.DefaultPath; var path = useCustomPath ? new PathString("/EndPoints/ApplyMyMigrations") : MigrationsEndPointOptions.DefaultPath;
TestServer server = TestServer.Create(app => var builder = new WebApplicationBuilder()
{ .Configure(app =>
if (useCustomPath)
{ {
app.UseMigrationsEndPoint(o => o.Path = path); if (useCustomPath)
} {
else app.UseMigrationsEndPoint(o => o.Path = path);
}
else
{
app.UseMigrationsEndPoint();
}
})
.ConfigureServices(services =>
{ {
app.UseMigrationsEndPoint(); services.AddEntityFramework().AddSqlServer();
} services.AddScoped<BloggingContextWithMigrations>();
}, services.AddSingleton(optionsBuilder.Options);
services => });
{ var server = new TestServer(builder);
services.AddEntityFramework().AddSqlServer();
services.AddScoped<BloggingContextWithMigrations>();
services.AddSingleton(optionsBuilder.Options);
});
using (var db = BloggingContextWithMigrations.CreateWithoutExternalServiceProvider(optionsBuilder.Options)) using (var db = BloggingContextWithMigrations.CreateWithoutExternalServiceProvider(optionsBuilder.Options))
{ {
@ -118,10 +122,12 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
[Fact] [Fact]
public async Task Context_type_not_specified() public async Task Context_type_not_specified()
{ {
var server = TestServer.Create(app => var builder = new WebApplicationBuilder()
{ .Configure(app =>
app.UseMigrationsEndPoint(); {
}); app.UseMigrationsEndPoint();
});
var server = new TestServer(builder);
var formData = new FormUrlEncodedContent(new List<KeyValuePair<string, string>>()); var formData = new FormUrlEncodedContent(new List<KeyValuePair<string, string>>());
@ -136,10 +142,12 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
[Fact] [Fact]
public async Task Invalid_context_type_specified() public async Task Invalid_context_type_specified()
{ {
var server = TestServer.Create(app => var builder = new WebApplicationBuilder()
{ .Configure(app =>
app.UseMigrationsEndPoint(); {
}); app.UseMigrationsEndPoint();
});
var server = new TestServer(builder);
var typeName = "You won't find this type ;)"; var typeName = "You won't find this type ;)";
var formData = new FormUrlEncodedContent(new List<KeyValuePair<string, string>> var formData = new FormUrlEncodedContent(new List<KeyValuePair<string, string>>
@ -158,9 +166,10 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
[Fact] [Fact]
public async Task Context_not_registered_in_services() public async Task Context_not_registered_in_services()
{ {
var server = TestServer.Create( var builder = new WebApplicationBuilder()
app => app.UseMigrationsEndPoint(), .Configure(app => app.UseMigrationsEndPoint())
services => services.AddEntityFramework().AddSqlServer()); .ConfigureServices(services => services.AddEntityFramework().AddSqlServer());
var server = new TestServer(builder);
var formData = new FormUrlEncodedContent(new List<KeyValuePair<string, string>> var formData = new FormUrlEncodedContent(new List<KeyValuePair<string, string>>
{ {
@ -184,14 +193,15 @@ namespace Microsoft.AspNet.Diagnostics.Entity.Tests
var optionsBuilder = new DbContextOptionsBuilder(); var optionsBuilder = new DbContextOptionsBuilder();
optionsBuilder.UseSqlServer(database.ConnectionString); optionsBuilder.UseSqlServer(database.ConnectionString);
TestServer server = TestServer.Create( var builder = new WebApplicationBuilder()
app => app.UseMigrationsEndPoint(), .Configure(app => app.UseMigrationsEndPoint())
services => .ConfigureServices(services =>
{ {
services.AddEntityFramework().AddSqlServer(); services.AddEntityFramework().AddSqlServer();
services.AddScoped<BloggingContextWithSnapshotThatThrows>(); services.AddScoped<BloggingContextWithSnapshotThatThrows>();
services.AddSingleton(optionsBuilder.Options); services.AddSingleton(optionsBuilder.Options);
}); });
var server = new TestServer(builder);
var formData = new FormUrlEncodedContent(new List<KeyValuePair<string, string>> var formData = new FormUrlEncodedContent(new List<KeyValuePair<string, string>>
{ {

View File

@ -13,6 +13,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.FileProviders; using Microsoft.AspNet.FileProviders;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.TestHost; using Microsoft.AspNet.TestHost;
using Microsoft.AspNet.Testing; using Microsoft.AspNet.Testing;
using Microsoft.Extensions.PlatformAbstractions; using Microsoft.Extensions.PlatformAbstractions;
@ -485,15 +486,17 @@ namespace Microsoft.AspNet.Diagnostics
{ {
// Arrange // Arrange
DiagnosticListener diagnosticListener = null; DiagnosticListener diagnosticListener = null;
var server = TestServer.Create(app => var builder = new WebApplicationBuilder()
{ .Configure(app =>
diagnosticListener = app.ApplicationServices.GetRequiredService<DiagnosticListener>();
app.UseDeveloperExceptionPage();
app.Run(context =>
{ {
throw new Exception("Test exception"); diagnosticListener = app.ApplicationServices.GetRequiredService<DiagnosticListener>();
app.UseDeveloperExceptionPage();
app.Run(context =>
{
throw new Exception("Test exception");
});
}); });
}); var server = new TestServer(builder);
var listener = new TestDiagnosticListener(); var listener = new TestDiagnosticListener();
diagnosticListener.SubscribeWithAdapter(listener); diagnosticListener.SubscribeWithAdapter(listener);

View File

@ -10,6 +10,7 @@ using System.Net;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.AspNet.TestHost; using Microsoft.AspNet.TestHost;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@ -25,25 +26,28 @@ namespace Microsoft.AspNet.Diagnostics
[InlineData(HttpStatusCode.InternalServerError)] [InlineData(HttpStatusCode.InternalServerError)]
public async Task OnlyHandles_UnhandledExceptions(HttpStatusCode expectedStatusCode) public async Task OnlyHandles_UnhandledExceptions(HttpStatusCode expectedStatusCode)
{ {
using (var server = TestServer.Create(app => var builder = new WebApplicationBuilder()
{ .Configure(app =>
app.UseExceptionHandler("/handle-errors");
app.Map("/handle-errors", (innerAppBuilder) =>
{ {
innerAppBuilder.Run(async (httpContext) => app.UseExceptionHandler("/handle-errors");
app.Map("/handle-errors", (innerAppBuilder) =>
{ {
await httpContext.Response.WriteAsync("Handled error in a custom way."); innerAppBuilder.Run(async (httpContext) =>
{
await httpContext.Response.WriteAsync("Handled error in a custom way.");
});
}); });
app.Run((RequestDelegate)(async (context) =>
{
context.Response.StatusCode = (int)expectedStatusCode;
context.Response.ContentType = "text/plain; charset=utf-8";
await context.Response.WriteAsync("An error occurred while adding a product");
}));
}); });
app.Run((RequestDelegate)(async (context) => using (var server = new TestServer(builder))
{
context.Response.StatusCode = (int)expectedStatusCode;
context.Response.ContentType = "text/plain; charset=utf-8";
await context.Response.WriteAsync("An error occurred while adding a product");
}));
}))
{ {
var client = server.CreateClient(); var client = server.CreateClient();
var response = await client.GetAsync(string.Empty); var response = await client.GetAsync(string.Empty);
@ -55,40 +59,43 @@ namespace Microsoft.AspNet.Diagnostics
[Fact] [Fact]
public async Task DoesNotHandle_UnhandledExceptions_WhenResponseAlreadyStarted() public async Task DoesNotHandle_UnhandledExceptions_WhenResponseAlreadyStarted()
{ {
using (var server = TestServer.Create(app => var builder = new WebApplicationBuilder()
{ .Configure(app =>
app.Use(async (httpContext, next) =>
{ {
Exception exception = null; app.Use(async (httpContext, next) =>
try
{ {
await next(); Exception exception = null;
} try
catch (InvalidOperationException ex) {
await next();
}
catch (InvalidOperationException ex)
{
exception = ex;
}
Assert.NotNull(exception);
Assert.Equal("Something bad happened", exception.Message);
});
app.UseExceptionHandler("/handle-errors");
app.Map("/handle-errors", (innerAppBuilder) =>
{ {
exception = ex; innerAppBuilder.Run(async (httpContext) =>
} {
await httpContext.Response.WriteAsync("Handled error in a custom way.");
});
});
Assert.NotNull(exception); app.Run(async (httpContext) =>
Assert.Equal("Something bad happened", exception.Message);
});
app.UseExceptionHandler("/handle-errors");
app.Map("/handle-errors", (innerAppBuilder) =>
{
innerAppBuilder.Run(async (httpContext) =>
{ {
await httpContext.Response.WriteAsync("Handled error in a custom way."); await httpContext.Response.WriteAsync("Hello");
throw new InvalidOperationException("Something bad happened");
}); });
}); });
app.Run(async (httpContext) => using (var server = new TestServer(builder))
{
await httpContext.Response.WriteAsync("Hello");
throw new InvalidOperationException("Something bad happened");
});
}))
{ {
var client = server.CreateClient(); var client = server.CreateClient();
var response = await client.GetAsync(string.Empty); var response = await client.GetAsync(string.Empty);
@ -101,51 +108,54 @@ namespace Microsoft.AspNet.Diagnostics
public async Task ClearsResponseBuffer_BeforeRequestIsReexecuted() public async Task ClearsResponseBuffer_BeforeRequestIsReexecuted()
{ {
var expectedResponseBody = "New response body"; var expectedResponseBody = "New response body";
using (var server = TestServer.Create(app => var builder = new WebApplicationBuilder()
{ .Configure(app =>
// add response buffering
app.Use(async (httpContext, next) =>
{ {
var response = httpContext.Response; // add response buffering
var originalResponseBody = response.Body; app.Use(async (httpContext, next) =>
var bufferingStream = new MemoryStream();
response.Body = bufferingStream;
try
{ {
await next(); var response = httpContext.Response;
var originalResponseBody = response.Body;
var bufferingStream = new MemoryStream();
response.Body = bufferingStream;
response.Body = originalResponseBody; try
bufferingStream.Seek(0, SeekOrigin.Begin); {
await bufferingStream.CopyToAsync(response.Body); await next();
}
finally response.Body = originalResponseBody;
bufferingStream.Seek(0, SeekOrigin.Begin);
await bufferingStream.CopyToAsync(response.Body);
}
finally
{
response.Body = originalResponseBody;
}
});
app.UseExceptionHandler("/handle-errors");
app.Map("/handle-errors", (innerAppBuilder) =>
{ {
response.Body = originalResponseBody; innerAppBuilder.Run(async (httpContext) =>
} {
}); Assert.True(httpContext.Response.Body.CanSeek);
Assert.Equal(0, httpContext.Response.Body.Position);
app.UseExceptionHandler("/handle-errors"); await httpContext.Response.WriteAsync(expectedResponseBody);
});
});
app.Map("/handle-errors", (innerAppBuilder) => app.Run(async (context) =>
{
innerAppBuilder.Run(async (httpContext) =>
{ {
Assert.True(httpContext.Response.Body.CanSeek); // Write some content into the response before throwing exception
Assert.Equal(0, httpContext.Response.Body.Position); await context.Response.WriteAsync(new string('a', 100));
await httpContext.Response.WriteAsync(expectedResponseBody); throw new InvalidOperationException("Invalid input provided.");
}); });
}); });
app.Run(async (context) => using (var server = new TestServer(builder))
{
// Write some content into the response before throwing exception
await context.Response.WriteAsync(new string('a', 100));
throw new InvalidOperationException("Invalid input provided.");
});
}))
{ {
var client = server.CreateClient(); var client = server.CreateClient();
var response = await client.GetAsync(string.Empty); var response = await client.GetAsync(string.Empty);
@ -170,29 +180,32 @@ namespace Microsoft.AspNet.Diagnostics
{ {
var expiresTime = DateTime.UtcNow.AddDays(5).ToString("R"); var expiresTime = DateTime.UtcNow.AddDays(5).ToString("R");
var expectedResponseBody = "Handled error in a custom way."; var expectedResponseBody = "Handled error in a custom way.";
using (var server = TestServer.Create(app => var builder = new WebApplicationBuilder()
{ .Configure(app =>
app.UseExceptionHandler("/handle-errors");
app.Map("/handle-errors", (innerAppBuilder) =>
{ {
innerAppBuilder.Run(async (httpContext) => app.UseExceptionHandler("/handle-errors");
{
httpContext.Response.Headers.Add("Cache-Control", new[] { "max-age=600" });
httpContext.Response.Headers.Add("Pragma", new[] { "max-age=600" });
httpContext.Response.Headers.Add(
"Expires", new[] { expiresTime });
httpContext.Response.Headers.Add("ETag", new[] { "12345" });
await httpContext.Response.WriteAsync(expectedResponseBody); app.Map("/handle-errors", (innerAppBuilder) =>
{
innerAppBuilder.Run(async (httpContext) =>
{
httpContext.Response.Headers.Add("Cache-Control", new[] { "max-age=600" });
httpContext.Response.Headers.Add("Pragma", new[] { "max-age=600" });
httpContext.Response.Headers.Add(
"Expires", new[] { expiresTime });
httpContext.Response.Headers.Add("ETag", new[] { "12345" });
await httpContext.Response.WriteAsync(expectedResponseBody);
});
});
app.Run((context) =>
{
throw new InvalidOperationException("Invalid input provided.");
}); });
}); });
app.Run((context) => using (var server = new TestServer(builder))
{
throw new InvalidOperationException("Invalid input provided.");
});
}))
{ {
var client = server.CreateClient(); var client = server.CreateClient();
var response = await client.GetAsync(string.Empty); var response = await client.GetAsync(string.Empty);
@ -217,28 +230,31 @@ namespace Microsoft.AspNet.Diagnostics
{ {
var expiresTime = DateTime.UtcNow.AddDays(10).ToString("R"); var expiresTime = DateTime.UtcNow.AddDays(10).ToString("R");
var expectedResponseBody = "Hello world!"; var expectedResponseBody = "Hello world!";
using (var server = TestServer.Create(app => var builder = new WebApplicationBuilder()
{ .Configure(app =>
app.UseExceptionHandler("/handle-errors");
app.Map("/handle-errors", (innerAppBuilder) =>
{ {
innerAppBuilder.Run(async (httpContext) => app.UseExceptionHandler("/handle-errors");
app.Map("/handle-errors", (innerAppBuilder) =>
{ {
await httpContext.Response.WriteAsync("Handled error in a custom way."); innerAppBuilder.Run(async (httpContext) =>
{
await httpContext.Response.WriteAsync("Handled error in a custom way.");
});
});
app.Run(async (httpContext) =>
{
httpContext.Response.Headers.Add("Cache-Control", new[] { "max-age=3600" });
httpContext.Response.Headers.Add("Pragma", new[] { "max-age=3600" });
httpContext.Response.Headers.Add("Expires", new[] { expiresTime });
httpContext.Response.Headers.Add("ETag", new[] { "abcdef" });
await httpContext.Response.WriteAsync(expectedResponseBody);
}); });
}); });
app.Run(async (httpContext) => using (var server = new TestServer(builder))
{
httpContext.Response.Headers.Add("Cache-Control", new[] { "max-age=3600" });
httpContext.Response.Headers.Add("Pragma", new[] { "max-age=3600" });
httpContext.Response.Headers.Add("Expires", new[] { expiresTime });
httpContext.Response.Headers.Add("ETag", new[] { "abcdef" });
await httpContext.Response.WriteAsync(expectedResponseBody);
});
}))
{ {
var client = server.CreateClient(); var client = server.CreateClient();
var response = await client.GetAsync(string.Empty); var response = await client.GetAsync(string.Empty);
@ -264,46 +280,49 @@ namespace Microsoft.AspNet.Diagnostics
public async Task DoesNotClearCacheHeaders_WhenResponseHasAlreadyStarted() public async Task DoesNotClearCacheHeaders_WhenResponseHasAlreadyStarted()
{ {
var expiresTime = DateTime.UtcNow.AddDays(10).ToString("R"); var expiresTime = DateTime.UtcNow.AddDays(10).ToString("R");
using (var server = TestServer.Create(app => var builder = new WebApplicationBuilder()
{ .Configure(app =>
app.Use(async (httpContext, next) =>
{ {
Exception exception = null; app.Use(async (httpContext, next) =>
try
{ {
await next(); Exception exception = null;
} try
catch (InvalidOperationException ex) {
await next();
}
catch (InvalidOperationException ex)
{
exception = ex;
}
Assert.NotNull(exception);
Assert.Equal("Something bad happened", exception.Message);
});
app.UseExceptionHandler("/handle-errors");
app.Map("/handle-errors", (innerAppBuilder) =>
{ {
exception = ex; innerAppBuilder.Run(async (httpContext) =>
} {
await httpContext.Response.WriteAsync("Handled error in a custom way.");
});
});
Assert.NotNull(exception); app.Run(async (httpContext) =>
Assert.Equal("Something bad happened", exception.Message);
});
app.UseExceptionHandler("/handle-errors");
app.Map("/handle-errors", (innerAppBuilder) =>
{
innerAppBuilder.Run(async (httpContext) =>
{ {
await httpContext.Response.WriteAsync("Handled error in a custom way."); httpContext.Response.Headers.Add("Cache-Control", new[] { "max-age=3600" });
httpContext.Response.Headers.Add("Pragma", new[] { "max-age=3600" });
httpContext.Response.Headers.Add("Expires", new[] { expiresTime });
httpContext.Response.Headers.Add("ETag", new[] { "abcdef" });
await httpContext.Response.WriteAsync("Hello");
throw new InvalidOperationException("Something bad happened");
}); });
}); });
app.Run(async (httpContext) => using (var server = new TestServer(builder))
{
httpContext.Response.Headers.Add("Cache-Control", new[] { "max-age=3600" });
httpContext.Response.Headers.Add("Pragma", new[] { "max-age=3600" });
httpContext.Response.Headers.Add("Expires", new[] { expiresTime });
httpContext.Response.Headers.Add("ETag", new[] { "abcdef" });
await httpContext.Response.WriteAsync("Hello");
throw new InvalidOperationException("Something bad happened");
});
}))
{ {
var client = server.CreateClient(); var client = server.CreateClient();
var response = await client.GetAsync(string.Empty); var response = await client.GetAsync(string.Empty);
@ -331,23 +350,25 @@ namespace Microsoft.AspNet.Diagnostics
// Arrange // Arrange
DiagnosticListener diagnosticListener = null; DiagnosticListener diagnosticListener = null;
var server = TestServer.Create(app => var builder = new WebApplicationBuilder()
{ .Configure(app =>
diagnosticListener = app.ApplicationServices.GetRequiredService<DiagnosticListener>();
app.UseExceptionHandler("/handle-errors");
app.Map("/handle-errors", (innerAppBuilder) =>
{ {
innerAppBuilder.Run(async (httpContext) => diagnosticListener = app.ApplicationServices.GetRequiredService<DiagnosticListener>();
app.UseExceptionHandler("/handle-errors");
app.Map("/handle-errors", (innerAppBuilder) =>
{ {
await httpContext.Response.WriteAsync("Handled error in a custom way."); innerAppBuilder.Run(async (httpContext) =>
{
await httpContext.Response.WriteAsync("Handled error in a custom way.");
});
});
app.Run(context =>
{
throw new Exception("Test exception");
}); });
}); });
app.Run(context => var server = new TestServer(builder);
{
throw new Exception("Test exception");
});
});
var listener = new TestDiagnosticListener(); var listener = new TestDiagnosticListener();
diagnosticListener.SubscribeWithAdapter(listener); diagnosticListener.SubscribeWithAdapter(listener);

View File

@ -5,6 +5,7 @@ using System;
using System.Diagnostics; using System.Diagnostics;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.TestHost; using Microsoft.AspNet.TestHost;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Xunit; using Xunit;
@ -18,16 +19,19 @@ namespace Microsoft.AspNet.MiddlewareAnalysis
{ {
DiagnosticListener diagnosticListener = null; DiagnosticListener diagnosticListener = null;
var server = TestServer.Create(app => var builder = new WebApplicationBuilder()
{ .Configure(app =>
diagnosticListener = app.ApplicationServices.GetRequiredService<DiagnosticListener>();
app.UseDeveloperExceptionPage();
app.Run(context =>
{ {
throw new Exception("Test exception"); diagnosticListener = app.ApplicationServices.GetRequiredService<DiagnosticListener>();
});
}, services => services.AddMiddlewareAnalysis()); app.UseDeveloperExceptionPage();
app.Run(context =>
{
throw new Exception("Test exception");
});
})
.ConfigureServices(services => services.AddMiddlewareAnalysis());
var server = new TestServer(builder);
var listener = new TestDiagnosticListener(); var listener = new TestDiagnosticListener();
diagnosticListener.SubscribeWithAdapter(listener); diagnosticListener.SubscribeWithAdapter(listener);