asp.net-core-testhost

Programmatically invoking the ASP.NET Core request pipeline

旧街凉风 提交于 2021-01-02 12:54:55
问题 Question Is there a way to programmatically invoke the ASP.NET Core request pipeline from within my own application, given I have a HTTP verb, the route, headers and body payload? Background There are use-cases where the WebAPI of our ASP.NET Core application is not accessible because the application is running behind a firewall or is otherwise not reachable. To provide a solution for this scenario we want our application to poll some other service for "work-items" which then translate into

Programmatically invoking the ASP.NET Core request pipeline

我怕爱的太早我们不能终老 提交于 2021-01-02 12:52:46
问题 Question Is there a way to programmatically invoke the ASP.NET Core request pipeline from within my own application, given I have a HTTP verb, the route, headers and body payload? Background There are use-cases where the WebAPI of our ASP.NET Core application is not accessible because the application is running behind a firewall or is otherwise not reachable. To provide a solution for this scenario we want our application to poll some other service for "work-items" which then translate into

Mocking and resolving Autofac dependency in integration test in AspNetCore with TestServer

谁说胖子不能爱 提交于 2019-12-12 12:19:17
问题 I'm using AspNetCore 2.2 Following (moreless) the docs here: https://docs.microsoft.com/en-us/aspnet/core/test/integration-tests?view=aspnetcore-2.2 I am using Autofac, my Startup class has the following methods: public void ConfigureServices(IServiceCollection services) public void ConfigureContainer(ContainerBuilder containerBuilder) //this is where things can be registered directly with autofac and runs after ConfigureServices public void Configure(...) //the method called by runtime The

IdentityServer4 Testserver could not found

≡放荡痞女 提交于 2019-12-01 03:56:38
问题 I am writing a test to get a token from identity server4 using Microsoft.AspNetCore.TestHost var hostBuilder = new WebHostBuilder() .ConfigureServices(services => { services.AddIdentityServer() .AddTemporarySigningCredential() .AddInMemoryIdentityResources(Config.GetIdentityResources()) .AddInMemoryApiResources(Config.GetApiResources()) .AddInMemoryClients(Config.GetClients()) .AddTestUsers(Config.GetUsers()) ; }) .Configure(app => { app.UseIdentityServer(); }); var server = new TestServer