forked from graphql-dotnet/graphql-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDefaultValidationTest.cs
More file actions
28 lines (24 loc) · 1.06 KB
/
Copy pathDefaultValidationTest.cs
File metadata and controls
28 lines (24 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System.Net;
using System.Net.Http.Headers;
using FluentAssertions;
using GraphQL.Client.Http;
using Xunit;
namespace GraphQL.Client.Serializer.Tests;
public class DefaultValidationTest
{
[Theory]
[InlineData(HttpStatusCode.OK, "application/json", true)]
[InlineData(HttpStatusCode.OK, "application/graphql-response+json", true)]
[InlineData(HttpStatusCode.BadRequest, "application/json", true)]
[InlineData(HttpStatusCode.BadRequest, "text/html", false)]
[InlineData(HttpStatusCode.OK, "text/html", false)]
[InlineData(HttpStatusCode.Forbidden, "text/html", false)]
[InlineData(HttpStatusCode.Forbidden, "application/json", false)]
public void IsValidResponse_OkJson_True(HttpStatusCode statusCode, string mediaType, bool expectedResult)
{
var response = new HttpResponseMessage(statusCode);
response.Content.Headers.ContentType = new MediaTypeHeaderValue(mediaType);
bool isValid = new GraphQLHttpClientOptions().IsValidResponseToDeserialize(response);
isValid.Should().Be(expectedResult);
}
}