move LocalInProcHttpServer to Shared TestFramework (#2418)
This commit is contained in:
Родитель
ede19dee6c
Коммит
72d817aaea
|
@ -202,7 +202,7 @@ Global
|
|||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{4B0BC3B7-C7FC-4333-9E28-5790D9153F07} = {BED5EB47-4AB1-4387-98B6-83CC327D6D16}
|
||||
{F76C6CBD-29B0-4564-BDCB-C969F8FEC136} = {C2FEEDE5-8CAE-41A4-8932-42D284A86EA7}
|
||||
{F76C6CBD-29B0-4564-BDCB-C969F8FEC136} = {BED5EB47-4AB1-4387-98B6-83CC327D6D16}
|
||||
{21CB9A8A-F25B-4DEB-92CB-ACB6920EB8BC} = {A61B048F-ECEA-4BED-A2ED-22834E7D4DFB}
|
||||
{E9ECEE96-DD50-42F6-9F33-0978CDFA15ED} = {68CC2924-E162-44BE-8D7A-DBA385365585}
|
||||
{2759BC71-7F47-44DA-8579-AE2D8C8C684D} = {C2FEEDE5-8CAE-41A4-8932-42D284A86EA7}
|
||||
|
|
|
@ -46,5 +46,9 @@
|
|||
<PackageReference Include="Azure.Core" Version="1.14.0" /> <!-- Supports: net461, netstandard2.0, and net5.0 -->
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(IsNetCore)' == 'True'">
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="..\..\TestFramework\Shared\TestFramework.Shared.projitems" Label="TestFramework.Shared" />
|
||||
</Project>
|
||||
|
|
|
@ -8,28 +8,25 @@ using System.Threading;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
|
||||
namespace Microsoft.ApplicationInsights.WindowsServer.Channel.Helpers
|
||||
namespace Microsoft.ApplicationInsights.TestFramework
|
||||
{
|
||||
public sealed class LocalInProcHttpServer : IDisposable
|
||||
public class LocalInProcHttpServer : IDisposable
|
||||
{
|
||||
private readonly IWebHost host;
|
||||
private readonly CancellationTokenSource cts;
|
||||
|
||||
public RequestDelegate ServerLogic;
|
||||
public RequestDelegate ServerLogic = async (httpContext) => await httpContext.Response.WriteAsync("Hello World!");
|
||||
|
||||
public LocalInProcHttpServer(string url, RequestDelegate serverLogic = null)
|
||||
public LocalInProcHttpServer(string url)
|
||||
{
|
||||
this.cts = new CancellationTokenSource();
|
||||
this.ServerLogic = serverLogic;
|
||||
this.host = new WebHostBuilder()
|
||||
.UseKestrel()
|
||||
.UseUrls(url)
|
||||
.Configure(
|
||||
(app) =>
|
||||
.Configure((app) =>
|
||||
{
|
||||
app.Run(ServerLogic);
|
||||
}
|
||||
)
|
||||
})
|
||||
.Build();
|
||||
|
||||
Task.Run(() => this.host.RunAsync(this.cts.Token));
|
|
@ -15,6 +15,7 @@
|
|||
<Compile Include="$(MSBuildThisFileDirectory)DeterministicTaskScheduler.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)EventSourceTest.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ExpectedExceptionWithMessageAttribute.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)LocalInProcHttpServer.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)MockProcessorModule.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)StubEnvironmentVariablePlatform.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)StubException.cs" />
|
||||
|
|
Загрузка…
Ссылка в новой задаче