Beispiel #1
0
    private async Task <Result> GetAsync(TestServer server, string url = "/graphql")
    {
        HttpResponseMessage response = await server.CreateClient().GetAsync(
            TestServerExtensions.CreateUrl($"{url}/bcp-config.json"));

        var content = await response.Content.ReadAsStringAsync();

        return(new Result
        {
            Content = content,
            ContentType = response.Content.Headers.ContentType,
            StatusCode = response.StatusCode,
        });
    }
        public async Task Download_GraphQL_SDL()
        {
            // arrange
            TestServer server  = CreateStarWarsServer();
            var        url     = TestServerExtensions.CreateUrl("/graphql?sdl");
            var        request = new HttpRequestMessage(HttpMethod.Get, url);

            // act
            HttpResponseMessage response = await server.CreateClient().SendAsync(request);

            // assert
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            var result = await response.Content.ReadAsStringAsync();

            result.MatchSnapshot();
        }
    public async Task Download_GraphQL_SDL_Explicit_Route_Explicit_Pattern()
    {
        // arrange
        TestServer server  = CreateServer(b => b.MapGraphQLSchema("/foo/bar"));
        var        url     = TestServerExtensions.CreateUrl("/foo/bar");
        var        request = new HttpRequestMessage(HttpMethod.Get, url);

        // act
        HttpResponseMessage response = await server.CreateClient().SendAsync(request);

        // assert
        Assert.Equal(HttpStatusCode.OK, response.StatusCode);
        var result = await response.Content.ReadAsStringAsync();

        result.MatchSnapshot();
    }
        public async Task Download_GraphQL_SDL_Disabled()
        {
            // arrange
            TestServer server = CreateStarWarsServer(
                configureConventions: e => e.WithOptions(
                    new GraphQLServerOptions
            {
                EnableSchemaRequests = false
            }));
            var url     = TestServerExtensions.CreateUrl("/graphql?sdl");
            var request = new HttpRequestMessage(HttpMethod.Get, url);

            // act
            HttpResponseMessage response = await server.CreateClient().SendAsync(request);

            // assert
            Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
            var result = await response.Content.ReadAsStringAsync();

            result.MatchSnapshot();
        }