private async Task <string> GetSettingsAsync(
            TestServer server,
            string path)
        {
            HttpResponseMessage response =
                await server.CreateClient().GetAsync(
                    TestServerExtensions.CreateUrl(path));

            response.EnsureSuccessStatusCode();
            return(await response.Content.ReadAsStringAsync());
        }
        private async Task <Result> GetAsync(TestServer server)
        {
            HttpResponseMessage response = await server.CreateClient().GetAsync(
                TestServerExtensions.CreateUrl("/graphql/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();
        }
Esempio n. 4
0
        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();
        }
Esempio n. 5
0
        public async Task UseGraphQLHttpGetSchema_Builder()
        {
            // arrange
            TestServer server = ServerFactory.Create(
                services => services.AddStarWars(),
                app => app.UseGraphQLHttpGetSchema());

            HttpClient client = server.CreateClient();

            string uri = TestServerExtensions.CreateUrl(null);

            // act
            HttpResponseMessage message = await client.GetAsync(uri);

            // assert
            string s = await message.Content.ReadAsStringAsync();

            s.MatchSnapshot();
        }
Esempio n. 6
0
        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();
        }