public async Task HttpPost_EnumArgument() { // arrange TestServer server = CreateTestServer(); QueryRequestDto request = new QueryRequestDto { Query = "query a($a: TestEnum) { withEnum(test: $a) }", Variables = JObject.FromObject(new Dictionary <string, object> { { "a", "A" } }) }; // act HttpResponseMessage message = await server.SendRequestAsync(request); // assert Assert.Equal(HttpStatusCode.OK, message.StatusCode); string json = await message.Content.ReadAsStringAsync(); QueryResultDto result = JsonConvert.DeserializeObject <QueryResultDto>(json); Assert.Null(result.Errors); Assert.Equal(Snapshot.Current(), Snapshot.New(result)); }
public async Task HttpPost_WithHttpContext() { // arrange TestServer server = CreateTestServer(); QueryRequestDto request = new QueryRequestDto { Query = @" { requestPath }" }; // act HttpResponseMessage message = await server.SendRequestAsync(request); // assert Assert.Equal(HttpStatusCode.OK, message.StatusCode); string json = await message.Content.ReadAsStringAsync(); QueryResultDto result = JsonConvert.DeserializeObject <QueryResultDto>(json); Assert.Null(result.Errors); Assert.Equal(Snapshot.Current(), Snapshot.New(result)); }
public async Task SendRequestWithArguments() { // arrange Schema schema = CreateSchema(); QueryRequestDto request = new QueryRequestDto { Query = @" query test($a: String) { withScalarArgument(a: $a) { a } }", Variables = new Dictionary <string, object> { { "a", "a" } } }; TestServer server = TestServerFactory.Create(schema, null); // act HttpResponseMessage message = await server.SendRequestAsync(request); // assert Assert.Equal(HttpStatusCode.OK, message.StatusCode); string json = await message.Content.ReadAsStringAsync(); QueryResultDto result = JsonConvert.DeserializeObject <QueryResultDto>(json); Assert.Null(result.Errors); Assert.Equal(Snapshot.Current(), Snapshot.New(result)); }
public async Task BasicTest() { // arrange Schema schema = CreateSchema(); QueryRequestDto request = new QueryRequestDto { Query = "{ basic { a } }" }; TestServer server = TestServerFactory.Create(schema, null); // act HttpResponseMessage message = await server.SendRequestAsync(request); // assert Assert.Equal(HttpStatusCode.OK, message.StatusCode); string json = await message.Content.ReadAsStringAsync(); QueryResultDto result = JsonConvert.DeserializeObject <QueryResultDto>(json); Assert.Null(result.Errors); Assert.Equal(Snapshot.Current(), Snapshot.New(result)); }
public async Task HttpPost_WithObjectVariables() { // arrange TestServer server = CreateTestServer(); QueryRequestDto request = new QueryRequestDto { Query = @" query test($a: FooInput!) { withObjectArgument(b: $a) { a b c } }", Variables = JObject.FromObject(new Dictionary <string, object> { { "a", new Dictionary <string, object> { { "a", "44" }, { "b", "55" }, { "c", 66 } } } }) }; // act HttpResponseMessage message = await server.SendRequestAsync(request); // assert Assert.Equal(HttpStatusCode.OK, message.StatusCode); string json = await message.Content.ReadAsStringAsync(); QueryResultDto result = JsonConvert.DeserializeObject <QueryResultDto>(json); Assert.Null(result.Errors); Assert.Equal(Snapshot.Current(), Snapshot.New(result)); }