From ff10d07b949da6302ab2c8cd45a948e59594b78d Mon Sep 17 00:00:00 2001 From: TomPallister Date: Sat, 16 Jul 2016 15:10:19 +0100 Subject: [PATCH] Set up acceptance tests on windows --- Ocelot.sln | 7 ++++ .../Ocelot.AcceptanceTests.xproj | 22 +++++++++++++ .../Properties/AssemblyInfo.cs | 19 +++++++++++ test/Ocelot.AcceptanceTests/RouterTests.cs | 33 +++++++++++++++---- test/Ocelot.AcceptanceTests/project.json | 7 ++-- 5 files changed, 78 insertions(+), 10 deletions(-) create mode 100644 test/Ocelot.AcceptanceTests/Ocelot.AcceptanceTests.xproj create mode 100644 test/Ocelot.AcceptanceTests/Properties/AssemblyInfo.cs diff --git a/Ocelot.sln b/Ocelot.sln index 848e011d..4387cd03 100644 --- a/Ocelot.sln +++ b/Ocelot.sln @@ -20,6 +20,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{5B401523-3 EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Ocelot.UnitTests", "test\Ocelot.UnitTests\Ocelot.UnitTests.xproj", "{54E84F1A-E525-4443-96EC-039CBD50C263}" EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Ocelot.AcceptanceTests", "test\Ocelot.AcceptanceTests\Ocelot.AcceptanceTests.xproj", "{F8C224FE-36BE-45F5-9B0E-666D8F4A9B52}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -38,6 +40,10 @@ Global {54E84F1A-E525-4443-96EC-039CBD50C263}.Debug|Any CPU.Build.0 = Debug|Any CPU {54E84F1A-E525-4443-96EC-039CBD50C263}.Release|Any CPU.ActiveCfg = Release|Any CPU {54E84F1A-E525-4443-96EC-039CBD50C263}.Release|Any CPU.Build.0 = Release|Any CPU + {F8C224FE-36BE-45F5-9B0E-666D8F4A9B52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F8C224FE-36BE-45F5-9B0E-666D8F4A9B52}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F8C224FE-36BE-45F5-9B0E-666D8F4A9B52}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F8C224FE-36BE-45F5-9B0E-666D8F4A9B52}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -46,5 +52,6 @@ Global {AEC8FB40-B370-48A6-9B38-78E560041F01} = {5CFB79B7-C9DC-45A4-9A75-625D92471702} {D6DF4206-0DBA-41D8-884D-C3E08290FDBB} = {5CFB79B7-C9DC-45A4-9A75-625D92471702} {54E84F1A-E525-4443-96EC-039CBD50C263} = {5B401523-36DA-4491-B73A-7590A26E420B} + {F8C224FE-36BE-45F5-9B0E-666D8F4A9B52} = {5B401523-36DA-4491-B73A-7590A26E420B} EndGlobalSection EndGlobal diff --git a/test/Ocelot.AcceptanceTests/Ocelot.AcceptanceTests.xproj b/test/Ocelot.AcceptanceTests/Ocelot.AcceptanceTests.xproj new file mode 100644 index 00000000..84e2327e --- /dev/null +++ b/test/Ocelot.AcceptanceTests/Ocelot.AcceptanceTests.xproj @@ -0,0 +1,22 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + f8c224fe-36be-45f5-9b0e-666d8f4a9b52 + Ocelot.AcceptanceTests + .\obj + .\bin\ + v4.5 + + + 2.0 + + + + + + \ No newline at end of file diff --git a/test/Ocelot.AcceptanceTests/Properties/AssemblyInfo.cs b/test/Ocelot.AcceptanceTests/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..2f3ceca8 --- /dev/null +++ b/test/Ocelot.AcceptanceTests/Properties/AssemblyInfo.cs @@ -0,0 +1,19 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Ocelot.AcceptanceTests")] +[assembly: AssemblyTrademark("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("f8c224fe-36be-45f5-9b0e-666d8f4a9b52")] diff --git a/test/Ocelot.AcceptanceTests/RouterTests.cs b/test/Ocelot.AcceptanceTests/RouterTests.cs index 43dc2e4d..ecc468ae 100644 --- a/test/Ocelot.AcceptanceTests/RouterTests.cs +++ b/test/Ocelot.AcceptanceTests/RouterTests.cs @@ -1,24 +1,43 @@ using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; +using System.Net.Http; using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; -using Ocelot; +using Microsoft.AspNetCore.TestHost; using Xunit; namespace Ocelot.AcceptanceTests { - public class RouterTests + public class RouterTests : IDisposable { + private readonly TestServer _server; + private readonly HttpClient _client; + public RouterTests() { + // Arrange + _server = new TestServer(new WebHostBuilder() + .UseStartup()); + _client = _server.CreateClient(); } [Fact] - public void should_route_request() + public async Task ReturnHelloWorld() { - + // Act + var response = await _client.GetAsync("/"); + response.EnsureSuccessStatusCode(); + + var responseString = await response.Content.ReadAsStringAsync(); + + // Assert + Assert.Equal("Hello from Tom", + responseString); + } + + public void Dispose() + { + _client.Dispose(); + _server.Dispose(); } } } diff --git a/test/Ocelot.AcceptanceTests/project.json b/test/Ocelot.AcceptanceTests/project.json index da9f68a7..f59b9e22 100644 --- a/test/Ocelot.AcceptanceTests/project.json +++ b/test/Ocelot.AcceptanceTests/project.json @@ -1,4 +1,4 @@ -{ +{ "version": "1.0.0-*", "testRunner": "xunit", @@ -20,10 +20,11 @@ "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0", "Microsoft.AspNetCore.Http": "1.0.0", "Ocelot.Library": "1.0.0-*", - "Ocelot": "1.0.0-*", "xunit": "2.1.0", "dotnet-test-xunit": "2.2.0-preview2-build1029", - "Shouldly": "2.8.0" + "Shouldly": "2.8.0", + "Ocelot": "1.0.0-*", + "Microsoft.AspNetCore.TestHost": "1.0.0" }, "frameworks": {