Removed the fake woop

This commit is contained in:
tom.pallister 2016-10-12 14:00:13 +01:00
parent 58393f07ec
commit cff130196f
4 changed files with 41 additions and 101 deletions

View File

@ -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();
}
}
}
}

View File

@ -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;
}
});
}
}
}

View File

@ -1,3 +1,5 @@
namespace Ocelot.AcceptanceTests
{
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@ -5,28 +7,27 @@ using System.Net;
using System.Net.Http; using System.Net.Http;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.TestHost; using Microsoft.AspNetCore.TestHost;
using Ocelot.AcceptanceTests.Fake;
using Ocelot.Library.Infrastructure.Configuration.Yaml; using Ocelot.Library.Infrastructure.Configuration.Yaml;
using Shouldly; using Shouldly;
using TestStack.BDDfy; using TestStack.BDDfy;
using Xunit; using Xunit;
using YamlDotNet.Serialization; using YamlDotNet.Serialization;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
namespace Ocelot.AcceptanceTests
{
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();
} }

View File

@ -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;