public void SetUp() { IOAuthCredentials oAuthCredentials = EssentialDependencyCheck<IOAuthCredentials>.Instance; IApiUri apiUri = EssentialDependencyCheck<IApiUri>.Instance; var httpGetResolver = new HttpClient(); var urlSigner = new UrlSigner(); _requestCoordinator = new RequestCoordinator(httpGetResolver, urlSigner, oAuthCredentials, apiUri); }
public void Setup() { var httpClient = A.Fake<IHttpClient>(); A.CallTo(() => httpClient.Get(A<GetRequest>.Ignored)).Returns(new Response(HttpStatusCode.OK, "OK")); var apiUri = A.Fake<IApiUri>(); A.CallTo(() => apiUri.Uri) .Returns("http://uri/"); _requestCoordinator = new RequestCoordinator(httpClient, new UrlSigner(new OAuthSignatureGenerator()), new AppSettingsCredentials(), apiUri); }
public void Setup() { var httpClient = A.Fake<IHttpClient>(); A.CallTo(() => httpClient.Get(A<IRequest>.Ignored.Argument)).Returns(new Response()); var apiUri = A.Fake<IApiUri>(); A.CallTo(() => apiUri.Uri) .Returns("http://uri/"); _requestCoordinator = new RequestCoordinator(httpClient, new UrlSigner(), new AppSettingsCredentials(), apiUri); }
public void Setup() { _httpClient = A.Fake<IHttpClient>(); _urlSigner = A.Fake<IUrlSigner>(); _requestCoordinator = new RequestCoordinator(_httpClient, _urlSigner, EssentialDependencyCheck<IOAuthCredentials>.Instance, EssentialDependencyCheck<IApiUri>.Instance); }
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 endPointState = new EndPointInfo { UriPath = "test", HttpMethod = "GET", Headers = new Dictionary<string, string>() }; endpointResolver.HitEndpoint(endPointState); 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_return_xmlnode_if_valid_xml_received_using_async() { var fakeClient = new FakeHttpClient(new Response(HttpStatusCode.OK, SERVICE_STATUS)); var endpointResolver = new RequestCoordinator(fakeClient, _urlSigner, EssentialDependencyCheck<IOAuthCredentials>.Instance, EssentialDependencyCheck<IApiUri>.Instance); var reset = new AutoResetEvent(false); string response = string.Empty; endpointResolver.HitEndpointAsync(new EndPointInfo(), s => { response = s.Body; reset.Set(); }); reset.WaitOne(1000 * 5); var payload = new XmlDocument(); payload.LoadXml(response); Assert.That(payload.HasChildNodes); Assert.That(payload.SelectSingleNode("//serverTime"), Is.Not.Null); }