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_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 RequestData(), 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); }
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 AppSettingsCredentials(), apiUri); }
public override void onTrigger(IChatService svc, IChatMessage msg, string[] arg) { if (arg.Length < 1) { arg = new string[] { "" }; } switch (arg[0]) { case "sub": svc.SendTextMessage("Sent Debug Sub Rain.", msg.Channel); RequestCoordinator.subRain(); break; case "": svc.SendTextMessage($"No Alert Rain selected. {Settings.prefix} alert <type>", msg.Channel); break; } }
public void Setup() { _httpClient = A.Fake <IHttpClient>(); _urlSigner = A.Fake <IUrlSigner>(); _requestCoordinator = new RequestCoordinator(_httpClient, _urlSigner, EssentialDependencyCheck <IOAuthCredentials> .Instance, EssentialDependencyCheck <IApiUri> .Instance); }