From 02625d58943d999f603032cb5c18d2b4214cb1ae Mon Sep 17 00:00:00 2001 From: Ivan Maximov Date: Fri, 3 Apr 2020 20:48:10 +0300 Subject: [PATCH 1/9] spell check, formatting, code cleanup --- GraphQL.Client.sln | 7 +++-- .../GraphQL.Client.Example.csproj | 1 - .../PersonAndFilmsResponse.cs | 1 + examples/GraphQL.Client.Example/Program.cs | 6 +--- root.props | 1 - ...aphQL.Client.Abstractions.Websocket.csproj | 4 +-- .../GraphQLWebSocketMessageType.cs | 1 - .../GraphQLWebSocketRequest.cs | 5 +--- .../GraphQLWebSocketResponse.cs | 3 -- .../GraphQLWebsocketConnectionState.cs | 2 ++ .../IGraphQLWebsocketJsonSerializer.cs | 2 +- .../GraphQL.Client.Abstractions.csproj | 1 - .../IGraphQLClient.cs | 5 +--- .../IGraphQLJsonSerializer.cs | 5 +--- .../ExecutionResultExtensions.cs | 7 ----- .../GraphQLEnumConverter.cs | 1 - .../GraphQLLocalExecutionClient.cs | 4 +-- ...raphQL.Client.Serializer.Newtonsoft.csproj | 2 +- .../MapConverter.cs | 15 ++++------ .../NewtonsoftJsonSerializer.cs | 2 -- ...QL.Client.Serializer.SystemTextJson.csproj | 2 +- .../ImmutableConverter.cs | 1 - .../JsonSerializerOptionsExtensions.cs | 3 +- src/GraphQL.Client/GraphQL.Client.csproj | 10 ++----- src/GraphQL.Client/GraphQLHttpClient.cs | 29 +++++++++---------- .../GraphQLHttpClientExtensions.cs | 2 +- .../GraphQLHttpClientOptions.cs | 2 -- src/GraphQL.Client/GraphQLHttpException.cs | 4 --- src/GraphQL.Client/GraphQLHttpRequest.cs | 1 - src/GraphQL.Client/GraphQLHttpResponse.cs | 4 +-- .../Websocket/GraphQLHttpWebSocket.cs | 7 ++--- .../GraphQL.Primitives.csproj | 1 + src/GraphQL.Primitives/GraphQLError.cs | 7 +---- src/GraphQL.Primitives/GraphQLLocation.cs | 4 --- src/GraphQL.Primitives/GraphQLRequest.cs | 3 -- src/GraphQL.Primitives/GraphQLResponse.cs | 7 ----- src/GraphQL.Primitives/Map.cs | 1 - src/src.props | 1 - .../BaseSerializeNoCamelCaseTest.cs | 4 +-- .../BaseSerializerTest.cs | 3 +- .../Chat/AddMessageMutationResult.cs | 1 + .../Chat/AddMessageVariables.cs | 4 ++- .../Chat/GraphQLClientChatExtensions.cs | 1 - .../Chat/JoinDeveloperMutationResult.cs | 2 ++ .../Chat/Schema/ChatQuery.cs | 2 -- tests/GraphQL.Client.Tests.Common/Common.cs | 1 + .../Helpers/CallbackMonitor.cs | 1 + .../Helpers/ConcurrentTaskWrapper.cs | 1 - .../Helpers/MiscellaneousExtensions.cs | 2 -- .../Helpers/ObservableTester.cs | 2 +- .../GraphQL.Integration.Tests.csproj | 4 +-- .../Helpers/IntegrationServerTestFixture.cs | 2 ++ .../Helpers/WebHostHelpers.cs | 2 ++ .../QueryAndMutationTests/Base.cs | 3 -- .../WebsocketTests/Base.cs | 7 +---- .../WebsocketTests/Newtonsoft.cs | 3 +- .../GraphQLLocationTest.cs | 4 --- .../GraphQLRequestTest.cs | 29 ++++++++++--------- .../GraphQLResponseTest.cs | 4 --- .../JsonSerializationTests.cs | 2 -- .../GraphQL/Models/Repository.cs | 8 ++--- tests/GraphQL.Server.Test/GraphQL/Storage.cs | 4 --- .../GraphQL/TestMutation.cs | 4 --- .../GraphQL.Server.Test/GraphQL/TestQuery.cs | 4 --- .../GraphQL.Server.Test/GraphQL/TestSchema.cs | 4 --- .../GraphQL/TestSubscription.cs | 4 --- tests/GraphQL.Server.Test/Program.cs | 6 +--- tests/GraphQL.Server.Test/Startup.cs | 12 -------- tests/IntegrationTestServer/Startup.cs | 6 ++-- tests/tests.props | 1 - 70 files changed, 91 insertions(+), 210 deletions(-) delete mode 100644 src/GraphQL.Client.LocalExecution/ExecutionResultExtensions.cs diff --git a/GraphQL.Client.sln b/GraphQL.Client.sln index 24ea23a4..3d966cd9 100644 --- a/GraphQL.Client.sln +++ b/GraphQL.Client.sln @@ -34,8 +34,9 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{05CAF9B2-981E-40C0-AE31-5FA56E351F12}" ProjectSection(SolutionItems) = preProject .github\workflows\branches-ubuntu.yml = .github\workflows\branches-ubuntu.yml - .github\workflows\branches.yml = .github\workflows\branches.yml - .github\workflows\main.yml = .github\workflows\main.yml + .github\workflows\branches-windows.yml = .github\workflows\branches-windows.yml + .github\workflows\main-ubuntu.yml = .github\workflows\main-ubuntu.yml + .github\workflows\main-windows.yml = .github\workflows\main-windows.yml EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GraphQL.Primitives", "src\GraphQL.Primitives\GraphQL.Primitives.csproj", "{87FC440E-6A4D-47D8-9EB2-416FC31CC4A6}" @@ -64,7 +65,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GraphQL.Client.Serializer.S EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{89AD33AB-64F6-4F82-822F-21DF7A10CEC0}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GraphQL.Client.Example", "examples\GraphQL.Client.Example\GraphQL.Client.Example.csproj", "{6B13B87D-1EF4-485F-BC5D-891E2F4DA6CD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GraphQL.Client.Example", "examples\GraphQL.Client.Example\GraphQL.Client.Example.csproj", "{6B13B87D-1EF4-485F-BC5D-891E2F4DA6CD}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/examples/GraphQL.Client.Example/GraphQL.Client.Example.csproj b/examples/GraphQL.Client.Example/GraphQL.Client.Example.csproj index 54506df0..d6a75865 100644 --- a/examples/GraphQL.Client.Example/GraphQL.Client.Example.csproj +++ b/examples/GraphQL.Client.Example/GraphQL.Client.Example.csproj @@ -3,7 +3,6 @@ Exe netcoreapp3.1 - false diff --git a/examples/GraphQL.Client.Example/PersonAndFilmsResponse.cs b/examples/GraphQL.Client.Example/PersonAndFilmsResponse.cs index ea3d7de5..eafba6d1 100644 --- a/examples/GraphQL.Client.Example/PersonAndFilmsResponse.cs +++ b/examples/GraphQL.Client.Example/PersonAndFilmsResponse.cs @@ -9,6 +9,7 @@ public class PersonAndFilmsResponse public class PersonContent { public string Name { get; set; } + public FilmConnectionContent FilmConnection { get; set; } public class FilmConnectionContent diff --git a/examples/GraphQL.Client.Example/Program.cs b/examples/GraphQL.Client.Example/Program.cs index 2ef597ec..0bfd14b1 100644 --- a/examples/GraphQL.Client.Example/Program.cs +++ b/examples/GraphQL.Client.Example/Program.cs @@ -7,13 +7,10 @@ namespace GraphQL.Client.Example { - public class Program { - - public static async Task Main(string[] args) + public static async Task Main() { - _ = args; using var graphQLClient = new GraphQLHttpClient("https://swapi.apis.guru/", new NewtonsoftJsonSerializer()); var personAndFilmsRequest = new GraphQLRequest @@ -49,6 +46,5 @@ query PersonAndFilms($id: ID) { Console.WriteLine("Press any key to quit..."); Console.ReadKey(); } - } } diff --git a/root.props b/root.props index 2c0a5b7d..b076b4d3 100644 --- a/root.props +++ b/root.props @@ -1,4 +1,3 @@ - diff --git a/src/GraphQL.Client.Abstractions.Websocket/GraphQL.Client.Abstractions.Websocket.csproj b/src/GraphQL.Client.Abstractions.Websocket/GraphQL.Client.Abstractions.Websocket.csproj index c191671f..9abfd542 100644 --- a/src/GraphQL.Client.Abstractions.Websocket/GraphQL.Client.Abstractions.Websocket.csproj +++ b/src/GraphQL.Client.Abstractions.Websocket/GraphQL.Client.Abstractions.Websocket.csproj @@ -1,14 +1,14 @@ + Abstractions for the Websocket transport used in GraphQL.Client netstandard2.0 - 8.0 - + diff --git a/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebSocketMessageType.cs b/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebSocketMessageType.cs index 6dd7f019..daa83114 100644 --- a/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebSocketMessageType.cs +++ b/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebSocketMessageType.cs @@ -84,6 +84,5 @@ public static class GraphQLWebSocketMessageType /// id: string : operation id /// public const string GQL_STOP = "stop"; // Client -> Server - } } diff --git a/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebSocketRequest.cs b/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebSocketRequest.cs index 7c986acc..623e4271 100644 --- a/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebSocketRequest.cs +++ b/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebSocketRequest.cs @@ -4,7 +4,6 @@ namespace GraphQL.Client.Abstractions.Websocket { - /// /// A Subscription Request /// @@ -50,7 +49,7 @@ public GraphQLRequest Payload public Task SendTask() => _tcs.Task; /// - /// gets called when the send operation for this request has completed sucessfully + /// gets called when the send operation for this request has completed successfully /// public void SendCompleted() => _tcs.SetResult(true); @@ -109,7 +108,5 @@ public override int GetHashCode() /// public static bool operator !=(GraphQLWebSocketRequest request1, GraphQLWebSocketRequest request2) => !(request1 == request2); - } - } diff --git a/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebSocketResponse.cs b/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebSocketResponse.cs index d6c69a70..390834da 100644 --- a/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebSocketResponse.cs +++ b/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebSocketResponse.cs @@ -3,13 +3,11 @@ namespace GraphQL.Client.Abstractions.Websocket { - /// /// A Subscription Response /// public class GraphQLWebSocketResponse : IEquatable { - /// /// The Identifier of the Response /// @@ -65,7 +63,6 @@ public override int GetHashCode() /// public static bool operator !=(GraphQLWebSocketResponse response1, GraphQLWebSocketResponse response2) => !(response1 == response2); - } public class GraphQLWebSocketResponse : GraphQLWebSocketResponse, IEquatable> diff --git a/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebsocketConnectionState.cs b/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebsocketConnectionState.cs index 148436cd..c5fd3107 100644 --- a/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebsocketConnectionState.cs +++ b/src/GraphQL.Client.Abstractions.Websocket/GraphQLWebsocketConnectionState.cs @@ -3,7 +3,9 @@ namespace GraphQL.Client.Abstractions.Websocket public enum GraphQLWebsocketConnectionState { Disconnected, + Connecting, + Connected } } diff --git a/src/GraphQL.Client.Abstractions.Websocket/IGraphQLWebsocketJsonSerializer.cs b/src/GraphQL.Client.Abstractions.Websocket/IGraphQLWebsocketJsonSerializer.cs index 23536db5..5e3d58ec 100644 --- a/src/GraphQL.Client.Abstractions.Websocket/IGraphQLWebsocketJsonSerializer.cs +++ b/src/GraphQL.Client.Abstractions.Websocket/IGraphQLWebsocketJsonSerializer.cs @@ -12,7 +12,7 @@ public interface IGraphQLWebsocketJsonSerializer : IGraphQLJsonSerializer byte[] SerializeToBytes(GraphQLWebSocketRequest request); Task DeserializeToWebsocketResponseWrapperAsync(Stream stream); - GraphQLWebSocketResponse> DeserializeToWebsocketResponse(byte[] bytes); + GraphQLWebSocketResponse> DeserializeToWebsocketResponse(byte[] bytes); } } diff --git a/src/GraphQL.Client.Abstractions/GraphQL.Client.Abstractions.csproj b/src/GraphQL.Client.Abstractions/GraphQL.Client.Abstractions.csproj index 63e9aa89..666c63c0 100644 --- a/src/GraphQL.Client.Abstractions/GraphQL.Client.Abstractions.csproj +++ b/src/GraphQL.Client.Abstractions/GraphQL.Client.Abstractions.csproj @@ -4,7 +4,6 @@ Abstractions for GraphQL.Client - GraphQL.Client.Abstractions netstandard2.0 diff --git a/src/GraphQL.Client.Abstractions/IGraphQLClient.cs b/src/GraphQL.Client.Abstractions/IGraphQLClient.cs index df0557af..0508f8b5 100644 --- a/src/GraphQL.Client.Abstractions/IGraphQLClient.cs +++ b/src/GraphQL.Client.Abstractions/IGraphQLClient.cs @@ -5,10 +5,8 @@ namespace GraphQL.Client.Abstractions { - public interface IGraphQLClient : IDisposable { - Task> SendQueryAsync(GraphQLRequest request, CancellationToken cancellationToken = default); Task> SendMutationAsync(GraphQLRequest request, CancellationToken cancellationToken = default); @@ -30,9 +28,8 @@ public interface IGraphQLClient : IDisposable /// Any exception thrown by will cause the sequence to fail. /// /// the GraphQL request for this subscription - /// an external handler for all s occuring within the sequence + /// an external handler for all s occurring within the sequence /// an observable stream for the specified subscription IObservable> CreateSubscriptionStream(GraphQLRequest request, Action exceptionHandler); } - } diff --git a/src/GraphQL.Client.Abstractions/IGraphQLJsonSerializer.cs b/src/GraphQL.Client.Abstractions/IGraphQLJsonSerializer.cs index 5c119e4a..fa21dbac 100644 --- a/src/GraphQL.Client.Abstractions/IGraphQLJsonSerializer.cs +++ b/src/GraphQL.Client.Abstractions/IGraphQLJsonSerializer.cs @@ -8,9 +8,6 @@ public interface IGraphQLJsonSerializer { string SerializeToString(GraphQLRequest request); - Task> DeserializeFromUtf8StreamAsync(Stream stream, - CancellationToken cancellationToken); + Task> DeserializeFromUtf8StreamAsync(Stream stream, CancellationToken cancellationToken); } - - } diff --git a/src/GraphQL.Client.LocalExecution/ExecutionResultExtensions.cs b/src/GraphQL.Client.LocalExecution/ExecutionResultExtensions.cs deleted file mode 100644 index 32133976..00000000 --- a/src/GraphQL.Client.LocalExecution/ExecutionResultExtensions.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace GraphQL.Client.LocalExecution -{ - public class ExecutionResultExtensions - { - - } -} diff --git a/src/GraphQL.Client.LocalExecution/GraphQLEnumConverter.cs b/src/GraphQL.Client.LocalExecution/GraphQLEnumConverter.cs index 89bbcfc0..a02cf935 100644 --- a/src/GraphQL.Client.LocalExecution/GraphQLEnumConverter.cs +++ b/src/GraphQL.Client.LocalExecution/GraphQLEnumConverter.cs @@ -34,5 +34,4 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s } } } - } diff --git a/src/GraphQL.Client.LocalExecution/GraphQLLocalExecutionClient.cs b/src/GraphQL.Client.LocalExecution/GraphQLLocalExecutionClient.cs index c055cecb..d458d20e 100644 --- a/src/GraphQL.Client.LocalExecution/GraphQLLocalExecutionClient.cs +++ b/src/GraphQL.Client.LocalExecution/GraphQLLocalExecutionClient.cs @@ -22,10 +22,8 @@ public static GraphQLLocalExecutionClient New(TSchema schema, => new GraphQLLocalExecutionClient(schema, serializer); } - public class GraphQLLocalExecutionClient : IGraphQLClient where TSchema : ISchema { - private static readonly JsonSerializerSettings _variablesSerializerSettings = new JsonSerializerSettings { Formatting = Formatting.Indented, @@ -38,8 +36,8 @@ public class GraphQLLocalExecutionClient : IGraphQLClient where TSchema }; public TSchema Schema { get; } - public IGraphQLJsonSerializer Serializer { get; } + public IGraphQLJsonSerializer Serializer { get; } private readonly DocumentExecuter _documentExecuter; diff --git a/src/GraphQL.Client.Serializer.Newtonsoft/GraphQL.Client.Serializer.Newtonsoft.csproj b/src/GraphQL.Client.Serializer.Newtonsoft/GraphQL.Client.Serializer.Newtonsoft.csproj index c492b1ed..a298a460 100644 --- a/src/GraphQL.Client.Serializer.Newtonsoft/GraphQL.Client.Serializer.Newtonsoft.csproj +++ b/src/GraphQL.Client.Serializer.Newtonsoft/GraphQL.Client.Serializer.Newtonsoft.csproj @@ -1,10 +1,10 @@ + A serializer implementation for GraphQL.Client using Newtonsoft.Json as underlying JSON library netstandard2.0 - 8.0 diff --git a/src/GraphQL.Client.Serializer.Newtonsoft/MapConverter.cs b/src/GraphQL.Client.Serializer.Newtonsoft/MapConverter.cs index f15787e8..64bc8671 100644 --- a/src/GraphQL.Client.Serializer.Newtonsoft/MapConverter.cs +++ b/src/GraphQL.Client.Serializer.Newtonsoft/MapConverter.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Runtime.InteropServices; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -12,13 +11,12 @@ public override void WriteJson(JsonWriter writer, Map value, JsonSerializer seri throw new NotImplementedException( "This converter currently is only intended to be used to read a JSON object into a strongly-typed representation."); - public override Map ReadJson(JsonReader reader, Type objectType, Map existingValue, - bool hasExistingValue, JsonSerializer serializer) + public override Map ReadJson(JsonReader reader, Type objectType, Map existingValue, bool hasExistingValue, JsonSerializer serializer) { var rootToken = JToken.ReadFrom(reader); if (rootToken is JObject) { - return ReadDictionary(rootToken); + return (Map)ReadDictionary(rootToken, new Map()); } else throw new ArgumentException("This converter can only parse when the root element is a JSON Object."); @@ -27,7 +25,7 @@ public override Map ReadJson(JsonReader reader, Type objectType, Map existingVal private object ReadToken(JToken? token) => token switch { - JObject jObject => ReadDictionary>(jObject), + JObject jObject => ReadDictionary(jObject, new Dictionary()), JArray jArray => ReadArray(jArray), JValue jValue => jValue.Value, JConstructor _ => throw new ArgumentOutOfRangeException(nameof(token.Type), @@ -39,16 +37,15 @@ private object ReadToken(JToken? token) => _ => throw new ArgumentOutOfRangeException(nameof(token.Type)) }; - private TDictionary ReadDictionary(JToken element) where TDictionary : Dictionary + private Dictionary ReadDictionary(JToken element, Dictionary to) { - var result = Activator.CreateInstance(); foreach (var property in ((JObject)element).Properties()) { if (IsUnsupportedJTokenType(property.Value.Type)) continue; - result[property.Name] = ReadToken(property.Value); + to[property.Name] = ReadToken(property.Value); } - return result; + return to; } private IEnumerable ReadArray(JToken element) diff --git a/src/GraphQL.Client.Serializer.Newtonsoft/NewtonsoftJsonSerializer.cs b/src/GraphQL.Client.Serializer.Newtonsoft/NewtonsoftJsonSerializer.cs index 99936421..5ec06c1a 100644 --- a/src/GraphQL.Client.Serializer.Newtonsoft/NewtonsoftJsonSerializer.cs +++ b/src/GraphQL.Client.Serializer.Newtonsoft/NewtonsoftJsonSerializer.cs @@ -49,7 +49,6 @@ public GraphQLWebSocketResponse> DeserializeToWebsock public Task> DeserializeFromUtf8StreamAsync(Stream stream, CancellationToken cancellationToken) => DeserializeFromUtf8Stream>(stream); - private Task DeserializeFromUtf8Stream(Stream stream) { using var sr = new StreamReader(stream); @@ -57,6 +56,5 @@ private Task DeserializeFromUtf8Stream(Stream stream) var serializer = JsonSerializer.Create(JsonSerializerSettings); return Task.FromResult(serializer.Deserialize(reader)); } - } } diff --git a/src/GraphQL.Client.Serializer.SystemTextJson/GraphQL.Client.Serializer.SystemTextJson.csproj b/src/GraphQL.Client.Serializer.SystemTextJson/GraphQL.Client.Serializer.SystemTextJson.csproj index e8be48d7..009daeea 100644 --- a/src/GraphQL.Client.Serializer.SystemTextJson/GraphQL.Client.Serializer.SystemTextJson.csproj +++ b/src/GraphQL.Client.Serializer.SystemTextJson/GraphQL.Client.Serializer.SystemTextJson.csproj @@ -1,10 +1,10 @@ + A serializer implementation for GraphQL.Client using System.Text.Json as underlying JSON library netstandard2.0;netcoreapp3.1 - 8.0 diff --git a/src/GraphQL.Client.Serializer.SystemTextJson/ImmutableConverter.cs b/src/GraphQL.Client.Serializer.SystemTextJson/ImmutableConverter.cs index 78b5811b..4a26f6f2 100644 --- a/src/GraphQL.Client.Serializer.SystemTextJson/ImmutableConverter.cs +++ b/src/GraphQL.Client.Serializer.SystemTextJson/ImmutableConverter.cs @@ -8,7 +8,6 @@ namespace GraphQL.Client.Serializer.SystemTextJson { - /// /// class for converting immutable objects, derived from https://github.com/manne/obviously/blob/master/src/system.text.json/Core/ImmutableConverter.cs /// diff --git a/src/GraphQL.Client.Serializer.SystemTextJson/JsonSerializerOptionsExtensions.cs b/src/GraphQL.Client.Serializer.SystemTextJson/JsonSerializerOptionsExtensions.cs index e2d914c0..bc2ddc14 100644 --- a/src/GraphQL.Client.Serializer.SystemTextJson/JsonSerializerOptionsExtensions.cs +++ b/src/GraphQL.Client.Serializer.SystemTextJson/JsonSerializerOptionsExtensions.cs @@ -4,8 +4,7 @@ namespace GraphQL.Client.Serializer.SystemTextJson { public static class JsonSerializerOptionsExtensions { - public static JsonSerializerOptions SetupImmutableConverter( - this JsonSerializerOptions options) + public static JsonSerializerOptions SetupImmutableConverter(this JsonSerializerOptions options) { options.Converters.Add(new ImmutableConverter()); return options; diff --git a/src/GraphQL.Client/GraphQL.Client.csproj b/src/GraphQL.Client/GraphQL.Client.csproj index 0e0119ba..5946a683 100644 --- a/src/GraphQL.Client/GraphQL.Client.csproj +++ b/src/GraphQL.Client/GraphQL.Client.csproj @@ -2,10 +2,10 @@ - + netstandard2.0;net461 - GraphQL.Client.Http - + GraphQL.Client.Http + NETSTANDARD @@ -23,7 +23,6 @@ - @@ -37,7 +36,4 @@ - - - diff --git a/src/GraphQL.Client/GraphQLHttpClient.cs b/src/GraphQL.Client/GraphQLHttpClient.cs index 72b4b907..4388e8e1 100644 --- a/src/GraphQL.Client/GraphQLHttpClient.cs +++ b/src/GraphQL.Client/GraphQLHttpClient.cs @@ -11,10 +11,8 @@ namespace GraphQL.Client.Http { - public class GraphQLHttpClient : IGraphQLClient { - private readonly GraphQLHttpWebSocket _graphQlHttpWebSocket; private readonly CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource(); private readonly ConcurrentDictionary, object> _subscriptionStreams = new ConcurrentDictionary, object>(); @@ -42,8 +40,7 @@ public class GraphQLHttpClient : IGraphQLClient /// /// the websocket connection state /// - public IObservable WebsocketConnectionState => - _graphQlHttpWebSocket.ConnectionState; + public IObservable WebsocketConnectionState => _graphQlHttpWebSocket.ConnectionState; #region Constructors @@ -160,7 +157,6 @@ private Uri GetWebSocketUri() #endregion - #region IDisposable /// @@ -172,26 +168,27 @@ public void Dispose() { if (!_disposed) { - _dispose(); + _disposed = true; + Dispose(true); } } } - private bool _disposed = false; + private volatile bool _disposed; private readonly object _disposeLocker = new object(); - private void _dispose() + protected virtual void Dispose(bool disposing) { - _disposed = true; - Debug.WriteLine($"disposing GraphQLHttpClient on endpoint {Options.EndPoint}"); - _cancellationTokenSource.Cancel(); - HttpClient.Dispose(); - _graphQlHttpWebSocket.Dispose(); - _cancellationTokenSource.Dispose(); + if (disposing) + { + Debug.WriteLine($"Disposing GraphQLHttpClient on endpoint {Options.EndPoint}"); + _cancellationTokenSource.Cancel(); + HttpClient.Dispose(); + _graphQlHttpWebSocket.Dispose(); + _cancellationTokenSource.Dispose(); + } } #endregion - } - } diff --git a/src/GraphQL.Client/GraphQLHttpClientExtensions.cs b/src/GraphQL.Client/GraphQLHttpClientExtensions.cs index 99886c0c..31f29785 100644 --- a/src/GraphQL.Client/GraphQLHttpClientExtensions.cs +++ b/src/GraphQL.Client/GraphQLHttpClientExtensions.cs @@ -15,7 +15,7 @@ public static class GraphQLHttpClientExtensions /// /// the GraphQL client /// the GraphQL request for this subscription - /// an external handler for all s occuring within the sequence + /// an external handler for all s occurring within the sequence /// an observable stream for the specified subscription public static IObservable> CreateSubscriptionStream(this IGraphQLClient client, GraphQLRequest request, Action webSocketExceptionHandler) => diff --git a/src/GraphQL.Client/GraphQLHttpClientOptions.cs b/src/GraphQL.Client/GraphQLHttpClientOptions.cs index 6b93cb7b..aeb99db6 100644 --- a/src/GraphQL.Client/GraphQLHttpClientOptions.cs +++ b/src/GraphQL.Client/GraphQLHttpClientOptions.cs @@ -5,13 +5,11 @@ namespace GraphQL.Client.Http { - /// /// The Options that the will use /// public class GraphQLHttpClientOptions { - /// /// The GraphQL EndPoint to be used /// diff --git a/src/GraphQL.Client/GraphQLHttpException.cs b/src/GraphQL.Client/GraphQLHttpException.cs index d30bd759..3b256bf3 100644 --- a/src/GraphQL.Client/GraphQLHttpException.cs +++ b/src/GraphQL.Client/GraphQLHttpException.cs @@ -3,13 +3,11 @@ namespace GraphQL.Client.Http { - /// /// An exception thrown on unexpected /// public class GraphQLHttpException : Exception { - /// /// The /// @@ -23,7 +21,5 @@ public GraphQLHttpException(HttpResponseMessage httpResponseMessage) : base($"Un { HttpResponseMessage = httpResponseMessage ?? throw new ArgumentNullException(nameof(httpResponseMessage)); } - } - } diff --git a/src/GraphQL.Client/GraphQLHttpRequest.cs b/src/GraphQL.Client/GraphQLHttpRequest.cs index f801f9c7..1069ac4c 100644 --- a/src/GraphQL.Client/GraphQLHttpRequest.cs +++ b/src/GraphQL.Client/GraphQLHttpRequest.cs @@ -4,7 +4,6 @@ namespace GraphQL.Client.Http { - public class GraphQLHttpRequest : GraphQLRequest { public GraphQLHttpRequest() diff --git a/src/GraphQL.Client/GraphQLHttpResponse.cs b/src/GraphQL.Client/GraphQLHttpResponse.cs index 73a4cea8..b4b09784 100644 --- a/src/GraphQL.Client/GraphQLHttpResponse.cs +++ b/src/GraphQL.Client/GraphQLHttpResponse.cs @@ -4,7 +4,6 @@ namespace GraphQL.Client.Http { - public class GraphQLHttpResponse : GraphQLResponse { public GraphQLHttpResponse(GraphQLResponse response, HttpResponseHeaders responseHeaders, HttpStatusCode statusCode) @@ -17,6 +16,7 @@ public GraphQLHttpResponse(GraphQLResponse response, HttpResponseHeaders resp } public HttpResponseHeaders ResponseHeaders { get; set; } + public HttpStatusCode StatusCode { get; set; } } @@ -25,7 +25,7 @@ public static class GraphQLResponseExtensions public static GraphQLHttpResponse ToGraphQLHttpResponse(this GraphQLResponse response, HttpResponseHeaders responseHeaders, HttpStatusCode statusCode) => new GraphQLHttpResponse(response, responseHeaders, statusCode); /// - /// Casts to . Throws ig the cast fails. + /// Casts to . Throws if the cast fails. /// /// /// diff --git a/src/GraphQL.Client/Websocket/GraphQLHttpWebSocket.cs b/src/GraphQL.Client/Websocket/GraphQLHttpWebSocket.cs index f0156030..21222865 100644 --- a/src/GraphQL.Client/Websocket/GraphQLHttpWebSocket.cs +++ b/src/GraphQL.Client/Websocket/GraphQLHttpWebSocket.cs @@ -48,7 +48,6 @@ internal class GraphQLHttpWebSocket : IDisposable #endregion - #region Public properties /// @@ -73,7 +72,6 @@ internal class GraphQLHttpWebSocket : IDisposable #endregion - public GraphQLHttpWebSocket(Uri webSocketUri, GraphQLHttpClient client) { _internalCancellationToken = _internalCancellationTokenSource.Token; @@ -89,7 +87,6 @@ public GraphQLHttpWebSocket(Uri webSocketUri, GraphQLHttpClient client) .Subscribe(async request => await SendWebSocketRequestAsync(request)); } - #region Send requests /// @@ -490,7 +487,7 @@ private IObservable GetMessageStream() => Observable.Using(() => new EventLoopScheduler(), scheduler => Observable.Create(async observer => { - // make sure the websocket ist connected + // make sure the websocket is connected await InitializeWebSocket(); // subscribe observer to message stream var subscription = new CompositeDisposable(_incomingMessages.ObserveOn(scheduler).Subscribe(observer)) @@ -591,6 +588,7 @@ private async Task CloseAsync() } #region IDisposable + public void Dispose() => Complete(); /// @@ -636,6 +634,7 @@ private async Task CompleteAsync() Debug.WriteLine($"websocket {_clientWebSocket.GetHashCode()} disposed"); } + #endregion } } diff --git a/src/GraphQL.Primitives/GraphQL.Primitives.csproj b/src/GraphQL.Primitives/GraphQL.Primitives.csproj index 53f58f4b..2b97da30 100644 --- a/src/GraphQL.Primitives/GraphQL.Primitives.csproj +++ b/src/GraphQL.Primitives/GraphQL.Primitives.csproj @@ -7,4 +7,5 @@ GraphQL netstandard2.0 + diff --git a/src/GraphQL.Primitives/GraphQLError.cs b/src/GraphQL.Primitives/GraphQLError.cs index 0bfe834c..9b7cfc99 100644 --- a/src/GraphQL.Primitives/GraphQLError.cs +++ b/src/GraphQL.Primitives/GraphQLError.cs @@ -5,13 +5,11 @@ namespace GraphQL { - /// /// Represents a GraphQL Error of a GraphQL Query /// public class GraphQLError : IEquatable { - /// /// The locations of the error /// @@ -41,8 +39,7 @@ public class GraphQLError : IEquatable /// /// The object to compare with this instance /// true if obj is an instance of and equals the value of the instance; otherwise, false - public override bool Equals(object? obj) => - Equals(obj as GraphQLError); + public override bool Equals(object? obj) => Equals(obj as GraphQLError); /// /// Returns a value that indicates whether this instance is equal to a specified object @@ -117,7 +114,5 @@ public override int GetHashCode() /// true if left and right are unequal; otherwise, false public static bool operator !=(GraphQLError? left, GraphQLError? right) => !EqualityComparer.Default.Equals(left, right); - } - } diff --git a/src/GraphQL.Primitives/GraphQLLocation.cs b/src/GraphQL.Primitives/GraphQLLocation.cs index c1fe6cee..9464817a 100644 --- a/src/GraphQL.Primitives/GraphQLLocation.cs +++ b/src/GraphQL.Primitives/GraphQLLocation.cs @@ -3,13 +3,11 @@ namespace GraphQL { - /// /// Represents a GraphQL Location of a GraphQL Query /// public sealed class GraphQLLocation : IEquatable { - /// /// The Column /// @@ -65,7 +63,5 @@ public override int GetHashCode() => /// true if left and right are unequal; otherwise, false public static bool operator !=(GraphQLLocation? left, GraphQLLocation? right) => !EqualityComparer.Default.Equals(left, right); - } - } diff --git a/src/GraphQL.Primitives/GraphQLRequest.cs b/src/GraphQL.Primitives/GraphQLRequest.cs index a36dae38..72033552 100644 --- a/src/GraphQL.Primitives/GraphQLRequest.cs +++ b/src/GraphQL.Primitives/GraphQLRequest.cs @@ -4,7 +4,6 @@ namespace GraphQL { - /// /// A GraphQL request /// @@ -110,6 +109,4 @@ public override int GetHashCode() /// true if left and right are unequal; otherwise, false public static bool operator !=(GraphQLRequest? left, GraphQLRequest? right) => !(left == right); } - - } diff --git a/src/GraphQL.Primitives/GraphQLResponse.cs b/src/GraphQL.Primitives/GraphQLResponse.cs index 0b2781fd..ff8eaac9 100644 --- a/src/GraphQL.Primitives/GraphQLResponse.cs +++ b/src/GraphQL.Primitives/GraphQLResponse.cs @@ -5,10 +5,8 @@ namespace GraphQL { - public class GraphQLResponse : IEquatable?> { - [DataMember(Name = "data")] public T Data { get; set; } @@ -86,13 +84,8 @@ public override int GetHashCode() } } - public static bool operator ==(GraphQLResponse? response1, GraphQLResponse? response2) => EqualityComparer?>.Default.Equals(response1, response2); public static bool operator !=(GraphQLResponse? response1, GraphQLResponse? response2) => !(response1 == response2); - } - - - } diff --git a/src/GraphQL.Primitives/Map.cs b/src/GraphQL.Primitives/Map.cs index cba91bee..9c4f503b 100644 --- a/src/GraphQL.Primitives/Map.cs +++ b/src/GraphQL.Primitives/Map.cs @@ -2,7 +2,6 @@ namespace GraphQL { - /// /// A type equivalent to a javascript map. Create a custom json converter for this class to customize your serializers behaviour /// diff --git a/src/src.props b/src/src.props index e2e2512b..f09d3e47 100644 --- a/src/src.props +++ b/src/src.props @@ -1,4 +1,3 @@ - diff --git a/tests/GraphQL.Client.Serializer.Tests/BaseSerializeNoCamelCaseTest.cs b/tests/GraphQL.Client.Serializer.Tests/BaseSerializeNoCamelCaseTest.cs index 5547e136..7ef81660 100644 --- a/tests/GraphQL.Client.Serializer.Tests/BaseSerializeNoCamelCaseTest.cs +++ b/tests/GraphQL.Client.Serializer.Tests/BaseSerializeNoCamelCaseTest.cs @@ -13,9 +13,10 @@ namespace GraphQL.Client.Serializer.Tests { public abstract class BaseSerializeNoCamelCaseTest { - public IGraphQLWebsocketJsonSerializer Serializer { get; } + public IGraphQLClient ChatClient { get; } + public IGraphQLClient StarWarsClient { get; } protected BaseSerializeNoCamelCaseTest(IGraphQLWebsocketJsonSerializer serializer) @@ -41,7 +42,6 @@ public void SerializeToBytesTest(string expectedJson, GraphQLWebSocketRequest re json.Should().Be(expectedJson.RemoveWhitespace()); } - [Fact] public async void WorksWithoutCamelCaseNamingStrategy() { diff --git a/tests/GraphQL.Client.Serializer.Tests/BaseSerializerTest.cs b/tests/GraphQL.Client.Serializer.Tests/BaseSerializerTest.cs index 940b7392..5811823c 100644 --- a/tests/GraphQL.Client.Serializer.Tests/BaseSerializerTest.cs +++ b/tests/GraphQL.Client.Serializer.Tests/BaseSerializerTest.cs @@ -18,7 +18,9 @@ namespace GraphQL.Client.Serializer.Tests public abstract class BaseSerializerTest { public IGraphQLWebsocketJsonSerializer Serializer { get; } + public IGraphQLClient ChatClient { get; } + public IGraphQLClient StarWarsClient { get; } protected BaseSerializerTest(IGraphQLWebsocketJsonSerializer serializer) @@ -83,7 +85,6 @@ public async void CanDeserializeExtensions() response.Errors[0].Extensions["data"].Should().BeEquivalentTo(ChatQuery.TestExtensions); } - [Theory] [ClassData(typeof(StarWarsHumans))] public async void CanDoSerializationWithAnonymousTypes(int id, string name) diff --git a/tests/GraphQL.Client.Tests.Common/Chat/AddMessageMutationResult.cs b/tests/GraphQL.Client.Tests.Common/Chat/AddMessageMutationResult.cs index 385e537b..70a51a72 100644 --- a/tests/GraphQL.Client.Tests.Common/Chat/AddMessageMutationResult.cs +++ b/tests/GraphQL.Client.Tests.Common/Chat/AddMessageMutationResult.cs @@ -3,6 +3,7 @@ namespace GraphQL.Client.Tests.Common.Chat public class AddMessageMutationResult { public AddMessageContent AddMessage { get; set; } + public class AddMessageContent { public string Content { get; set; } diff --git a/tests/GraphQL.Client.Tests.Common/Chat/AddMessageVariables.cs b/tests/GraphQL.Client.Tests.Common/Chat/AddMessageVariables.cs index 3a6ae10c..0a330007 100644 --- a/tests/GraphQL.Client.Tests.Common/Chat/AddMessageVariables.cs +++ b/tests/GraphQL.Client.Tests.Common/Chat/AddMessageVariables.cs @@ -4,12 +4,14 @@ namespace GraphQL.Client.Tests.Common.Chat { public class AddMessageVariables { - public AddMessageInput Input { get; set; } + public class AddMessageInput { public string FromId { get; set; } + public string Content { get; set; } + public DateTime SentAt { get; set; } } } diff --git a/tests/GraphQL.Client.Tests.Common/Chat/GraphQLClientChatExtensions.cs b/tests/GraphQL.Client.Tests.Common/Chat/GraphQLClientChatExtensions.cs index 261f5722..f4417860 100644 --- a/tests/GraphQL.Client.Tests.Common/Chat/GraphQLClientChatExtensions.cs +++ b/tests/GraphQL.Client.Tests.Common/Chat/GraphQLClientChatExtensions.cs @@ -44,6 +44,5 @@ public static Task> JoinDeveloperUs }); return client.SendMutationAsync(graphQLRequest); } - } } diff --git a/tests/GraphQL.Client.Tests.Common/Chat/JoinDeveloperMutationResult.cs b/tests/GraphQL.Client.Tests.Common/Chat/JoinDeveloperMutationResult.cs index c1b02444..c9910444 100644 --- a/tests/GraphQL.Client.Tests.Common/Chat/JoinDeveloperMutationResult.cs +++ b/tests/GraphQL.Client.Tests.Common/Chat/JoinDeveloperMutationResult.cs @@ -3,9 +3,11 @@ namespace GraphQL.Client.Tests.Common.Chat public class JoinDeveloperMutationResult { public JoinContent Join { get; set; } + public class JoinContent { public string DisplayName { get; set; } + public string Id { get; set; } } } diff --git a/tests/GraphQL.Client.Tests.Common/Chat/Schema/ChatQuery.cs b/tests/GraphQL.Client.Tests.Common/Chat/Schema/ChatQuery.cs index 0eb335ef..e60bf97e 100644 --- a/tests/GraphQL.Client.Tests.Common/Chat/Schema/ChatQuery.cs +++ b/tests/GraphQL.Client.Tests.Common/Chat/Schema/ChatQuery.cs @@ -7,7 +7,6 @@ namespace GraphQL.Client.Tests.Common.Chat.Schema { public class ChatQuery : ObjectGraphType { - public static readonly Dictionary TestExtensions = new Dictionary { {"extension1", "hello world"}, {"another extension", 4711}, @@ -19,7 +18,6 @@ public class ChatQuery : ObjectGraphType public readonly ManualResetEventSlim LongRunningQueryBlocker = new ManualResetEventSlim(); public readonly ManualResetEventSlim WaitingOnQueryBlocker = new ManualResetEventSlim(); - public ChatQuery(IChat chat) { Name = "ChatQuery"; diff --git a/tests/GraphQL.Client.Tests.Common/Common.cs b/tests/GraphQL.Client.Tests.Common/Common.cs index 3bfd2409..97dd30fe 100644 --- a/tests/GraphQL.Client.Tests.Common/Common.cs +++ b/tests/GraphQL.Client.Tests.Common/Common.cs @@ -17,6 +17,7 @@ public static StarWarsSchema GetStarWarsSchema() services.AddStarWarsSchema(); return services.BuildServiceProvider().GetRequiredService(); } + public static ChatSchema GetChatSchema() { var services = new ServiceCollection(); diff --git a/tests/GraphQL.Client.Tests.Common/Helpers/CallbackMonitor.cs b/tests/GraphQL.Client.Tests.Common/Helpers/CallbackMonitor.cs index a6a4e50f..df759d07 100644 --- a/tests/GraphQL.Client.Tests.Common/Helpers/CallbackMonitor.cs +++ b/tests/GraphQL.Client.Tests.Common/Helpers/CallbackMonitor.cs @@ -20,6 +20,7 @@ public class CallbackMonitor /// Indicates that an update has been received since the last /// public bool CallbackInvoked => _callbackInvoked.IsSet; + /// /// The last payload which was received. /// diff --git a/tests/GraphQL.Client.Tests.Common/Helpers/ConcurrentTaskWrapper.cs b/tests/GraphQL.Client.Tests.Common/Helpers/ConcurrentTaskWrapper.cs index 6af84092..c16e1744 100644 --- a/tests/GraphQL.Client.Tests.Common/Helpers/ConcurrentTaskWrapper.cs +++ b/tests/GraphQL.Client.Tests.Common/Helpers/ConcurrentTaskWrapper.cs @@ -3,7 +3,6 @@ namespace GraphQL.Client.Tests.Common.Helpers { - public class ConcurrentTaskWrapper { public static ConcurrentTaskWrapper New(Func> createTask) => new ConcurrentTaskWrapper(createTask); diff --git a/tests/GraphQL.Client.Tests.Common/Helpers/MiscellaneousExtensions.cs b/tests/GraphQL.Client.Tests.Common/Helpers/MiscellaneousExtensions.cs index b769399b..dcbb6db9 100644 --- a/tests/GraphQL.Client.Tests.Common/Helpers/MiscellaneousExtensions.cs +++ b/tests/GraphQL.Client.Tests.Common/Helpers/MiscellaneousExtensions.cs @@ -22,7 +22,5 @@ public static CallbackMonitor ConfigureMonitorForOnWebsocketC }; return tester; } - - } } diff --git a/tests/GraphQL.Client.Tests.Common/Helpers/ObservableTester.cs b/tests/GraphQL.Client.Tests.Common/Helpers/ObservableTester.cs index dad65ff1..82e7eac7 100644 --- a/tests/GraphQL.Client.Tests.Common/Helpers/ObservableTester.cs +++ b/tests/GraphQL.Client.Tests.Common/Helpers/ObservableTester.cs @@ -26,6 +26,7 @@ public class ObservableTester : IDisposable /// Indicates that an update has been received since the last /// public bool UpdateReceived => _updateReceived.IsSet; + /// /// The last payload which was received. /// @@ -171,5 +172,4 @@ public static class ObservableExtensions { public static ObservableTester Monitor(this IObservable observable) => new ObservableTester(observable); } - } diff --git a/tests/GraphQL.Integration.Tests/GraphQL.Integration.Tests.csproj b/tests/GraphQL.Integration.Tests/GraphQL.Integration.Tests.csproj index 777bd6ed..5b55b2e2 100644 --- a/tests/GraphQL.Integration.Tests/GraphQL.Integration.Tests.csproj +++ b/tests/GraphQL.Integration.Tests/GraphQL.Integration.Tests.csproj @@ -1,8 +1,7 @@ - + netcoreapp3.1 - false @@ -28,5 +27,4 @@ - diff --git a/tests/GraphQL.Integration.Tests/Helpers/IntegrationServerTestFixture.cs b/tests/GraphQL.Integration.Tests/Helpers/IntegrationServerTestFixture.cs index e70751b7..25773b47 100644 --- a/tests/GraphQL.Integration.Tests/Helpers/IntegrationServerTestFixture.cs +++ b/tests/GraphQL.Integration.Tests/Helpers/IntegrationServerTestFixture.cs @@ -13,7 +13,9 @@ namespace GraphQL.Integration.Tests.Helpers public abstract class IntegrationServerTestFixture { public int Port { get; private set; } + public IWebHost Server { get; private set; } + public abstract IGraphQLWebsocketJsonSerializer Serializer { get; } public IntegrationServerTestFixture() diff --git a/tests/GraphQL.Integration.Tests/Helpers/WebHostHelpers.cs b/tests/GraphQL.Integration.Tests/Helpers/WebHostHelpers.cs index 81ff2248..0bdb0e8c 100644 --- a/tests/GraphQL.Integration.Tests/Helpers/WebHostHelpers.cs +++ b/tests/GraphQL.Integration.Tests/Helpers/WebHostHelpers.cs @@ -55,7 +55,9 @@ public TestServerSetup(IGraphQLWebsocketJsonSerializer serializer) } public int Port { get; } + public IWebHost Server { get; set; } + public IGraphQLWebsocketJsonSerializer Serializer { get; set; } public GraphQLHttpClient GetStarWarsClient(bool requestsViaWebsocket = false) diff --git a/tests/GraphQL.Integration.Tests/QueryAndMutationTests/Base.cs b/tests/GraphQL.Integration.Tests/QueryAndMutationTests/Base.cs index 550eb6a0..4e9cd45a 100644 --- a/tests/GraphQL.Integration.Tests/QueryAndMutationTests/Base.cs +++ b/tests/GraphQL.Integration.Tests/QueryAndMutationTests/Base.cs @@ -15,10 +15,8 @@ namespace GraphQL.Integration.Tests.QueryAndMutationTests { - public abstract class Base : IAsyncLifetime { - protected IntegrationServerTestFixture Fixture; protected GraphQLHttpClient StarWarsClient; protected GraphQLHttpClient ChatClient; @@ -222,6 +220,5 @@ query Long { // let the server finish its query chatQuery.LongRunningQueryBlocker.Set(); } - } } diff --git a/tests/GraphQL.Integration.Tests/WebsocketTests/Base.cs b/tests/GraphQL.Integration.Tests/WebsocketTests/Base.cs index 1a0a273e..2bb72794 100644 --- a/tests/GraphQL.Integration.Tests/WebsocketTests/Base.cs +++ b/tests/GraphQL.Integration.Tests/WebsocketTests/Base.cs @@ -162,7 +162,6 @@ public class MessageAddedContent } } - [Fact] public async void CanReconnectWithSameObservable() { @@ -223,6 +222,7 @@ public class UserJoinedSubscriptionResult public class UserJoinedContent { public string DisplayName { get; set; } + public string Id { get; set; } } @@ -230,7 +230,6 @@ public class UserJoinedContent private readonly GraphQLRequest _subscriptionRequest2 = new GraphQLRequest(SUBSCRIPTION_QUERY2); - [Fact] public async void CanConnectTwoSubscriptionsSimultaneously() { @@ -352,7 +351,6 @@ public async void CanHandleConnectionTimeout() } } - [Fact] public async void CanHandleSubscriptionError() { @@ -377,10 +375,8 @@ public async void CanHandleSubscriptionError() tester.Should().HaveCompleted(); ChatClient.Dispose(); } - } - [Fact] public async void CanHandleQueryErrorInSubscription() { @@ -408,6 +404,5 @@ public async void CanHandleQueryErrorInSubscription() ChatClient.Dispose(); } } - } } diff --git a/tests/GraphQL.Integration.Tests/WebsocketTests/Newtonsoft.cs b/tests/GraphQL.Integration.Tests/WebsocketTests/Newtonsoft.cs index aa6cb945..d77ca14c 100644 --- a/tests/GraphQL.Integration.Tests/WebsocketTests/Newtonsoft.cs +++ b/tests/GraphQL.Integration.Tests/WebsocketTests/Newtonsoft.cs @@ -7,6 +7,7 @@ namespace GraphQL.Integration.Tests.WebsocketTests public class Newtonsoft : Base, IClassFixture { public Newtonsoft(ITestOutputHelper output, NewtonsoftIntegrationServerTestFixture fixture) : base(output, fixture) - { } + { + } } } diff --git a/tests/GraphQL.Primitives.Tests/GraphQLLocationTest.cs b/tests/GraphQL.Primitives.Tests/GraphQLLocationTest.cs index ce34bcc8..3d7fde8d 100644 --- a/tests/GraphQL.Primitives.Tests/GraphQLLocationTest.cs +++ b/tests/GraphQL.Primitives.Tests/GraphQLLocationTest.cs @@ -2,10 +2,8 @@ namespace GraphQL.Primitives.Tests { - public class GraphQLLocationTest { - [Fact] public void ConstructorFact() { @@ -60,7 +58,5 @@ public void GetHashCodeFact() var graphQLLocation2 = new GraphQLLocation { Column = 1, Line = 2 }; Assert.True(graphQLLocation1.GetHashCode() == graphQLLocation2.GetHashCode()); } - } - } diff --git a/tests/GraphQL.Primitives.Tests/GraphQLRequestTest.cs b/tests/GraphQL.Primitives.Tests/GraphQLRequestTest.cs index 8fbda085..e5b41a15 100644 --- a/tests/GraphQL.Primitives.Tests/GraphQLRequestTest.cs +++ b/tests/GraphQL.Primitives.Tests/GraphQLRequestTest.cs @@ -2,10 +2,8 @@ namespace GraphQL.Primitives.Tests { - public class GraphQLRequestTest { - [Fact] public void ConstructorFact() { @@ -47,7 +45,6 @@ public void Equality3Fact() Assert.Equal(graphQLRequest1, graphQLRequest2); } - [Fact] public void Equality4Fact() { @@ -75,8 +72,8 @@ public void InEquality1Fact() [Fact] public void InEquality2Fact() { - GraphQLRequest graphQLRequest1 = new GraphQLRequest("{hero{name}}", new { varName = "varValue1" }, "operationName"); - GraphQLRequest graphQLRequest2 = new GraphQLRequest("{hero{name}}", new { varName = "varValue2" }, "operationName"); + var graphQLRequest1 = new GraphQLRequest("{hero{name}}", new { varName = "varValue1" }, "operationName"); + var graphQLRequest2 = new GraphQLRequest("{hero{name}}", new { varName = "varValue2" }, "operationName"); Assert.NotEqual(graphQLRequest1, graphQLRequest2); } @@ -122,8 +119,10 @@ public void PropertyQueryGetFact() [Fact] public void PropertyQuerySetFact() { - var graphQLRequest = new GraphQLRequest("{hero{name}}", new { varName = "varValue1" }, "operationName"); - graphQLRequest.Query = "{hero{name2}}"; + var graphQLRequest = new GraphQLRequest("{hero{name}}", new { varName = "varValue1" }, "operationName") + { + Query = "{hero{name2}}" + }; Assert.Equal("{hero{name2}}", graphQLRequest.Query); } @@ -144,8 +143,10 @@ public void PropertyOperationNameNullGetFact() [Fact] public void PropertyOperationNameSetFact() { - var graphQLRequest = new GraphQLRequest("{hero{name}}", new { varName = "varValue" }, "operationName1"); - graphQLRequest.OperationName = "operationName2"; + var graphQLRequest = new GraphQLRequest("{hero{name}}", new { varName = "varValue" }, "operationName1") + { + OperationName = "operationName2" + }; Assert.Equal("operationName2", graphQLRequest.OperationName); } @@ -166,17 +167,17 @@ public void PropertyVariableNullGetFact() [Fact] public void PropertyVariableSetFact() { - var graphQLRequest = new GraphQLRequest("{hero{name}}", new { varName = "varValue1" }, "operationName1"); - graphQLRequest.Variables = new + var graphQLRequest = new GraphQLRequest("{hero{name}}", new { varName = "varValue1" }, "operationName1") { - varName = "varValue2" + Variables = new + { + varName = "varValue2" + } }; Assert.Equal(new { varName = "varValue2" }, graphQLRequest.Variables); } - } - } diff --git a/tests/GraphQL.Primitives.Tests/GraphQLResponseTest.cs b/tests/GraphQL.Primitives.Tests/GraphQLResponseTest.cs index ed23f3fd..ce062e05 100644 --- a/tests/GraphQL.Primitives.Tests/GraphQLResponseTest.cs +++ b/tests/GraphQL.Primitives.Tests/GraphQLResponseTest.cs @@ -2,10 +2,8 @@ namespace GraphQL.Primitives.Tests { - public class GraphQLResponseTest { - [Fact] public void Constructor1Fact() { @@ -112,7 +110,5 @@ public void GetHashCodeFact() }; Assert.True(graphQLResponse1.GetHashCode() == graphQLResponse2.GetHashCode()); } - } - } diff --git a/tests/GraphQL.Primitives.Tests/JsonSerializationTests.cs b/tests/GraphQL.Primitives.Tests/JsonSerializationTests.cs index da1ccf02..094670a0 100644 --- a/tests/GraphQL.Primitives.Tests/JsonSerializationTests.cs +++ b/tests/GraphQL.Primitives.Tests/JsonSerializationTests.cs @@ -7,7 +7,6 @@ namespace GraphQL.Primitives.Tests { public class JsonSerializationTests { - [Fact] public void WebSocketResponseDeserialization() { @@ -22,7 +21,6 @@ public void WebSocketResponseDeserialization() public class TestObject { public string Id { get; set; } - } public class ExtendedTestObject : TestObject diff --git a/tests/GraphQL.Server.Test/GraphQL/Models/Repository.cs b/tests/GraphQL.Server.Test/GraphQL/Models/Repository.cs index e387d32b..95e5f1fc 100644 --- a/tests/GraphQL.Server.Test/GraphQL/Models/Repository.cs +++ b/tests/GraphQL.Server.Test/GraphQL/Models/Repository.cs @@ -3,19 +3,21 @@ namespace GraphQL.Server.Test.GraphQL.Models { - public class Repository { public int DatabaseId { get; set; } + public string Id { get; set; } + public string Name { get; set; } + public object Owner { get; set; } + public Uri Url { get; set; } } public class RepositoryGraphType : ObjectGraphType { - public RepositoryGraphType() { Name = nameof(Repository); @@ -25,7 +27,5 @@ public RepositoryGraphType() //this.Field(expression => expression.Owner); Field>("url"); } - } - } diff --git a/tests/GraphQL.Server.Test/GraphQL/Storage.cs b/tests/GraphQL.Server.Test/GraphQL/Storage.cs index 613a537a..0280b28f 100644 --- a/tests/GraphQL.Server.Test/GraphQL/Storage.cs +++ b/tests/GraphQL.Server.Test/GraphQL/Storage.cs @@ -5,10 +5,8 @@ namespace GraphQL.Server.Test.GraphQL { - public static class Storage { - public static IQueryable Repositories { get; } = new List() .Append(new Repository { @@ -19,7 +17,5 @@ public static class Storage Url = new Uri("https://github.com/graphql-dotnet/graphql-client") }) .AsQueryable(); - } - } diff --git a/tests/GraphQL.Server.Test/GraphQL/TestMutation.cs b/tests/GraphQL.Server.Test/GraphQL/TestMutation.cs index a1077dc6..dfd67981 100644 --- a/tests/GraphQL.Server.Test/GraphQL/TestMutation.cs +++ b/tests/GraphQL.Server.Test/GraphQL/TestMutation.cs @@ -2,14 +2,10 @@ namespace GraphQL.Server.Test.GraphQL { - public class TestMutation : ObjectGraphType { - public TestMutation() { } - } - } diff --git a/tests/GraphQL.Server.Test/GraphQL/TestQuery.cs b/tests/GraphQL.Server.Test/GraphQL/TestQuery.cs index 2fb39ab3..bf8aa3ae 100644 --- a/tests/GraphQL.Server.Test/GraphQL/TestQuery.cs +++ b/tests/GraphQL.Server.Test/GraphQL/TestQuery.cs @@ -4,10 +4,8 @@ namespace GraphQL.Server.Test.GraphQL { - public class TestQuery : ObjectGraphType { - public TestQuery() { Field("repository", arguments: new QueryArguments(new QueryArgument> { Name = "owner" }, new QueryArgument> { Name = "name" }), resolve: context => @@ -17,7 +15,5 @@ public TestQuery() return Storage.Repositories.FirstOrDefault(predicate => predicate.Name == name); }); } - } - } diff --git a/tests/GraphQL.Server.Test/GraphQL/TestSchema.cs b/tests/GraphQL.Server.Test/GraphQL/TestSchema.cs index a61d3558..c589d388 100644 --- a/tests/GraphQL.Server.Test/GraphQL/TestSchema.cs +++ b/tests/GraphQL.Server.Test/GraphQL/TestSchema.cs @@ -2,17 +2,13 @@ namespace GraphQL.Server.Test.GraphQL { - public class TestSchema : Schema { - public TestSchema() { Query = new TestQuery(); //this.Mutation = new TestMutation(); //this.Subscription = new TestSubscription(); } - } - } diff --git a/tests/GraphQL.Server.Test/GraphQL/TestSubscription.cs b/tests/GraphQL.Server.Test/GraphQL/TestSubscription.cs index f6d50470..4fabf386 100644 --- a/tests/GraphQL.Server.Test/GraphQL/TestSubscription.cs +++ b/tests/GraphQL.Server.Test/GraphQL/TestSubscription.cs @@ -2,14 +2,10 @@ namespace GraphQL.Server.Test.GraphQL { - public class TestSubscription : ObjectGraphType { - public TestSubscription() { } - } - } diff --git a/tests/GraphQL.Server.Test/Program.cs b/tests/GraphQL.Server.Test/Program.cs index 2b5c329a..df18d888 100644 --- a/tests/GraphQL.Server.Test/Program.cs +++ b/tests/GraphQL.Server.Test/Program.cs @@ -4,18 +4,14 @@ namespace GraphQL.Server.Test { - public class Program { - public static async Task Main(string[] args) => await CreateHostBuilder(args).Build().RunAsync(); public static IWebHostBuilder CreateHostBuilder(string[] args = null) => WebHost.CreateDefaultBuilder(args) - .UseKestrel(options => { options.AllowSynchronousIO = true; }) + .UseKestrel(options => options.AllowSynchronousIO = true) .UseStartup(); - } - } diff --git a/tests/GraphQL.Server.Test/Startup.cs b/tests/GraphQL.Server.Test/Startup.cs index d330ed5d..a1f710ee 100644 --- a/tests/GraphQL.Server.Test/Startup.cs +++ b/tests/GraphQL.Server.Test/Startup.cs @@ -2,23 +2,13 @@ using GraphQL.Server.Ui.GraphiQL; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; namespace GraphQL.Server.Test { - public class Startup { - - public IConfiguration Configuration { get; } - - public Startup(IConfiguration configuration) - { - Configuration = configuration; - } - public void Configure(IApplicationBuilder app) { var webHostEnvironment = app.ApplicationServices.GetRequiredService(); @@ -43,7 +33,5 @@ public void ConfigureServices(IServiceCollection services) options.ExposeExceptions = true; }).AddWebSockets(); } - } - } diff --git a/tests/IntegrationTestServer/Startup.cs b/tests/IntegrationTestServer/Startup.cs index 71a76d67..49586dc0 100644 --- a/tests/IntegrationTestServer/Startup.cs +++ b/tests/IntegrationTestServer/Startup.cs @@ -24,16 +24,14 @@ public Startup(IConfiguration configuration, IWebHostEnvironment environment) } public IConfiguration Configuration { get; } + public IWebHostEnvironment Environment { get; } // This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { - services.Configure(options => - { - options.AllowSynchronousIO = true; - }); + services.Configure(options => options.AllowSynchronousIO = true); services.AddTransient(provider => new FuncDependencyResolver(provider.GetService)); services.AddChatSchema(); diff --git a/tests/tests.props b/tests/tests.props index 46e995fc..2b4c9451 100644 --- a/tests/tests.props +++ b/tests/tests.props @@ -1,4 +1,3 @@ - From 3bbeec2821e71d422d41f9667c5ad3c115443be9 Mon Sep 17 00:00:00 2001 From: Ivan Maximov Date: Sat, 4 Apr 2020 13:31:17 +0300 Subject: [PATCH 2/9] consolidate test projects spaces instead of tabs --- .../GraphQL.Client.Example.csproj | 16 ++--- root.props | 66 +++++++++---------- ...aphQL.Client.Abstractions.Websocket.csproj | 12 ++-- .../GraphQL.Client.Abstractions.csproj | 22 +++---- .../GraphQL.Client.LocalExecution.csproj | 26 ++++---- ...raphQL.Client.Serializer.Newtonsoft.csproj | 2 +- ...QL.Client.Serializer.SystemTextJson.csproj | 14 ++-- src/GraphQL.Client/GraphQL.Client.csproj | 50 +++++++------- .../GraphQL.Primitives.csproj | 12 ++-- src/src.props | 56 ++++++++-------- .../GraphQL.Client.Serializer.Tests.csproj | 11 +--- .../GraphQL.Client.Tests.Common.csproj | 4 +- .../Helpers/CallbackMonitor.cs | 4 +- .../Helpers/ObservableTester.cs | 10 +-- .../GraphQL.Integration.Tests.csproj | 11 +--- .../WebsocketTests/Base.cs | 2 - .../GraphQL.Primitives.Tests.csproj | 8 --- .../JsonSerializationTests.cs | 1 + .../GraphQL.Server.Test.csproj | 20 +++--- .../IntegrationTestServer.csproj | 3 + tests/tests.props | 20 +++--- 21 files changed, 177 insertions(+), 193 deletions(-) diff --git a/examples/GraphQL.Client.Example/GraphQL.Client.Example.csproj b/examples/GraphQL.Client.Example/GraphQL.Client.Example.csproj index d6a75865..ff9af100 100644 --- a/examples/GraphQL.Client.Example/GraphQL.Client.Example.csproj +++ b/examples/GraphQL.Client.Example/GraphQL.Client.Example.csproj @@ -1,13 +1,13 @@ - - Exe - netcoreapp3.1 - + + Exe + netcoreapp3.1 + - - - - + + + + diff --git a/root.props b/root.props index b076b4d3..17bd287e 100644 --- a/root.props +++ b/root.props @@ -1,38 +1,38 @@ - - Deinok,Alexander Rose,graphql-dotnet - A GraphQL Client for .NET Standard - True - True - 8.0 - en-US - CS0618;CS1591;CS1701;CS8618;CS8632;NU5048;NU5105;NU5125 - annotations - icon.png - LICENSE.txt - https://github.com/graphql-dotnet/graphql-client - true - GraphQL - git - https://github.com/graphql-dotnet/graphql-client - True - 4 - + + Deinok,Alexander Rose,graphql-dotnet + A GraphQL Client for .NET Standard + True + True + 8.0 + en-US + $(NoWarn);CS1591;NU5048;NU5105;NU5125 + annotations + icon.png + LICENSE.txt + https://github.com/graphql-dotnet/graphql-client + true + GraphQL + git + https://github.com/graphql-dotnet/graphql-client + True + 4 + - - - PreserveNewest - true - LICENSE.txt - false - - - PreserveNewest - true - icon.png - false - - + + + PreserveNewest + true + LICENSE.txt + false + + + PreserveNewest + true + icon.png + false + + diff --git a/src/GraphQL.Client.Abstractions.Websocket/GraphQL.Client.Abstractions.Websocket.csproj b/src/GraphQL.Client.Abstractions.Websocket/GraphQL.Client.Abstractions.Websocket.csproj index 9abfd542..d1980775 100644 --- a/src/GraphQL.Client.Abstractions.Websocket/GraphQL.Client.Abstractions.Websocket.csproj +++ b/src/GraphQL.Client.Abstractions.Websocket/GraphQL.Client.Abstractions.Websocket.csproj @@ -1,14 +1,14 @@ - + - + Abstractions for the Websocket transport used in GraphQL.Client netstandard2.0 - + - - - + + + diff --git a/src/GraphQL.Client.Abstractions/GraphQL.Client.Abstractions.csproj b/src/GraphQL.Client.Abstractions/GraphQL.Client.Abstractions.csproj index 666c63c0..d7678b66 100644 --- a/src/GraphQL.Client.Abstractions/GraphQL.Client.Abstractions.csproj +++ b/src/GraphQL.Client.Abstractions/GraphQL.Client.Abstractions.csproj @@ -1,18 +1,18 @@ - + - - Abstractions for GraphQL.Client - netstandard2.0 - + + Abstractions for GraphQL.Client + netstandard2.0 + - - - + + + - - - + + + diff --git a/src/GraphQL.Client.LocalExecution/GraphQL.Client.LocalExecution.csproj b/src/GraphQL.Client.LocalExecution/GraphQL.Client.LocalExecution.csproj index 927c3470..ebef7ea0 100644 --- a/src/GraphQL.Client.LocalExecution/GraphQL.Client.LocalExecution.csproj +++ b/src/GraphQL.Client.LocalExecution/GraphQL.Client.LocalExecution.csproj @@ -1,20 +1,20 @@ - + - - A GraphQL Client which executes the queries directly on a provided GraphQL schema using graphql-dotnet - netstandard2.0 - + + A GraphQL Client which executes the queries directly on a provided GraphQL schema using graphql-dotnet + netstandard2.0 + - - - - - + + + + + - - - + + + diff --git a/src/GraphQL.Client.Serializer.Newtonsoft/GraphQL.Client.Serializer.Newtonsoft.csproj b/src/GraphQL.Client.Serializer.Newtonsoft/GraphQL.Client.Serializer.Newtonsoft.csproj index a298a460..4bbcb784 100644 --- a/src/GraphQL.Client.Serializer.Newtonsoft/GraphQL.Client.Serializer.Newtonsoft.csproj +++ b/src/GraphQL.Client.Serializer.Newtonsoft/GraphQL.Client.Serializer.Newtonsoft.csproj @@ -1,6 +1,6 @@ - + A serializer implementation for GraphQL.Client using Newtonsoft.Json as underlying JSON library diff --git a/src/GraphQL.Client.Serializer.SystemTextJson/GraphQL.Client.Serializer.SystemTextJson.csproj b/src/GraphQL.Client.Serializer.SystemTextJson/GraphQL.Client.Serializer.SystemTextJson.csproj index 009daeea..9433b8dd 100644 --- a/src/GraphQL.Client.Serializer.SystemTextJson/GraphQL.Client.Serializer.SystemTextJson.csproj +++ b/src/GraphQL.Client.Serializer.SystemTextJson/GraphQL.Client.Serializer.SystemTextJson.csproj @@ -1,18 +1,18 @@ - + A serializer implementation for GraphQL.Client using System.Text.Json as underlying JSON library netstandard2.0;netcoreapp3.1 - - - + + + - - - + + + diff --git a/src/GraphQL.Client/GraphQL.Client.csproj b/src/GraphQL.Client/GraphQL.Client.csproj index 5946a683..ac1fa526 100644 --- a/src/GraphQL.Client/GraphQL.Client.csproj +++ b/src/GraphQL.Client/GraphQL.Client.csproj @@ -1,39 +1,39 @@ - + - netstandard2.0;net461 - GraphQL.Client.Http + netstandard2.0;net461 + GraphQL.Client.Http - - NETSTANDARD - + + NETSTANDARD + - - NETFRAMEWORK - + + NETFRAMEWORK + - - - + + + - - - + + + - - - + + + - - - + + + - - - - + + + + diff --git a/src/GraphQL.Primitives/GraphQL.Primitives.csproj b/src/GraphQL.Primitives/GraphQL.Primitives.csproj index 2b97da30..1c324df3 100644 --- a/src/GraphQL.Primitives/GraphQL.Primitives.csproj +++ b/src/GraphQL.Primitives/GraphQL.Primitives.csproj @@ -1,11 +1,11 @@ - + - - GraphQL basic types - GraphQL - netstandard2.0 - + + GraphQL basic types + GraphQL + netstandard2.0 + diff --git a/src/src.props b/src/src.props index f09d3e47..2f7ebb50 100644 --- a/src/src.props +++ b/src/src.props @@ -1,36 +1,36 @@ - + - - true - 8.0 - + + true + 8.0 + - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + - - false - false - false - false + + false + false + false + false - $(GitVersion_FullSemVer) - $(GitVersion_MajorMinorPatch) - $(GitVersion_NuGetPreReleaseTag) - $(GitVersion_PreReleaseTag) - $(GitVersion_NuGetVersion) - $(GitVersion_FullSemVer) - $(GitVersion_InformationalVersion) - $(GitVersion_AssemblySemVer) - $(GitVersion_AssemblySemFileVer) - $(GitVersion_BranchName) - $(GitVersion_Sha) - + $(GitVersion_FullSemVer) + $(GitVersion_MajorMinorPatch) + $(GitVersion_NuGetPreReleaseTag) + $(GitVersion_PreReleaseTag) + $(GitVersion_NuGetVersion) + $(GitVersion_FullSemVer) + $(GitVersion_InformationalVersion) + $(GitVersion_AssemblySemVer) + $(GitVersion_AssemblySemFileVer) + $(GitVersion_BranchName) + $(GitVersion_Sha) + diff --git a/tests/GraphQL.Client.Serializer.Tests/GraphQL.Client.Serializer.Tests.csproj b/tests/GraphQL.Client.Serializer.Tests/GraphQL.Client.Serializer.Tests.csproj index b61c1466..3a5af98e 100644 --- a/tests/GraphQL.Client.Serializer.Tests/GraphQL.Client.Serializer.Tests.csproj +++ b/tests/GraphQL.Client.Serializer.Tests/GraphQL.Client.Serializer.Tests.csproj @@ -1,18 +1,11 @@ + + netcoreapp3.1 - false - - - - - - - - diff --git a/tests/GraphQL.Client.Tests.Common/GraphQL.Client.Tests.Common.csproj b/tests/GraphQL.Client.Tests.Common/GraphQL.Client.Tests.Common.csproj index dfbb9146..ad646c73 100644 --- a/tests/GraphQL.Client.Tests.Common/GraphQL.Client.Tests.Common.csproj +++ b/tests/GraphQL.Client.Tests.Common/GraphQL.Client.Tests.Common.csproj @@ -1,12 +1,12 @@ + + netstandard2.0 - false - diff --git a/tests/GraphQL.Client.Tests.Common/Helpers/CallbackMonitor.cs b/tests/GraphQL.Client.Tests.Common/Helpers/CallbackMonitor.cs index df759d07..6aa7284a 100644 --- a/tests/GraphQL.Client.Tests.Common/Helpers/CallbackMonitor.cs +++ b/tests/GraphQL.Client.Tests.Common/Helpers/CallbackMonitor.cs @@ -12,7 +12,7 @@ public class CallbackMonitor private readonly ManualResetEventSlim _callbackInvoked = new ManualResetEventSlim(); /// - /// The timeout for . Defaults to 1 s + /// The timeout for . Defaults to 1 second. /// public TimeSpan Timeout { get; set; } = TimeSpan.FromSeconds(1); @@ -38,7 +38,7 @@ public void Invoke(T param) /// public void Reset() { - LastPayload = default(T); + LastPayload = default; _callbackInvoked.Reset(); } diff --git a/tests/GraphQL.Client.Tests.Common/Helpers/ObservableTester.cs b/tests/GraphQL.Client.Tests.Common/Helpers/ObservableTester.cs index 82e7eac7..1a8d5220 100644 --- a/tests/GraphQL.Client.Tests.Common/Helpers/ObservableTester.cs +++ b/tests/GraphQL.Client.Tests.Common/Helpers/ObservableTester.cs @@ -18,12 +18,12 @@ public class ObservableTester : IDisposable private readonly EventLoopScheduler _observeScheduler = new EventLoopScheduler(); /// - /// The timeout for . Defaults to 1 s + /// The timeout for SubscriptionAssertions.***Have*** methods. Defaults to 3 seconds. /// public TimeSpan Timeout { get; set; } = TimeSpan.FromSeconds(3); /// - /// Indicates that an update has been received since the last + /// Indicates that an update has been received since the last /// public bool UpdateReceived => _updateReceived.IsSet; @@ -102,7 +102,7 @@ public AndWhichConstraint, TPayload> HaveReceiv .ForCondition(isSet => isSet) .FailWith("Expected {context:Subscription} to receive new payload{reason}, but did not receive an update within {0}", timeout); - Subject._updateReceived.Reset(); + Subject.Reset(); return new AndWhichConstraint, TPayload>(this, Subject.LastPayload); } public AndWhichConstraint, TPayload> HaveReceivedPayload(string because = "", params object[] becauseArgs) @@ -117,7 +117,7 @@ public AndConstraint> NotHaveReceivedPayload(Ti .ForCondition(isSet => !isSet) .FailWith("Expected {context:Subscription} to not receive a new payload{reason}, but did receive an update: {0}", Subject.LastPayload); - Subject._updateReceived.Reset(); + Subject.Reset(); return new AndConstraint>(this); } public AndConstraint> NotHaveReceivedPayload(string because = "", params object[] becauseArgs) @@ -134,10 +134,10 @@ public AndWhichConstraint, Exception> HaveRecei return new AndWhichConstraint, Exception>(this, Subject.Error); } + public AndWhichConstraint, Exception> HaveReceivedError(string because = "", params object[] becauseArgs) => HaveReceivedError(Subject.Timeout, because, becauseArgs); - public AndConstraint> HaveCompleted(TimeSpan timeout, string because = "", params object[] becauseArgs) { diff --git a/tests/GraphQL.Integration.Tests/GraphQL.Integration.Tests.csproj b/tests/GraphQL.Integration.Tests/GraphQL.Integration.Tests.csproj index 5b55b2e2..3cc7fd29 100644 --- a/tests/GraphQL.Integration.Tests/GraphQL.Integration.Tests.csproj +++ b/tests/GraphQL.Integration.Tests/GraphQL.Integration.Tests.csproj @@ -1,23 +1,16 @@ + + netcoreapp3.1 - false - - - - - - all - runtime; build; native; contentfiles; analyzers - diff --git a/tests/GraphQL.Integration.Tests/WebsocketTests/Base.cs b/tests/GraphQL.Integration.Tests/WebsocketTests/Base.cs index 2bb72794..786d0923 100644 --- a/tests/GraphQL.Integration.Tests/WebsocketTests/Base.cs +++ b/tests/GraphQL.Integration.Tests/WebsocketTests/Base.cs @@ -380,8 +380,6 @@ public async void CanHandleSubscriptionError() [Fact] public async void CanHandleQueryErrorInSubscription() { - var test = new GraphQLRequest("tset", new { test = "blaa" }); - var callbackMonitor = ChatClient.ConfigureMonitorForOnWebsocketConnected(); await ChatClient.InitializeWebsocketConnection(); callbackMonitor.Should().HaveBeenInvokedWithPayload(); diff --git a/tests/GraphQL.Primitives.Tests/GraphQL.Primitives.Tests.csproj b/tests/GraphQL.Primitives.Tests/GraphQL.Primitives.Tests.csproj index c7be7594..99070b4c 100644 --- a/tests/GraphQL.Primitives.Tests/GraphQL.Primitives.Tests.csproj +++ b/tests/GraphQL.Primitives.Tests/GraphQL.Primitives.Tests.csproj @@ -6,16 +6,8 @@ netcoreapp3.1 - - - - - - - - diff --git a/tests/GraphQL.Primitives.Tests/JsonSerializationTests.cs b/tests/GraphQL.Primitives.Tests/JsonSerializationTests.cs index 094670a0..74add0a1 100644 --- a/tests/GraphQL.Primitives.Tests/JsonSerializationTests.cs +++ b/tests/GraphQL.Primitives.Tests/JsonSerializationTests.cs @@ -13,6 +13,7 @@ public void WebSocketResponseDeserialization() var testObject = new ExtendedTestObject { Id = "test", OtherData = "this is some other stuff" }; var json = JsonSerializer.Serialize(testObject); var deserialized = JsonSerializer.Deserialize(json); + deserialized.Id.Should().Be("test"); var dict = JsonSerializer.Deserialize>(json); var childObject = (JsonElement)dict["ChildObject"]; childObject.GetProperty("Id").GetString().Should().Be(testObject.ChildObject.Id); diff --git a/tests/GraphQL.Server.Test/GraphQL.Server.Test.csproj b/tests/GraphQL.Server.Test/GraphQL.Server.Test.csproj index 8ae5718c..bdb8aaba 100644 --- a/tests/GraphQL.Server.Test/GraphQL.Server.Test.csproj +++ b/tests/GraphQL.Server.Test/GraphQL.Server.Test.csproj @@ -1,13 +1,15 @@ - + - - netcoreapp3.1 - + - - - - - + + netcoreapp3.1 + + + + + + + diff --git a/tests/IntegrationTestServer/IntegrationTestServer.csproj b/tests/IntegrationTestServer/IntegrationTestServer.csproj index a1f28376..2cc80a82 100644 --- a/tests/IntegrationTestServer/IntegrationTestServer.csproj +++ b/tests/IntegrationTestServer/IntegrationTestServer.csproj @@ -1,7 +1,10 @@ + + netcoreapp3.1 + IntegrationTestServer.Program diff --git a/tests/tests.props b/tests/tests.props index 2b4c9451..af4d8c78 100644 --- a/tests/tests.props +++ b/tests/tests.props @@ -1,16 +1,18 @@ - + - + false - true - + $(NoWarn);NU1701;IDE1006 + - - - - - + + + + + + + From e26ab0425230afd2ce2dc9d3b844fe20fea8cbee Mon Sep 17 00:00:00 2001 From: Ivan Maximov Date: Sat, 4 Apr 2020 13:48:57 +0300 Subject: [PATCH 3/9] fix props --- examples/GraphQL.Client.Example/GraphQL.Client.Example.csproj | 1 + .../GraphQL.Client.Tests.Common.csproj | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/GraphQL.Client.Example/GraphQL.Client.Example.csproj b/examples/GraphQL.Client.Example/GraphQL.Client.Example.csproj index ff9af100..8880a7a6 100644 --- a/examples/GraphQL.Client.Example/GraphQL.Client.Example.csproj +++ b/examples/GraphQL.Client.Example/GraphQL.Client.Example.csproj @@ -3,6 +3,7 @@ Exe netcoreapp3.1 + false diff --git a/tests/GraphQL.Client.Tests.Common/GraphQL.Client.Tests.Common.csproj b/tests/GraphQL.Client.Tests.Common/GraphQL.Client.Tests.Common.csproj index ad646c73..1f013292 100644 --- a/tests/GraphQL.Client.Tests.Common/GraphQL.Client.Tests.Common.csproj +++ b/tests/GraphQL.Client.Tests.Common/GraphQL.Client.Tests.Common.csproj @@ -1,9 +1,8 @@ - - netstandard2.0 + false @@ -13,6 +12,7 @@ + From 1ae75762caf835aeaa40ebabdddb9766f3d18ada Mon Sep 17 00:00:00 2001 From: Ivan Maximov Date: Sat, 4 Apr 2020 13:55:46 +0300 Subject: [PATCH 4/9] fix again --- .../GraphQL.Client.Tests.Common.csproj | 2 +- tests/GraphQL.Server.Test/GraphQL.Server.Test.csproj | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/GraphQL.Client.Tests.Common/GraphQL.Client.Tests.Common.csproj b/tests/GraphQL.Client.Tests.Common/GraphQL.Client.Tests.Common.csproj index 1f013292..84b470fe 100644 --- a/tests/GraphQL.Client.Tests.Common/GraphQL.Client.Tests.Common.csproj +++ b/tests/GraphQL.Client.Tests.Common/GraphQL.Client.Tests.Common.csproj @@ -6,13 +6,13 @@ + - diff --git a/tests/GraphQL.Server.Test/GraphQL.Server.Test.csproj b/tests/GraphQL.Server.Test/GraphQL.Server.Test.csproj index bdb8aaba..eeb2302e 100644 --- a/tests/GraphQL.Server.Test/GraphQL.Server.Test.csproj +++ b/tests/GraphQL.Server.Test/GraphQL.Server.Test.csproj @@ -1,9 +1,8 @@ - - netcoreapp3.1 + false From 2c1dd95c37ac9d3c2e539f1ae13f21b881b316e8 Mon Sep 17 00:00:00 2001 From: Ivan Maximov Date: Sat, 4 Apr 2020 17:04:51 +0300 Subject: [PATCH 5/9] fix props --- .../GraphQL.Client.Tests.Common.csproj | 1 - tests/GraphQL.Server.Test/GraphQL.Server.Test.csproj | 1 - tests/IntegrationTestServer/IntegrationTestServer.csproj | 2 -- tests/tests.props | 7 +++++-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/GraphQL.Client.Tests.Common/GraphQL.Client.Tests.Common.csproj b/tests/GraphQL.Client.Tests.Common/GraphQL.Client.Tests.Common.csproj index 84b470fe..3be17715 100644 --- a/tests/GraphQL.Client.Tests.Common/GraphQL.Client.Tests.Common.csproj +++ b/tests/GraphQL.Client.Tests.Common/GraphQL.Client.Tests.Common.csproj @@ -2,7 +2,6 @@ netstandard2.0 - false diff --git a/tests/GraphQL.Server.Test/GraphQL.Server.Test.csproj b/tests/GraphQL.Server.Test/GraphQL.Server.Test.csproj index eeb2302e..ad08e233 100644 --- a/tests/GraphQL.Server.Test/GraphQL.Server.Test.csproj +++ b/tests/GraphQL.Server.Test/GraphQL.Server.Test.csproj @@ -2,7 +2,6 @@ netcoreapp3.1 - false diff --git a/tests/IntegrationTestServer/IntegrationTestServer.csproj b/tests/IntegrationTestServer/IntegrationTestServer.csproj index 2cc80a82..da280f0f 100644 --- a/tests/IntegrationTestServer/IntegrationTestServer.csproj +++ b/tests/IntegrationTestServer/IntegrationTestServer.csproj @@ -1,7 +1,5 @@ - - netcoreapp3.1 IntegrationTestServer.Program diff --git a/tests/tests.props b/tests/tests.props index af4d8c78..19bc6d36 100644 --- a/tests/tests.props +++ b/tests/tests.props @@ -8,10 +8,13 @@ - + - + + all + runtime;build;native;contentfiles;analyzers;buildtransitive + From a4c74b1fe4dedc80a7e177c72db358c615479215 Mon Sep 17 00:00:00 2001 From: Ivan Maximov Date: Sat, 4 Apr 2020 17:18:02 +0300 Subject: [PATCH 6/9] timeout --- tests/GraphQL.Client.Tests.Common/Helpers/ObservableTester.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/GraphQL.Client.Tests.Common/Helpers/ObservableTester.cs b/tests/GraphQL.Client.Tests.Common/Helpers/ObservableTester.cs index 1a8d5220..2374e7f4 100644 --- a/tests/GraphQL.Client.Tests.Common/Helpers/ObservableTester.cs +++ b/tests/GraphQL.Client.Tests.Common/Helpers/ObservableTester.cs @@ -18,9 +18,9 @@ public class ObservableTester : IDisposable private readonly EventLoopScheduler _observeScheduler = new EventLoopScheduler(); /// - /// The timeout for SubscriptionAssertions.***Have*** methods. Defaults to 3 seconds. + /// The timeout for SubscriptionAssertions.***Have*** methods. Defaults to 30 seconds. /// - public TimeSpan Timeout { get; set; } = TimeSpan.FromSeconds(3); + public TimeSpan Timeout { get; set; } = TimeSpan.FromSeconds(30); /// /// Indicates that an update has been received since the last From 51eb8013b81b18020147703afcea2fbd20e3693b Mon Sep 17 00:00:00 2001 From: Ivan Maximov Date: Sat, 4 Apr 2020 17:31:08 +0300 Subject: [PATCH 7/9] revert --- .../Helpers/ObservableTester.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/GraphQL.Client.Tests.Common/Helpers/ObservableTester.cs b/tests/GraphQL.Client.Tests.Common/Helpers/ObservableTester.cs index 2374e7f4..0c361d83 100644 --- a/tests/GraphQL.Client.Tests.Common/Helpers/ObservableTester.cs +++ b/tests/GraphQL.Client.Tests.Common/Helpers/ObservableTester.cs @@ -18,12 +18,12 @@ public class ObservableTester : IDisposable private readonly EventLoopScheduler _observeScheduler = new EventLoopScheduler(); /// - /// The timeout for SubscriptionAssertions.***Have*** methods. Defaults to 30 seconds. + /// The timeout for SubscriptionAssertions.***Have*** methods. Defaults to 3 seconds. /// - public TimeSpan Timeout { get; set; } = TimeSpan.FromSeconds(30); + public TimeSpan Timeout { get; set; } = TimeSpan.FromSeconds(3); /// - /// Indicates that an update has been received since the last + /// Indicates that an update has been received since the last reset of /// public bool UpdateReceived => _updateReceived.IsSet; @@ -102,9 +102,10 @@ public AndWhichConstraint, TPayload> HaveReceiv .ForCondition(isSet => isSet) .FailWith("Expected {context:Subscription} to receive new payload{reason}, but did not receive an update within {0}", timeout); - Subject.Reset(); + Subject._updateReceived.Reset(); return new AndWhichConstraint, TPayload>(this, Subject.LastPayload); } + public AndWhichConstraint, TPayload> HaveReceivedPayload(string because = "", params object[] becauseArgs) => HaveReceivedPayload(Subject.Timeout, because, becauseArgs); @@ -117,7 +118,7 @@ public AndConstraint> NotHaveReceivedPayload(Ti .ForCondition(isSet => !isSet) .FailWith("Expected {context:Subscription} to not receive a new payload{reason}, but did receive an update: {0}", Subject.LastPayload); - Subject.Reset(); + Subject._updateReceived.Reset(); return new AndConstraint>(this); } public AndConstraint> NotHaveReceivedPayload(string because = "", params object[] becauseArgs) From cbe68e18a6d21ac6a018f7f57424f235d4b15fe5 Mon Sep 17 00:00:00 2001 From: Ivan Maximov Date: Tue, 21 Apr 2020 01:10:33 +0300 Subject: [PATCH 8/9] fix build --- src/GraphQL.Client/GraphQLHttpRequest.cs | 2 ++ tests/GraphQL.Integration.Tests/QueryAndMutationTests/Base.cs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/GraphQL.Client/GraphQLHttpRequest.cs b/src/GraphQL.Client/GraphQLHttpRequest.cs index abf5d0d3..00f90d4a 100644 --- a/src/GraphQL.Client/GraphQLHttpRequest.cs +++ b/src/GraphQL.Client/GraphQLHttpRequest.cs @@ -41,7 +41,9 @@ public virtual HttpRequestMessage ToHttpRequestMessage(GraphQLHttpClientOptions Content = new StringContent(serializer.SerializeToString(this), Encoding.UTF8, options.MediaType) }; +#pragma warning disable CS0618 // Type or member is obsolete PreprocessHttpRequestMessage(message); +#pragma warning restore CS0618 // Type or member is obsolete return message; } } diff --git a/tests/GraphQL.Integration.Tests/QueryAndMutationTests/Base.cs b/tests/GraphQL.Integration.Tests/QueryAndMutationTests/Base.cs index 4e9cd45a..5855e626 100644 --- a/tests/GraphQL.Integration.Tests/QueryAndMutationTests/Base.cs +++ b/tests/GraphQL.Integration.Tests/QueryAndMutationTests/Base.cs @@ -173,7 +173,9 @@ public async void PreprocessHttpRequestMessageIsCalled() var callbackTester = new CallbackMonitor(); var graphQLRequest = new GraphQLHttpRequest($"{{ human(id: \"1\") {{ name }} }}") { +#pragma warning disable CS0618 // Type or member is obsolete PreprocessHttpRequestMessage = callbackTester.Invoke +#pragma warning restore CS0618 // Type or member is obsolete }; var defaultHeaders = StarWarsClient.HttpClient.DefaultRequestHeaders; From cc131e23e18b6e93ca49b21d34cd3e2162e60f98 Mon Sep 17 00:00:00 2001 From: Ivan Maximov Date: Tue, 21 Apr 2020 01:28:04 +0300 Subject: [PATCH 9/9] revert itemgroup --- src/GraphQL.Client/GraphQL.Client.csproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/GraphQL.Client/GraphQL.Client.csproj b/src/GraphQL.Client/GraphQL.Client.csproj index f6f7c0fe..febf2911 100644 --- a/src/GraphQL.Client/GraphQL.Client.csproj +++ b/src/GraphQL.Client/GraphQL.Client.csproj @@ -15,6 +15,10 @@ NETFRAMEWORK + + + +