private PostRequest BuildPostRequest(RequestData requestData)
		{
			var uri = ConstructEndpoint(requestData);
			var signedParams = SignHttpPostParams(uri, requestData);
			var postRequest = new PostRequest(uri, requestData.Headers, signedParams);
			return postRequest;
		}
		private GetRequest BuildGetRequest(RequestData requestData)
		{
			var uri = ConstructEndpoint(requestData);
			var signedUrl = SignHttpGetUrl(uri, requestData);
			var getRequest = new GetRequest(signedUrl, requestData.Headers);
			return getRequest;
		}
		private IDictionary<string, string> SignHttpPostParams(string uri, RequestData requestData)
		{
			if (requestData.IsSigned)
			{
				return _urlSigner.SignPostRequest(uri, requestData.UserToken, requestData.TokenSecret, _oAuthCredentials, requestData.Parameters);
			}
			return requestData.Parameters;
		}
		private string SignHttpGetUrl(string uri, RequestData requestData)
		{
			if (requestData.IsSigned)
			{
				return _urlSigner.SignGetUrl(uri, requestData.UserToken, requestData.TokenSecret, _oAuthCredentials);
			}
			return uri;
		}
		public void Should_not_care_how_many_times_you_create_an_endpoint()
		{
			var endPointState = new RequestData
				{
					UriPath = "{slug}", 
					HttpMethod = "GET", 
					Parameters = new Dictionary<string, string> { { "slug", "something" } }
				};
			var result = _requestCoordinator.ConstructEndpoint(endPointState);

			Assert.That(result, Is.EqualTo(_requestCoordinator.ConstructEndpoint(endPointState)));
		}
		public void should_substitue_route_parameters()
		{
			var requestData = new RequestData
			{
				UriPath = "something/{route}",
				Parameters = new Dictionary<string, string>
					{
						{"route","routevalue"}
					}
			};

			var result = _requestCoordinator.ConstructEndpoint(requestData);

			Assert.That(result,Is.StringContaining("something/routevalue"));
		}
		public void Should_fire_resolve_with_correct_values()
		{
			A.CallTo(() => _httpClient.Get(A<GetRequest>.Ignored))
				.Returns(new Response(HttpStatusCode.OK, SERVICE_STATUS));

			const string expectedMethod = "GET";
			var expectedHeaders = new Dictionary<string, string>();
			var expected = string.Format("{0}/test?oauth_consumer_key={1}", API_URL, _consumerKey);

			var requestData = new RequestData { UriPath = "test", HttpMethod = expectedMethod, Headers = expectedHeaders };

			_requestCoordinator.HitEndpoint(requestData);

			A.CallTo(() => _httpClient
					.Get(A<GetRequest>.That.Matches(y => y.Url == expected)))
					.MustHaveHappened();
		}
		public void routes_should_be_case_insensitive()
		{
			var requestData = new RequestData
			{
				UriPath = "something/{firstRoUte}/{secOndrouTe}/thrid/{tHirdRoute}",
				Parameters = new Dictionary<string, string>
					{
						{"firstRoute" , "firstValue"},
						{"secondRoute","secondValue"},
						{"thirdRoute" , "thirdValue"}
							
					}
			};

			var result = _requestCoordinator.ConstructEndpoint(requestData);

			Assert.That(result, Is.StringContaining("something/firstvalue/secondvalue/thrid/thirdvalue"));
		}
		public void should_substitue_multiple_route_parameters()
		{
			var requestData = new RequestData
			{
				UriPath = "something/{firstRoute}/{secondRoute}/thrid/{thirdRoute}",
				Parameters = new Dictionary<string, string>
					{
						{"firstRoute" , "firstValue"},
						{"secondRoute","secondValue"},
						{"thirdRoute" , "thirdValue"}
							
					}
			};

			var result = _requestCoordinator.ConstructEndpoint(requestData);

			Assert.That(result, Is.StringContaining("something/firstvalue/secondvalue/thrid/thirdvalue"));
		}
		public void Should_fire_resolve_with_url_encoded_parameters()
		{
			A.CallTo(() => _httpClient.Get(A<GetRequest>.Ignored))
				.Returns(new Response(HttpStatusCode.OK, SERVICE_STATUS));

			const string unEncodedParameterValue = "Alive & Amplified";

			const string expectedParameterValue = "Alive%20%26%20Amplified";
			var expectedHeaders = new Dictionary<string, string>();
			var testParameters = new Dictionary<string, string> { { "q", unEncodedParameterValue } };
			var expected = string.Format("{0}/test?oauth_consumer_key={1}&q={2}", API_URL, _consumerKey, expectedParameterValue);

			var requestData = new RequestData { UriPath = "test", HttpMethod = "GET", Headers = expectedHeaders, Parameters = testParameters };

			_requestCoordinator.HitEndpoint(requestData);

			A.CallTo(() => _httpClient
					.Get(A<GetRequest>.That.Matches(y => y.Url == expected)))
					.MustHaveHappened();
		}
		public override void HitEndpointAsync(RequestData requestData, Action<Response> action)
		{
			var postRequest = BuildPostRequest(requestData);
			HttpClient.PostAsync(postRequest,response => action(response));
		}
		public override Response HitEndpoint(RequestData requestData)
		{
			var postRequest = BuildPostRequest(requestData);
			return HttpClient.Post(postRequest);
		}
		public void should_handle_dashes_and_numbers()
		{
			var requestData = new RequestData
			{
				UriPath = "something/{route-66}",
				Parameters = new Dictionary<string, string>
					{
						{"route-66","routevalue"}
					}
			};

			var result = _requestCoordinator.ConstructEndpoint(requestData);

			Assert.That(result, Is.StringContaining("something/routevalue"));
		}
		public Response HitEndpointAndGetResponse(RequestData requestData)
		{
			throw new NotImplementedException();
		}
		public override Response HitEndpoint(RequestData requestData)
		{
			var getRequest = BuildGetRequest(requestData);
			return HttpClient.Get(getRequest);
		}
		public bool TryGet(RequestData key, out Response value)
		{
			TryGetCount++;
			value = StubResponse;
			return (StubResponse != null);
		}
		public void Set(RequestData key, Response value)
		{
			SetCount++;
			CachedResponses.Add(value);
		}
		public string ConstructEndpoint(RequestData requestData)
		{
			throw new NotImplementedException();
		}
		public void HitEndpointAsync(RequestData requestData, Action<Response> callback)
		{
			callback(StubPayload);
		}
		public void Should_use_api_uri_provided_by_IApiUri_interface()
		{
			const string expectedApiUri = "http://api.7dizzle";

			Given_a_urlresolver_that_returns_valid_xml();

			var apiUri = A.Fake<IApiUri>();

			A.CallTo(() => apiUri.Uri).Returns(expectedApiUri);

			IOAuthCredentials oAuthCredentials = EssentialDependencyCheck<IOAuthCredentials>.Instance;
			var endpointResolver = new RequestCoordinator(_httpClient, _urlSigner, oAuthCredentials, apiUri);

			var requestData = new RequestData
				{
					UriPath = "test", 
					HttpMethod = "GET", 
					Headers = new Dictionary<string, string>()
				};

			endpointResolver.HitEndpoint(requestData);

			A.CallTo(() => apiUri.Uri).MustHaveHappened(Repeated.Exactly.Once);

			A.CallTo(() => _httpClient.Get(
				A<GetRequest>.That.Matches(x => x.Url.ToString().Contains(expectedApiUri))))
				.MustHaveHappened(Repeated.Exactly.Once);
		}
		public void should_remove_parameters_that_match()
		{
			var requestData = new RequestData
			{
				UriPath = "something/{route-66}",
				Parameters = new Dictionary<string, string>
					{
						{"route-66","routevalue"}
					}
			};

			var result = _requestCoordinator.ConstructEndpoint(requestData);

			Assert.That(result, Is.Not.StringContaining("route-66=routevalue"));
		}