Esempio n. 1
0
        public async Task Returns_content_if_response_is_OK()
        {
            string content  = Guid.NewGuid().ToString();
            var    response = new HttpResponseMessage(HttpStatusCode.OK);

            response.Content = new StringContent(content);

            var httpClient = new HttpClient(new FakeHandler
            {
                Response     = response,
                InnerHandler = new HttpClientHandler()
            });

            var  link    = new GuidServiceLink();
            Guid guid    = Guid.Empty;
            var  machine = new HttpResponseMachine();

            machine.When(HttpStatusCode.OK)
            .Then(async(lr, r) =>
            {
                {
                    guid = Guid.Parse(r.Content.ReadAsStringAsync().Result);
                }
            });


            await httpClient.FollowLinkAsync(link, machine);

            Assert.Equal(content, guid.ToString());
        }
        public async Task Returns_content_if_response_is_OK()
        {
            string content = Guid.NewGuid().ToString();
            var response = new HttpResponseMessage(HttpStatusCode.OK);
            response.Content = new StringContent(content);

            var httpClient = new HttpClient(new FakeHandler
            {
                Response = response,
                InnerHandler = new HttpClientHandler()
            });

            var link = new GuidServiceLink();
            Guid guid = Guid.Empty;
            var machine = new HttpResponseMachine();
            machine.AddResponseHandler(async (lr, r) =>
            {
                {
                    
                    guid = Guid.Parse( r.Content.ReadAsStringAsync().Result);
                    return r;
                }
            }, HttpStatusCode.OK);


            await httpClient.FollowLinkAsync(link,machine);
            
            Assert.Equal(content, guid.ToString());



        }
Esempio n. 3
0
        public void TestLink()
        {
            var link = new GuidServiceLink()
            {
                Target = new Uri("http://localhost/guidservice")
            };
            var httpClient = new HttpClient();

            httpClient.FollowLinkAsync(link);
        }
 public void TestLink()
 {
     var link = new GuidServiceLink()
         {
             Target = new Uri("http://localhost/guidservice")
         };
     var httpClient = new HttpClient();
     httpClient.FollowLinkAsync(link);
     
 }
Esempio n. 5
0
        public Task Returns_content_if_response_is_OK()
        {
            string content = Guid.NewGuid().ToString();
            var response = new HttpResponseMessage(HttpStatusCode.OK);
            response.Content = new StringContent(content);

            var httpClient = new HttpClient(new FakeHandler
            {
                Response = response,
                InnerHandler = new HttpClientHandler()
            });

            var link = new GuidServiceLink();
            return httpClient.FollowLinkAsync(link).ContinueWith(
                t => Assert.Equal(content, link.Guid));
        }