after hours of pissing around on the mac...gave up..so got this configured how i wanted in VS2015 now to see if it works on the mac

This commit is contained in:
TomPallister
2016-07-03 20:39:08 +01:00
parent 3777e8c0c8
commit c512a772d4
36 changed files with 359 additions and 206 deletions

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>54e84f1a-e525-4443-96ec-039cbd50c263</ProjectGuid>
<RootNamespace>Ocelot.UnitTests</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

View File

@ -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.UnitTests")]
[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("54e84f1a-e525-4443-96ec-039cbd50c263")]

View File

@ -0,0 +1,111 @@
using Ocelot.Library.Infrastructure.Responses;
using Ocelot.Library.Infrastructure.Router;
using Shouldly;
using Xunit;
namespace Ocelot.UnitTests
{
public class RouterTests
{
private string _upstreamApiUrl;
private string _apiKey;
private IRouterService _router;
private Response _response;
private Response<Route> _getRouteResponse;
public RouterTests()
{
_router = new InMemoryRouterService();
}
[Fact]
public void can_add_route()
{
GivenIHaveAnUpstreamApi("http://www.someapi.com/api1");
GivenIWantToRouteRequestsToMyUpstreamApi("api");
WhenIAddTheConfiguration();
ThenTheResponseIsSuccesful();
}
[Fact]
public void can_get_route_by_key()
{
GivenIHaveSetUpAnApiKeyAndUpstreamUrl("api2", "http://www.someapi.com/api2");
WhenIRetrieveTheRouteByKey();
ThenTheRouteIsReturned();
}
[Fact]
public void should_return_error_response_when_key_already_used()
{
GivenIHaveSetUpAnApiKeyAndUpstreamUrl("api2", "http://www.someapi.com/api2");
WhenITryToUseTheSameKey();
ThenTheKeyHasAlreadyBeenUsed();
}
[Fact]
public void should_return_error_response_if_key_doesnt_exist()
{
GivenIWantToRouteRequestsToMyUpstreamApi("api");
WhenIRetrieveTheRouteByKey();
ThenTheKeyDoesNotExist();
}
private void WhenITryToUseTheSameKey()
{
WhenIAddTheConfiguration();
}
private void ThenTheKeyHasAlreadyBeenUsed()
{
_response.ShouldNotBeNull();
_response.ShouldBeOfType<ErrorResponse>();
_response.Errors[0].Message.ShouldBe("This key has already been used");
}
private void ThenTheKeyDoesNotExist()
{
_getRouteResponse.ShouldNotBeNull();
_getRouteResponse.ShouldBeOfType<ErrorResponse<Route>>();
_getRouteResponse.Errors[0].Message.ShouldBe("This key does not exist");
}
private void WhenIRetrieveTheRouteByKey()
{
_getRouteResponse = _router.GetRoute(_apiKey);
}
private void ThenTheRouteIsReturned()
{
_getRouteResponse.Data.ApiKey.ShouldBe(_apiKey);
_getRouteResponse.Data.UpstreamRoute.ShouldBe(_upstreamApiUrl);
}
private void GivenIHaveSetUpAnApiKeyAndUpstreamUrl(string apiKey, string upstreamUrl)
{
GivenIHaveAnUpstreamApi(upstreamUrl);
GivenIWantToRouteRequestsToMyUpstreamApi(apiKey);
WhenIAddTheConfiguration();
}
private void GivenIHaveAnUpstreamApi(string upstreamApiUrl)
{
_upstreamApiUrl = upstreamApiUrl;
}
private void GivenIWantToRouteRequestsToMyUpstreamApi(string apiKey)
{
_apiKey = apiKey;
}
private void WhenIAddTheConfiguration()
{
_response = _router.AddRoute(_apiKey, _upstreamApiUrl);
}
private void ThenTheResponseIsSuccesful()
{
_response.ShouldBeOfType<OkResponse>();
}
}
}

View File

@ -0,0 +1,36 @@
{
"version": "1.0.0-*",
"testRunner": "xunit",
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
},
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.AspNetCore.Http": "1.0.0",
"Ocelot.Library": "1.0.0-*",
"xunit": "2.1.0",
"dotnet-test-xunit": "2.2.0-preview2-build1029",
"Shouldly": "2.8.0"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
}
}