mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-22 06:22:50 +08:00
Removed the fake woop
This commit is contained in:
parent
58393f07ec
commit
cff130196f
@ -1,34 +0,0 @@
|
|||||||
using System.IO;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
|
|
||||||
namespace Ocelot.AcceptanceTests.Fake
|
|
||||||
{
|
|
||||||
public class FakeService
|
|
||||||
{
|
|
||||||
private Task _handler;
|
|
||||||
private IWebHost _webHostBuilder;
|
|
||||||
|
|
||||||
public void Start(string url)
|
|
||||||
{
|
|
||||||
_webHostBuilder = new WebHostBuilder()
|
|
||||||
.UseKestrel()
|
|
||||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
|
||||||
.UseIISIntegration()
|
|
||||||
.UseUrls(url)
|
|
||||||
.UseStartup<FakeStartup>()
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
_handler = Task.Run(() => _webHostBuilder.Run());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Stop()
|
|
||||||
{
|
|
||||||
if(_webHostBuilder != null)
|
|
||||||
{
|
|
||||||
_webHostBuilder.Dispose();
|
|
||||||
_handler.Wait();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Builder;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace Ocelot.AcceptanceTests.Fake
|
|
||||||
{
|
|
||||||
public class FakeStartup
|
|
||||||
{
|
|
||||||
public FakeStartup(IHostingEnvironment env)
|
|
||||||
{
|
|
||||||
var builder = new ConfigurationBuilder()
|
|
||||||
.SetBasePath(env.ContentRootPath)
|
|
||||||
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
|
|
||||||
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
|
|
||||||
.AddEnvironmentVariables();
|
|
||||||
Configuration = builder.Build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IConfigurationRoot Configuration { get; }
|
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to add services to the container.
|
|
||||||
public void ConfigureServices(IServiceCollection services)
|
|
||||||
{
|
|
||||||
// Add framework services.
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
|
|
||||||
{
|
|
||||||
app.Run(async context =>
|
|
||||||
{
|
|
||||||
if (context.Request.Method.ToLower() == "get")
|
|
||||||
{
|
|
||||||
await context.Response.WriteAsync("Hello from Laura");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
context.Response.StatusCode = 201;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,32 +1,33 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Net;
|
|
||||||
using System.Net.Http;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
using Microsoft.AspNetCore.TestHost;
|
|
||||||
using Ocelot.AcceptanceTests.Fake;
|
|
||||||
using Ocelot.Library.Infrastructure.Configuration.Yaml;
|
|
||||||
using Shouldly;
|
|
||||||
using TestStack.BDDfy;
|
|
||||||
using Xunit;
|
|
||||||
using YamlDotNet.Serialization;
|
|
||||||
|
|
||||||
namespace Ocelot.AcceptanceTests
|
namespace Ocelot.AcceptanceTests
|
||||||
{
|
{
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Http;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.TestHost;
|
||||||
|
using Ocelot.Library.Infrastructure.Configuration.Yaml;
|
||||||
|
using Shouldly;
|
||||||
|
using TestStack.BDDfy;
|
||||||
|
using Xunit;
|
||||||
|
using YamlDotNet.Serialization;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
public class OcelotTests : IDisposable
|
public class OcelotTests : IDisposable
|
||||||
{
|
{
|
||||||
private readonly FakeService _fakeService;
|
|
||||||
private TestServer _server;
|
private TestServer _server;
|
||||||
private HttpClient _client;
|
private HttpClient _client;
|
||||||
private HttpResponseMessage _response;
|
private HttpResponseMessage _response;
|
||||||
private readonly string _configurationPath;
|
private readonly string _configurationPath;
|
||||||
private StringContent _postContent;
|
private StringContent _postContent;
|
||||||
|
private Task _fake;
|
||||||
|
|
||||||
public OcelotTests()
|
public OcelotTests()
|
||||||
{
|
{
|
||||||
_configurationPath = "./bin/Debug/netcoreapp1.0/configuration.yaml";
|
_configurationPath = "./bin/Debug/netcoreapp1.0/configuration.yaml";
|
||||||
_fakeService = new FakeService();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@ -117,7 +118,29 @@ namespace Ocelot.AcceptanceTests
|
|||||||
|
|
||||||
private void GivenThereIsAServiceRunningOn(string url)
|
private void GivenThereIsAServiceRunningOn(string url)
|
||||||
{
|
{
|
||||||
_fakeService.Start(url);
|
var builder = new WebHostBuilder()
|
||||||
|
.Configure(app =>
|
||||||
|
{
|
||||||
|
app.Run(async context =>
|
||||||
|
{
|
||||||
|
if (context.Request.Method.ToLower() == "get")
|
||||||
|
{
|
||||||
|
await context.Response.WriteAsync("Hello from Laura");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
context.Response.StatusCode = 201;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.UseUrls(url)
|
||||||
|
.UseKestrel()
|
||||||
|
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||||
|
.UseIISIntegration()
|
||||||
|
.UseUrls(url)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
_fake = Task.Run(() => builder.Run());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WhenIGetUrlOnTheApiGateway(string url)
|
private void WhenIGetUrlOnTheApiGateway(string url)
|
||||||
@ -142,7 +165,6 @@ namespace Ocelot.AcceptanceTests
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_fakeService.Stop();
|
|
||||||
_client.Dispose();
|
_client.Dispose();
|
||||||
_server.Dispose();
|
_server.Dispose();
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
|
|||||||
private readonly Mock<ITemplateVariableNameAndValueFinder> _finder;
|
private readonly Mock<ITemplateVariableNameAndValueFinder> _finder;
|
||||||
private string _upstreamUrlPath;
|
private string _upstreamUrlPath;
|
||||||
private Response<DownstreamRoute> _result;
|
private Response<DownstreamRoute> _result;
|
||||||
private Response<DownstreamRoute> _response;
|
|
||||||
private List<ReRoute> _reRoutesConfig;
|
private List<ReRoute> _reRoutesConfig;
|
||||||
private Response<UrlMatch> _match;
|
private Response<UrlMatch> _match;
|
||||||
private string _upstreamHttpMethod;
|
private string _upstreamHttpMethod;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user