Esempio n. 1
0
        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 Should_use_custom_http_client()
		{
			var fakeRequestCoordinator = A.Fake<IRequestCoordinator>();
			var fakeHttpClient = new FakeHttpClient();

			new FluentApi<Status>(fakeRequestCoordinator).UsingClient(fakeHttpClient);

			Assert.That(fakeRequestCoordinator.HttpClient, Is.EqualTo(fakeHttpClient));
		}
		public async void Should_use_custom_http_client()
		{
			var requestHandler = StubRequestBuilder();
			var httpClient = StubHttpClient();
			var responseParser = StubResponseParser();
			var fakeHttpClient = new FakeHttpClient(_stubResponse);

			var api = new FluentApi<Status>(httpClient, requestHandler, responseParser).UsingClient(fakeHttpClient);
			Assert.That(fakeHttpClient.SendCount, Is.EqualTo(0));

			await api.Please();

			Assert.That(fakeHttpClient.SendCount, Is.EqualTo(1));
		}
		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);
		}