public void Works()
        {
            var builder1 = new GhostQueryBuilder <FakeContent>();

            var actual1 = builder1
                          .Limit(5)
                          .Page(2)
                          .OrderByDescending(m => m.PublishedAt)
                          .ApiKey("api_key")
                          .Build();

            Assert.Equal("?fields=Name%2cpublishedAt&limit=5&page=2&order=publishedAt+DESC&key=api_key", actual1);

            var builder2 = new GhostQueryBuilder <FakeContent>();

            var actual2 = builder2
                          .Limit(5)
                          .Page(2)
                          .Order(m => m.PublishedAt)
                          .ApiKey("api_key")
                          .Build();

            Assert.Equal("?fields=Name%2cpublishedAt&limit=5&page=2&order=publishedAt&key=api_key", actual2);


            var builder3 = new GhostQueryBuilder <FakeContent>();

            var actual3 = builder3
                          .Slug("welcome")
                          .ApiKey("api_key")
                          .Build();

            Assert.Equal("slug/welcome?fields=Name%2cpublishedAt&key=api_key", actual3);
        }
        public async Task GetPostsAsync_WithSlug_RequestsToCorrectEndpoint()
        {
            var mockHttp     = CreateMockHttp($"{PostsEndpoint}slug/welcome?fields=title%2cslug%2chtml%2cpublished_at&key=content_api_key", "{}");
            var ghostClient  = new GhostClient(mockHttp.ToHttpClient(), ApiUrl, ContentApiKey);
            var queryBuilder = new GhostQueryBuilder <PostContent>()
                               .Slug("welcome");

            await ghostClient.GetPostsAsync(queryBuilder);

            mockHttp.VerifyNoOutstandingExpectation();
        }
        public async Task GetPostsAsync_ThrowsException_WhenApiReturnsInvalidData()
        {
            var invalidResponse = "123";
            var mockHttp        = CreateMockHttp($"{PostsEndpoint}?fields=title%2cslug%2chtml%2cpublished_at&key=content_api_key", invalidResponse);
            var ghostClient     = new GhostClient(mockHttp.ToHttpClient(), ApiUrl, ContentApiKey);
            var queryBuilder    = new GhostQueryBuilder <PostContent>();

            await Assert.ThrowsAsync <InvalidOperationException>(async() =>
            {
                await ghostClient.GetPostsAsync(queryBuilder);
            });

            mockHttp.VerifyNoOutstandingExpectation();
        }
        public async Task GetPostsAsync_ReturnsCorrectly()
        {
            var actualGhostResponse = TestData.GhostResponseJson;
            var mockHttp            = CreateMockHttp(
                $"{PostsEndpoint}?fields=title%2cslug%2chtml%2cpublished_at&key=content_api_key", actualGhostResponse);

            var ghostClient  = new GhostClient(mockHttp.ToHttpClient(), ApiUrl, ContentApiKey);
            var queryBuilder = new GhostQueryBuilder <PostContent>();

            // Act
            var actual = await ghostClient.GetPostsAsync(queryBuilder);

            var expected = TestData.PostsResponse;

            Assert.Equal(expected.Posts, actual?.Posts);
            Assert.Equal(expected.Meta, actual?.Meta);
        }