public async Task can_fetch_a_root_resource()
        {
            var testServer = TestServer.Create<StartUp>();
            var client = new HyperFriendlyHttpClient(testServer.HttpClient, Uris.Home);

            await client.RootAsync();

            client.CurrentResult.StatusCode.ShouldEqual(HttpStatusCode.OK);
        }
        public async Task can_follow_is_true_when_rel_does_not_exist()
        {
            var testServer = TestServer.Create<StartUp>();
            var client = new HyperFriendlyHttpClient(testServer.HttpClient, Uris.Home);
            await client.RootAsync();

            var canFollow = client.CanFollow("not_a_resource");

            canFollow.ShouldBeFalse();
        }
        public async Task can_follow_a_link_for_all_supported_http_verbs(string rel)
        {
            var testServer = TestServer.Create<StartUp>();
            var client = new HyperFriendlyHttpClient(testServer.HttpClient, Uris.Home);

            await client.RootAsync();
            await client.FollowAsync(rel);
            JToken json = client.CurrentResult.ToJson();

            json.Value<string>("type").ShouldEqual(rel);
        }
        public async Task can_get_a_resource_content_as_a_serialized_object()
        {
            var testServer = TestServer.Create<StartUp>();
            var client = new HyperFriendlyHttpClient(testServer.HttpClient, Uris.Home);

            await client.RootAsync();
            await client.FollowAsync("some_resource");
            SomeResource resource = client.CurrentResult.ToObject<SomeResource>();

            resource.Type.ShouldEqual("some_resource");
        }
        public async Task can_get_a_resource_by_following_a_rel()
        {
            var testServer = TestServer.Create<StartUp>();
            var client = new HyperFriendlyHttpClient(testServer.HttpClient, Uris.Home);

            await client.RootAsync();
            await client.FollowAsync("some_resource");
            JToken json = client.CurrentResult.ToJson();

            json.Value<string>("type").ShouldEqual("some_resource");
        }
        public async Task can_follow_a_templated_link_using_an_anonymus_object()
        {
            var testServer = TestServer.Create<StartUp>();
            var client = new HyperFriendlyHttpClient(testServer.HttpClient, Uris.Home);
            await client.RootAsync();

            await client.FollowAsync("templated_resource", arguments: new { foo = "bar" });
            JToken json = client.CurrentResult.ToJson();

            json.Value<string>("type").ShouldEqual("templated_resource");
        }
        public async Task can_follow_is_true_when_location_header_exists()
        {
            var testServer = TestServer.Create<StartUp>();
            var client = new HyperFriendlyHttpClient(testServer.HttpClient, Uris.Home);
            await client.RootAsync();
            await client.FollowAsync("redirecting_resource");

            var canFollow = client.CanFollow();

            canFollow.ShouldBeTrue();
        }
        public async Task can_get_a_resource_by_following_the_location_header_of_another_resource()
        {
            var testServer = TestServer.Create<StartUp>();
            var client = new HyperFriendlyHttpClient(testServer.HttpClient, Uris.Home);

            await client.RootAsync();
            await client.FollowAsync("redirecting_resource");
            await client.FollowAsync();
            JToken json = client.CurrentResult.ToJson();

            json.Value<string>("type").ShouldEqual("resource_that_is_redirected_to");
        }
        public async Task can_get_a_root_resource_content_as_json()
        {
            var testServer = TestServer.Create<StartUp>();
            var client = new HyperFriendlyHttpClient(testServer.HttpClient, Uris.Home);

            await client.RootAsync();
            JToken jsonResult = client.CurrentResult.ToJson();

            jsonResult
                .SelectToken("_links.self.href")
                .Value<string>()
                .ShouldEqual("/");
        }
        public async Task can_post_content_to_a_resource()
        {
            var testServer = TestServer.Create<StartUp>();
            var client = new HyperFriendlyHttpClient(testServer.HttpClient, Uris.Home);
            var content = new { foo = "bar" };

            await client.RootAsync();
            await client.FollowAsync("some_resource_with_content", content);
            JToken json = client.CurrentResult.ToJson();

            json.Value<string>("type").ShouldEqual("some_resource_with_content");
            json.Value<string>("foo").ShouldEqual("bar");
        }
        public async Task can_get_a_collection_as_a_serialized_enumerable()
        {
            var testServer = TestServer.Create<StartUp>();
            var client = new HyperFriendlyHttpClient(testServer.HttpClient, Uris.Home);

            await client.RootAsync();
            await client.FollowAsync("collection_resource");
            var result = client.CurrentResult.CollectionResult<SomeResource>();

            var items = result.ToArray();
            items.Count().ShouldEqual(2);
            items.First().Type.ShouldEqual("some_resource");
            items.Last().Type.ShouldEqual("some_resource_2");
        }