diff --git a/src/Tochka.JsonRpc.All/Tochka.JsonRpc.All.csproj b/src/Tochka.JsonRpc.All/Tochka.JsonRpc.All.csproj
index 70e868e9..7b1d9c1d 100644
--- a/src/Tochka.JsonRpc.All/Tochka.JsonRpc.All.csproj
+++ b/src/Tochka.JsonRpc.All/Tochka.JsonRpc.All.csproj
@@ -18,13 +18,13 @@
$(NoWarn);NU5128
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/src/Tochka.JsonRpc.Client/JsonRpcClientBase.cs b/src/Tochka.JsonRpc.Client/JsonRpcClientBase.cs
index c9490e21..3e8f9c35 100644
--- a/src/Tochka.JsonRpc.Client/JsonRpcClientBase.cs
+++ b/src/Tochka.JsonRpc.Client/JsonRpcClientBase.cs
@@ -286,22 +286,6 @@ internal virtual async Task> SendRequestInternal
}
}
- private async Task<(IJsonRpcCallContext, string)> PrepareInternalRequestContext(string? requestUrl, Request request,
- CancellationToken cancellationToken) where TParams : class
- {
- var context = CreateContext();
- context.WithRequestUrl(requestUrl);
- var data = request.WithSerializedParams(DataJsonSerializerOptions);
- context.WithSingle(data);
- using var content = CreateHttpContent(data);
- using var requestMessage = CreateRequestMessage(requestUrl, content, new[] { request.Method });
- var httpResponseMessage = await Client.SendAsync(requestMessage, cancellationToken);
- context.WithHttpResponse(httpResponseMessage);
- var contentString = await GetContent(httpResponseMessage.Content, cancellationToken);
- context.WithHttpContent(httpResponseMessage.Content, contentString);
- return (context, contentString);
- }
-
// internal virtual for mocking in tests
internal virtual async Task SendBatchInternal(string? requestUrl, IEnumerable calls, CancellationToken cancellationToken)
{
@@ -437,6 +421,22 @@ protected internal virtual HttpContent CreateHttpContent(object data)
protected internal virtual async Task GetContent(HttpContent content, CancellationToken cancellationToken) =>
await content.ReadAsStringAsync(cancellationToken);
+ private async Task<(IJsonRpcCallContext, string)> PrepareInternalRequestContext(string? requestUrl, Request request, CancellationToken cancellationToken)
+ where TParams : class
+ {
+ var context = CreateContext();
+ context.WithRequestUrl(requestUrl);
+ var data = request.WithSerializedParams(DataJsonSerializerOptions);
+ context.WithSingle(data);
+ using var content = CreateHttpContent(data);
+ using var requestMessage = CreateRequestMessage(requestUrl, content, new[] { request.Method });
+ var httpResponseMessage = await Client.SendAsync(requestMessage, cancellationToken);
+ context.WithHttpResponse(httpResponseMessage);
+ var contentString = await GetContent(httpResponseMessage.Content, cancellationToken);
+ context.WithHttpContent(httpResponseMessage.Content, contentString);
+ return (context, contentString);
+ }
+
///
/// Set User-Agent header
///
diff --git a/src/Tochka.JsonRpc.Client/Models/BatchResult/BatchExtensions.cs b/src/Tochka.JsonRpc.Client/Models/BatchResult/BatchExtensions.cs
index 593ada8b..b6a72427 100644
--- a/src/Tochka.JsonRpc.Client/Models/BatchResult/BatchExtensions.cs
+++ b/src/Tochka.JsonRpc.Client/Models/BatchResult/BatchExtensions.cs
@@ -18,8 +18,6 @@ public static class BatchExtensions
/// true if the object contains an element that has the specified key; otherwise, false.
/// key is null
[ExcludeFromCodeCoverage]
- public static bool TryGetResponse(this IReadOnlyDictionary responses,
- IRpcId id,
- [NotNullWhen(true)] out IResponse? response) =>
+ public static bool TryGetResponse(this IReadOnlyDictionary responses, IRpcId id, [NotNullWhen(true)] out IResponse? response) =>
responses.TryGetValue(id, out response);
}
diff --git a/src/Tochka.JsonRpc.Client/Models/BatchResult/BatchJsonRpcResult.cs b/src/Tochka.JsonRpc.Client/Models/BatchResult/BatchJsonRpcResult.cs
index ff18ee4a..9f1c4625 100644
--- a/src/Tochka.JsonRpc.Client/Models/BatchResult/BatchJsonRpcResult.cs
+++ b/src/Tochka.JsonRpc.Client/Models/BatchResult/BatchJsonRpcResult.cs
@@ -28,6 +28,9 @@ public BatchJsonRpcResult(IJsonRpcCallContext context, JsonSerializerOptions hea
[PublicAPI]
public class BatchJsonRpcResult : IBatchJsonRpcResult
{
+ ///
+ public IBatchJsonRpcResultAdvanced Advanced { get; init; }
+
///
/// Context with all information about request and response
///
@@ -48,9 +51,6 @@ public class BatchJsonRpcResult : IBatchJsonRpcResult
///
protected readonly Dictionary Responses;
- ///
- public IBatchJsonRpcResultAdvanced Advanced { get; init; }
-
///
public BatchJsonRpcResult(IJsonRpcCallContext context, JsonSerializerOptions headersJsonSerializerOptions, JsonSerializerOptions dataJsonSerializerOptions)
{
diff --git a/src/Tochka.JsonRpc.Client/Models/BatchResult/IBatchJsonRpcResult.cs b/src/Tochka.JsonRpc.Client/Models/BatchResult/IBatchJsonRpcResult.cs
index 88daebed..8e462adb 100644
--- a/src/Tochka.JsonRpc.Client/Models/BatchResult/IBatchJsonRpcResult.cs
+++ b/src/Tochka.JsonRpc.Client/Models/BatchResult/IBatchJsonRpcResult.cs
@@ -9,6 +9,12 @@ namespace Tochka.JsonRpc.Client.Models.BatchResult;
[PublicAPI]
public interface IBatchJsonRpcResult
{
+ ///
+ /// Advanced data for complex work with batch Result of JSON-RPC request
+ ///
+ ///
+ IBatchJsonRpcResultAdvanced Advanced { get; init; }
+
///
/// Try to deserialize response result or throw if unable
///
@@ -31,12 +37,6 @@ public interface IBatchJsonRpcResult
/// Response id
/// if no response with given id or response has error
bool HasError(IRpcId id);
-
- ///
- /// Advanced data for complex work with batch Result of JSON-RPC request
- ///
- ///
- IBatchJsonRpcResultAdvanced Advanced { get; init; }
}
///
@@ -46,6 +46,12 @@ public interface IBatchJsonRpcResult
[PublicAPI]
public interface IBatchJsonRpcResult
{
+ ///
+ /// Advanced data for complex work with batch Result of JSON-RPC request
+ ///
+ ///
+ IBatchJsonRpcResultAdvanced Advanced { get; init; }
+
///
/// Try to deserialize response result to typed response or throw if unable
///
@@ -66,10 +72,4 @@ public interface IBatchJsonRpcResult
/// Response id
/// if no response with given id or response has error
bool HasError(IRpcId id);
-
- ///
- /// Advanced data for complex work with batch Result of JSON-RPC request
- ///
- ///
- IBatchJsonRpcResultAdvanced Advanced { get; init; }
}
diff --git a/src/Tochka.JsonRpc.Client/Models/SingleResult/ISingleJsonRpcResult.cs b/src/Tochka.JsonRpc.Client/Models/SingleResult/ISingleJsonRpcResult.cs
index 9c311da3..39c1f651 100644
--- a/src/Tochka.JsonRpc.Client/Models/SingleResult/ISingleJsonRpcResult.cs
+++ b/src/Tochka.JsonRpc.Client/Models/SingleResult/ISingleJsonRpcResult.cs
@@ -8,6 +8,12 @@ namespace Tochka.JsonRpc.Client.Models.SingleResult;
[PublicAPI]
public interface ISingleJsonRpcResult
{
+ ///
+ /// Advanced data for complex work with single Result of JSON-RPC request
+ ///
+ ///
+ ISingleJsonRpcResultAdvanced Advanced { get; init; }
+
///
/// Try to deserialize response result or throw if unable
///
@@ -26,15 +32,8 @@ public interface ISingleJsonRpcResult
/// Check if response has error
///
bool HasError();
-
- ///
- /// Advanced data for complex work with single Result of JSON-RPC request
- ///
- ///
- ISingleJsonRpcResultAdvanced Advanced { get; init; }
}
-
///
/// Result of single JSON-RPC request with typed response
/// Type of response
@@ -42,6 +41,12 @@ public interface ISingleJsonRpcResult
[PublicAPI]
public interface ISingleJsonRpcResult
{
+ ///
+ /// Advanced data for complex work with single Result of JSON-RPC request
+ ///
+ ///
+ ISingleJsonRpcResultAdvanced Advanced { get; init; }
+
///
/// Try to deserialize response result to typed response or throw if unable
///
@@ -58,10 +63,4 @@ public interface ISingleJsonRpcResult
/// Check if response has error
///
bool HasError();
-
- ///
- /// Advanced data for complex work with single Result of JSON-RPC request
- ///
- ///
- ISingleJsonRpcResultAdvanced Advanced { get; init; }
}
diff --git a/src/Tochka.JsonRpc.Client/Models/SingleResult/SingleJsonRpcResult.cs b/src/Tochka.JsonRpc.Client/Models/SingleResult/SingleJsonRpcResult.cs
index f6db41f2..faa805e9 100644
--- a/src/Tochka.JsonRpc.Client/Models/SingleResult/SingleJsonRpcResult.cs
+++ b/src/Tochka.JsonRpc.Client/Models/SingleResult/SingleJsonRpcResult.cs
@@ -22,11 +22,13 @@ public SingleJsonRpcResult(IJsonRpcCallContext context, JsonSerializerOptions he
public TResponse? AsResponse() => Advanced.AsResponse();
}
-
///
[PublicAPI]
public class SingleJsonRpcResult : ISingleJsonRpcResult
{
+ ///
+ public ISingleJsonRpcResultAdvanced Advanced { get; init; }
+
///
/// Context with all information about request and response
///
@@ -47,9 +49,6 @@ public class SingleJsonRpcResult : ISingleJsonRpcResult
///
protected readonly IResponse? Response;
- ///
- public ISingleJsonRpcResultAdvanced Advanced { get; init; }
-
///
public SingleJsonRpcResult(IJsonRpcCallContext context, JsonSerializerOptions headersJsonSerializerOptions, JsonSerializerOptions dataJsonSerializerOptions)
{
diff --git a/src/Tochka.JsonRpc.Common/Extensions.cs b/src/Tochka.JsonRpc.Common/Extensions.cs
index 26ab22e7..314f2e9e 100644
--- a/src/Tochka.JsonRpc.Common/Extensions.cs
+++ b/src/Tochka.JsonRpc.Common/Extensions.cs
@@ -14,7 +14,7 @@ public static class Extensions
///
/// Collection of objects
/// Type of item to get
- /// First item of type if found, null otherwise
+ /// First item of type if found, null otherwise
public static T? Get(this IEnumerable collection)
where T : class => collection.FirstOrDefault(static x => x is T) as T;
diff --git a/src/Tochka.JsonRpc.OpenRpc/Extensions.cs b/src/Tochka.JsonRpc.OpenRpc/Extensions.cs
index d3e40cb2..0c8a3177 100644
--- a/src/Tochka.JsonRpc.OpenRpc/Extensions.cs
+++ b/src/Tochka.JsonRpc.OpenRpc/Extensions.cs
@@ -113,6 +113,13 @@ public static IEndpointConventionBuilder MapOpenRpc(this IEndpointRouteBuilder e
return endpoints.MapGet(options.DocumentPath, requestDelegate);
}
+ public static JsonSchema BuildWithoutUri(this JsonSchemaBuilder builder)
+ {
+ var result = builder.Build();
+ result.BaseUri = null!;
+ return result;
+ }
+
private static void EnsureRequiredServicesRegistered(IServiceProvider services)
{
if (services.GetService() == null)
@@ -120,11 +127,4 @@ private static void EnsureRequiredServicesRegistered(IServiceProvider services)
throw new InvalidOperationException($"Unable to find the required services. Please add all the required services by calling '{nameof(IServiceCollection)}.{nameof(AddOpenRpc)}' in the application startup code.");
}
}
-
- public static JsonSchema BuildWithoutUri(this JsonSchemaBuilder builder)
- {
- var result = builder.Build();
- result.BaseUri = null!;
- return result;
- }
}
diff --git a/src/Tochka.JsonRpc.OpenRpc/Services/JsonSchemaBuilderExtensions.cs b/src/Tochka.JsonRpc.OpenRpc/Services/JsonSchemaBuilderExtensions.cs
index a487fc6f..78f674e5 100644
--- a/src/Tochka.JsonRpc.OpenRpc/Services/JsonSchemaBuilderExtensions.cs
+++ b/src/Tochka.JsonRpc.OpenRpc/Services/JsonSchemaBuilderExtensions.cs
@@ -13,4 +13,4 @@ public static JsonSchemaBuilder TryAppendTitle(this JsonSchemaBuilder builder, s
return builder;
}
-}
\ No newline at end of file
+}
diff --git a/src/Tochka.JsonRpc.OpenRpc/Services/OpenRpcSchemaGenerator.cs b/src/Tochka.JsonRpc.OpenRpc/Services/OpenRpcSchemaGenerator.cs
index c7fe947f..7206009f 100644
--- a/src/Tochka.JsonRpc.OpenRpc/Services/OpenRpcSchemaGenerator.cs
+++ b/src/Tochka.JsonRpc.OpenRpc/Services/OpenRpcSchemaGenerator.cs
@@ -43,38 +43,6 @@ private JsonSchema CreateOrRefInternal(Type type, string methodName, string? pro
return BuildSchema(clearType, clearTypeName, methodName, propertySummary, jsonSerializerOptions);
}
- private static Type TryUnwrapNullableType(Type type) => Nullable.GetUnderlyingType(type) ?? type;
-
- private static string GetClearTypeName(string methodName, Type clearType)
- {
- var clearTypeName = clearType.Name;
- if (!clearTypeName.StartsWith($"{methodName} ", StringComparison.Ordinal))
- {
- clearTypeName = $"{methodName} {clearTypeName}" + GetGenericTypeArgumentNames(clearType);
- }
-
- return clearTypeName;
- }
-
- private static string? GetGenericTypeArgumentNames(Type type)
- {
- if (type.GenericTypeArguments.Length > 0)
- {
- List typeArgumentNames = new(type.GenericTypeArguments.Length);
-
- foreach (var typeArgument in type.GenericTypeArguments)
- {
- var clearTypeArgument = TryUnwrapNullableType(typeArgument);
- var clearTypeArgumentName = clearTypeArgument.Name + GetGenericTypeArgumentNames(clearTypeArgument);
- typeArgumentNames.Add(clearTypeArgumentName);
- }
-
- return $"[{string.Join(',', typeArgumentNames)}]";
- }
-
- return null;
- }
-
private JsonSchema BuildSchema(Type type, string typeName, string methodName, string? propertySummary, JsonSerializerOptions jsonSerializerOptions)
{
if (registeredSchemas.ContainsKey(typeName) || registeredSchemaKeys.Contains(typeName))
@@ -86,10 +54,10 @@ private JsonSchema BuildSchema(Type type, string typeName, string methodName, st
if (typeof(IEnumerable).IsAssignableFrom(type) && itemType != null)
{
var collectionScheme = new JsonSchemaBuilder()
- .Type(SchemaValueType.Array)
- .Items(CreateOrRefInternal(itemType, methodName, null, jsonSerializerOptions))
- .TryAppendTitle(propertySummary)
- .BuildWithoutUri();
+ .Type(SchemaValueType.Array)
+ .Items(CreateOrRefInternal(itemType, methodName, null, jsonSerializerOptions))
+ .TryAppendTitle(propertySummary)
+ .BuildWithoutUri();
// returning schema itself if it's collection
return collectionScheme;
}
@@ -97,17 +65,17 @@ private JsonSchema BuildSchema(Type type, string typeName, string methodName, st
if (type.IsEnum)
{
var enumSchema = new JsonSchemaBuilder()
- .Enum(type.GetEnumNames().Select(jsonSerializerOptions.ConvertName))
- .BuildWithoutUri();
+ .Enum(type.GetEnumNames().Select(jsonSerializerOptions.ConvertName))
+ .BuildWithoutUri();
RegisterSchema(typeName, enumSchema);
// returning ref if it's enum or regular type with properties
return CreateRefSchema(typeName, propertySummary);
}
var simpleTypeSchema = new JsonSchemaBuilder()
- .FromType(type)
- .TryAppendTitle(propertySummary)
- .BuildWithoutUri();
+ .FromType(type)
+ .TryAppendTitle(propertySummary)
+ .BuildWithoutUri();
// can't check type.GetProperties() here because simple types have properties too
if (simpleTypeSchema.GetProperties() == null)
{
@@ -119,10 +87,10 @@ private JsonSchema BuildSchema(Type type, string typeName, string methodName, st
if (defaultStringConvertedSimpleTypes.TryGetValue(type, out var format))
{
var simpleStringSchema = new JsonSchemaBuilder()
- .Type(SchemaValueType.String)
- .Format(format)
- .TryAppendTitle(propertySummary)
- .BuildWithoutUri();
+ .Type(SchemaValueType.String)
+ .Format(format)
+ .TryAppendTitle(propertySummary)
+ .BuildWithoutUri();
return simpleStringSchema;
}
@@ -133,8 +101,8 @@ private JsonSchema BuildSchema(Type type, string typeName, string methodName, st
requiredPropsForSchemas.TryGetValue(typeName, out var requiredProperties);
var jsonSchemaBuilder = new JsonSchemaBuilder()
- .Type(SchemaValueType.Object)
- .Properties(propertiesSchemas);
+ .Type(SchemaValueType.Object)
+ .Properties(propertiesSchemas);
if (requiredProperties is not null)
{
jsonSchemaBuilder.Required(requiredProperties);
@@ -145,15 +113,6 @@ private JsonSchema BuildSchema(Type type, string typeName, string methodName, st
return CreateRefSchema(typeName, propertySummary);
}
- private static JsonSchema CreateRefSchema(string typeName, string? propertySummary)
- {
- var refSchemaBuilder = new JsonSchemaBuilder()
- .Ref($"#/components/schemas/{typeName}")
- .TryAppendTitle(propertySummary);
-
- return refSchemaBuilder.BuildWithoutUri();
- }
-
private void RegisterSchema(string key, JsonSchema schema)
{
registeredSchemaKeys.Add(key);
@@ -206,4 +165,45 @@ private void TryAddRequiredMember(string typeName, string propertyName, JsonSeri
requiredPropsForSchemas.TryAdd(typeName, requiredProperties);
}
-}
\ No newline at end of file
+
+ private static Type TryUnwrapNullableType(Type type) => Nullable.GetUnderlyingType(type) ?? type;
+
+ private static string GetClearTypeName(string methodName, Type clearType)
+ {
+ var clearTypeName = clearType.Name;
+ if (!clearTypeName.StartsWith($"{methodName} ", StringComparison.Ordinal))
+ {
+ clearTypeName = $"{methodName} {clearTypeName}" + GetGenericTypeArgumentNames(clearType);
+ }
+
+ return clearTypeName;
+ }
+
+ private static string? GetGenericTypeArgumentNames(Type type)
+ {
+ if (type.GenericTypeArguments.Length > 0)
+ {
+ List typeArgumentNames = new(type.GenericTypeArguments.Length);
+
+ foreach (var typeArgument in type.GenericTypeArguments)
+ {
+ var clearTypeArgument = TryUnwrapNullableType(typeArgument);
+ var clearTypeArgumentName = clearTypeArgument.Name + GetGenericTypeArgumentNames(clearTypeArgument);
+ typeArgumentNames.Add(clearTypeArgumentName);
+ }
+
+ return $"[{string.Join(',', typeArgumentNames)}]";
+ }
+
+ return null;
+ }
+
+ private static JsonSchema CreateRefSchema(string typeName, string? propertySummary)
+ {
+ var refSchemaBuilder = new JsonSchemaBuilder()
+ .Ref($"#/components/schemas/{typeName}")
+ .TryAppendTitle(propertySummary);
+
+ return refSchemaBuilder.BuildWithoutUri();
+ }
+}
diff --git a/src/Tochka.JsonRpc.Server/Services/JsonRpcRequestValidator.cs b/src/Tochka.JsonRpc.Server/Services/JsonRpcRequestValidator.cs
index 5f0578ea..2562a133 100644
--- a/src/Tochka.JsonRpc.Server/Services/JsonRpcRequestValidator.cs
+++ b/src/Tochka.JsonRpc.Server/Services/JsonRpcRequestValidator.cs
@@ -67,9 +67,9 @@ internal static string BuildRouteTemplate(string routePrefix)
.Replace("[area]", "{area}");
}
- // internal for tests
- internal static readonly Regex RouteWithWildcardSuffixRegex = RouteWithWildcardSuffix(); // "smth/{*smth}" or "smth/{*smth}/"
-
[GeneratedRegex(@"^.*?\{\*.*?}/?$")]
private static partial Regex RouteWithWildcardSuffix();
+
+ // internal for tests
+ internal static readonly Regex RouteWithWildcardSuffixRegex = RouteWithWildcardSuffix(); // "smth/{*smth}" or "smth/{*smth}/"
}
diff --git a/src/Tochka.JsonRpc.Swagger/Extensions.cs b/src/Tochka.JsonRpc.Swagger/Extensions.cs
index c7850887..b3b0279e 100644
--- a/src/Tochka.JsonRpc.Swagger/Extensions.cs
+++ b/src/Tochka.JsonRpc.Swagger/Extensions.cs
@@ -65,7 +65,7 @@ public static IServiceCollection AddSwaggerWithJsonRpc(this IServiceCollection s
c.IncludeXmlComments(xmlPath);
c.SupportNonNullableReferenceTypes();
-
+
// https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/2505
c.MapType(() => new OpenApiSchema
{
diff --git a/src/benchmarks/Tochka.JsonRpc.Benchmarks/Data/Requests.cs b/src/benchmarks/Tochka.JsonRpc.Benchmarks/Data/Requests.cs
index 72fd56b0..ca6b6d95 100644
--- a/src/benchmarks/Tochka.JsonRpc.Benchmarks/Data/Requests.cs
+++ b/src/benchmarks/Tochka.JsonRpc.Benchmarks/Data/Requests.cs
@@ -6,22 +6,24 @@ namespace Tochka.JsonRpc.Benchmarks.Data;
internal static class Requests
{
- public static string GetRequest(Guid id, string method, TestData parameters) => $$"""
- {
- "id": "{{id}}",
- "method": "{{method}}",
- "params": {{JsonSerializer.Serialize(parameters, JsonRpcSerializerOptions.SnakeCase)}},
- "jsonrpc": "2.0"
- }
- """;
+ public static string GetRequest(Guid id, string method, TestData parameters) =>
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{method}}",
+ "params": {{JsonSerializer.Serialize(parameters, JsonRpcSerializerOptions.SnakeCase)}},
+ "jsonrpc": "2.0"
+ }
+ """;
- public static string GetNotification(string method, TestData parameters) => $$"""
- {
- "method": "{{method}}",
- "params": {{JsonSerializer.Serialize(parameters, JsonRpcSerializerOptions.SnakeCase)}},
- "jsonrpc": "2.0"
- }
- """;
+ public static string GetNotification(string method, TestData parameters) =>
+ $$"""
+ {
+ "method": "{{method}}",
+ "params": {{JsonSerializer.Serialize(parameters, JsonRpcSerializerOptions.SnakeCase)}},
+ "jsonrpc": "2.0"
+ }
+ """;
public static IEnumerable AllDataValues => new[]
{
diff --git a/src/benchmarks/Tochka.JsonRpc.Benchmarks/Data/Responses.cs b/src/benchmarks/Tochka.JsonRpc.Benchmarks/Data/Responses.cs
index 214efc6e..d4751167 100644
--- a/src/benchmarks/Tochka.JsonRpc.Benchmarks/Data/Responses.cs
+++ b/src/benchmarks/Tochka.JsonRpc.Benchmarks/Data/Responses.cs
@@ -6,13 +6,14 @@ namespace Tochka.JsonRpc.Benchmarks.Data;
internal static class Responses
{
- public static string GetResponse(Guid id, TestData result) => $$"""
- {
- "id": "{{id}}",
- "result": {{JsonSerializer.Serialize(result, JsonRpcSerializerOptions.SnakeCase)}},
- "jsonrpc": "2.0"
- }
- """;
+ public static string GetResponse(Guid id, TestData result) =>
+ $$"""
+ {
+ "id": "{{id}}",
+ "result": {{JsonSerializer.Serialize(result, JsonRpcSerializerOptions.SnakeCase)}},
+ "jsonrpc": "2.0"
+ }
+ """;
public const string PlainKey = "plain";
public const string NestedKey = "nested";
diff --git a/src/tests/Tochka.JsonRpc.ApiExplorer.Tests/ClassWithEmptyConstructor.cs b/src/tests/Tochka.JsonRpc.ApiExplorer.Tests/ClassWithEmptyConstructor.cs
index a2776360..3a0f8e06 100644
--- a/src/tests/Tochka.JsonRpc.ApiExplorer.Tests/ClassWithEmptyConstructor.cs
+++ b/src/tests/Tochka.JsonRpc.ApiExplorer.Tests/ClassWithEmptyConstructor.cs
@@ -4,4 +4,4 @@ public record ClassWithEmptyConstructor
{
public string A { get; init; }
public object B { get; init; }
-}
\ No newline at end of file
+}
diff --git a/src/tests/Tochka.JsonRpc.ApiExplorer.Tests/ClassWithoutEmptyConstructor.cs b/src/tests/Tochka.JsonRpc.ApiExplorer.Tests/ClassWithoutEmptyConstructor.cs
index 6c54b868..139044e5 100644
--- a/src/tests/Tochka.JsonRpc.ApiExplorer.Tests/ClassWithoutEmptyConstructor.cs
+++ b/src/tests/Tochka.JsonRpc.ApiExplorer.Tests/ClassWithoutEmptyConstructor.cs
@@ -1,3 +1,3 @@
namespace Tochka.JsonRpc.ApiExplorer.Tests;
-public record ClassWithoutEmptyConstructor(string A, object B);
\ No newline at end of file
+public record ClassWithoutEmptyConstructor(string A, object B);
diff --git a/src/tests/Tochka.JsonRpc.ApiExplorer.Tests/JsonRpcDescriptionProviderTests.cs b/src/tests/Tochka.JsonRpc.ApiExplorer.Tests/JsonRpcDescriptionProviderTests.cs
index 422e3e57..abad6b86 100644
--- a/src/tests/Tochka.JsonRpc.ApiExplorer.Tests/JsonRpcDescriptionProviderTests.cs
+++ b/src/tests/Tochka.JsonRpc.ApiExplorer.Tests/JsonRpcDescriptionProviderTests.cs
@@ -30,12 +30,6 @@ public class JsonRpcDescriptionProviderTests
private JsonRpcDescriptionProvider descriptionProvider;
private Mock typeEmitterMock;
- private sealed class Foo;
-
- private sealed class Bar;
-
- private sealed class Baz;
-
[SetUp]
public void Setup()
{
@@ -402,8 +396,6 @@ public void OnProvidersExecuting_HasResponseType_RemoveItAndWrapResponseWithBase
description.SupportedResponseTypes.Single().Type.Should().Be(responseType);
}
-
-
[Test]
public void OnProvidersExecuting_DoesntHaveResponseType_WrapResponseWithObjectBaseType()
{
@@ -448,4 +440,10 @@ public void OnProvidersExecuting_DoesntHaveResponseType_WrapResponseWithObjectBa
private const string Method = "method";
private const string Route = "/api/jsonrpc";
+
+ private sealed class Foo;
+
+ private sealed class Bar;
+
+ private sealed class Baz;
}
diff --git a/src/tests/Tochka.JsonRpc.ApiExplorer.Tests/NonPublicClass.cs b/src/tests/Tochka.JsonRpc.ApiExplorer.Tests/NonPublicClass.cs
index e2fe9415..828eb95c 100644
--- a/src/tests/Tochka.JsonRpc.ApiExplorer.Tests/NonPublicClass.cs
+++ b/src/tests/Tochka.JsonRpc.ApiExplorer.Tests/NonPublicClass.cs
@@ -1,3 +1,3 @@
namespace Tochka.JsonRpc.ApiExplorer.Tests;
-internal sealed record NonPublicClass;
\ No newline at end of file
+internal sealed record NonPublicClass;
diff --git a/src/tests/Tochka.JsonRpc.ApiExplorer.Tests/SealedClass.cs b/src/tests/Tochka.JsonRpc.ApiExplorer.Tests/SealedClass.cs
index 5a4e87d2..742c9fd9 100644
--- a/src/tests/Tochka.JsonRpc.ApiExplorer.Tests/SealedClass.cs
+++ b/src/tests/Tochka.JsonRpc.ApiExplorer.Tests/SealedClass.cs
@@ -1,3 +1,3 @@
namespace Tochka.JsonRpc.ApiExplorer.Tests;
-public sealed record SealedClass;
\ No newline at end of file
+public sealed record SealedClass;
diff --git a/src/tests/Tochka.JsonRpc.ApiExplorer.Tests/TypeEmitterTests.cs b/src/tests/Tochka.JsonRpc.ApiExplorer.Tests/TypeEmitterTests.cs
index 0c1916f6..5e6c9dc0 100644
--- a/src/tests/Tochka.JsonRpc.ApiExplorer.Tests/TypeEmitterTests.cs
+++ b/src/tests/Tochka.JsonRpc.ApiExplorer.Tests/TypeEmitterTests.cs
@@ -431,12 +431,5 @@ public void CreateResponseType_ResultTypeIsVoid_GenericArgumentIsObject()
private const string ActionFullName = "namespace.controller.action";
private const string MethodName = "method";
- // ReSharper disable once MemberCanBePrivate.Global
public record NestedClass;
}
-
-// ReSharper disable once MemberCanBeInternal
-
-// ReSharper disable once MemberCanBeInternal
-
-// ReSharper disable once MemberCanBeInternal
\ No newline at end of file
diff --git a/src/tests/Tochka.JsonRpc.Client.Tests.Integration/IntegrationTests.cs b/src/tests/Tochka.JsonRpc.Client.Tests.Integration/IntegrationTests.cs
index fd8320db..b909bc5c 100644
--- a/src/tests/Tochka.JsonRpc.Client.Tests.Integration/IntegrationTests.cs
+++ b/src/tests/Tochka.JsonRpc.Client.Tests.Integration/IntegrationTests.cs
@@ -49,13 +49,14 @@ protected override void SetupServices(IServiceCollection services)
[Test]
public async Task SendNotification_SendRequestWithNullData_SerializeSuccessfully()
{
- var expectedRequestJson = $$"""
- {
- "method": "{{Method}}",
- "params": null,
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ {
+ "method": "{{Method}}",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
string actualContentType = null;
string actualRequestJson = null;
@@ -77,13 +78,14 @@ public async Task SendNotification_SendRequestWithNullData_SerializeSuccessfully
public async Task SendNotification_SendRequestWithPlainDataCamelCase_SerializeSuccessfully()
{
var requestData = TestData.Plain;
- var expectedRequestJson = $$"""
- {
- "method": "{{Method}}",
- "params": {{TestData.PlainFullCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ {
+ "method": "{{Method}}",
+ "params": {{TestData.PlainFullCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
string actualContentType = null;
string actualRequestJson = null;
@@ -105,13 +107,14 @@ public async Task SendNotification_SendRequestWithPlainDataCamelCase_SerializeSu
public async Task SendNotification_SendRequestWithPlainDataSnakeCase_SerializeSuccessfully()
{
var requestData = TestData.Plain;
- var expectedRequestJson = $$"""
- {
- "method": "{{Method}}",
- "params": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ {
+ "method": "{{Method}}",
+ "params": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
string actualContentType = null;
string actualRequestJson = null;
@@ -133,13 +136,14 @@ public async Task SendNotification_SendRequestWithPlainDataSnakeCase_SerializeSu
public async Task SendNotification_SendRequestWithNestedDataCamelCase_SerializeSuccessfully()
{
var requestData = TestData.Nested;
- var expectedRequestJson = $$"""
- {
- "method": "{{Method}}",
- "params": {{TestData.NestedFullCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ {
+ "method": "{{Method}}",
+ "params": {{TestData.NestedFullCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
string actualContentType = null;
string actualRequestJson = null;
@@ -161,13 +165,14 @@ public async Task SendNotification_SendRequestWithNestedDataCamelCase_SerializeS
public async Task SendNotification_SendRequestWithNestedDataSnakeCase_SerializeSuccessfully()
{
var requestData = TestData.Nested;
- var expectedRequestJson = $$"""
- {
- "method": "{{Method}}",
- "params": {{TestData.NestedFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ {
+ "method": "{{Method}}",
+ "params": {{TestData.NestedFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
string actualContentType = null;
string actualRequestJson = null;
@@ -189,14 +194,15 @@ public async Task SendNotification_SendRequestWithNestedDataSnakeCase_SerializeS
public async Task SendRequest_SendRequestWithStringId_SerializeSuccessfully()
{
var id = Guid.NewGuid().ToString();
- var expectedRequestJson = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
var responseBody = JsonDocument.Parse($$"""
{
"id": "{{id}}",
@@ -228,14 +234,15 @@ public async Task SendRequest_SendRequestWithStringId_SerializeSuccessfully()
public async Task SendRequest_SendRequestWithIntId_SerializeSuccessfully()
{
var id = 123;
- var expectedRequestJson = $$"""
- {
- "id": {{id}},
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ {
+ "id": {{id}},
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
var responseBody = JsonDocument.Parse($$"""
{
"id": {{id}},
@@ -267,14 +274,15 @@ public async Task SendRequest_SendRequestWithIntId_SerializeSuccessfully()
public async Task SendRequest_SendRequestWithFloatId_SerializeSuccessfully()
{
var id = 123.5;
- var expectedRequestJson = $$"""
- {
- "id": {{id.ToString(CultureInfo.InvariantCulture)}},
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ {
+ "id": {{id.ToString(CultureInfo.InvariantCulture)}},
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
var responseBody = JsonDocument.Parse($$"""
{
"id": {{id.ToString(CultureInfo.InvariantCulture)}},
@@ -305,14 +313,15 @@ public async Task SendRequest_SendRequestWithFloatId_SerializeSuccessfully()
[Test]
public async Task SendRequest_SendRequestWithNullId_SerializeSuccessfully()
{
- var expectedRequestJson = $$"""
- {
- "id": null,
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ {
+ "id": null,
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
var responseBody = JsonDocument.Parse("""
{
"id": null,
@@ -344,14 +353,15 @@ public async Task SendRequest_SendRequestWithNullId_SerializeSuccessfully()
public async Task SendRequest_SendRequestWithNullData_SerializeSuccessfully()
{
var id = Guid.NewGuid().ToString();
- var expectedRequestJson = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": null,
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
var responseBody = JsonDocument.Parse($$"""
{
"id": "{{id}}",
@@ -385,14 +395,15 @@ public async Task SendRequest_SendRequestWithPlainDataCamelCase_SerializeSuccess
{
var id = Guid.NewGuid().ToString();
var requestData = TestData.Plain;
- var expectedRequestJson = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {{TestData.PlainFullCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {{TestData.PlainFullCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
var responseBody = JsonDocument.Parse($$"""
{
"id": "{{id}}",
@@ -427,14 +438,15 @@ public async Task SendRequest_SendRequestWithPlainDataSnakeCase_SerializeSuccess
{
var id = Guid.NewGuid().ToString();
var requestData = TestData.Plain;
- var expectedRequestJson = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
var responseBody = JsonDocument.Parse($$"""
{
"id": "{{id}}",
@@ -469,14 +481,15 @@ public async Task SendRequest_SendRequestWithNestedDataCamelCase_SerializeSucces
{
var id = Guid.NewGuid().ToString();
var requestData = TestData.Nested;
- var expectedRequestJson = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {{TestData.NestedFullCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {{TestData.NestedFullCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
var responseBody = JsonDocument.Parse($$"""
{
"id": "{{id}}",
@@ -511,14 +524,15 @@ public async Task SendRequest_SendRequestWithNestedDataSnakeCase_SerializeSucces
{
var id = Guid.NewGuid().ToString();
var requestData = TestData.Nested;
- var expectedRequestJson = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {{TestData.NestedFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {{TestData.NestedFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
var responseBody = JsonDocument.Parse($$"""
{
"id": "{{id}}",
@@ -552,14 +566,15 @@ public async Task SendRequest_SendRequestWithNestedDataSnakeCase_SerializeSucces
public async Task SendRequest_GetErrorWithCamelCaseData_DeserializeSuccessfully()
{
var id = Guid.NewGuid().ToString();
- var expectedRequestJson = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
var errorCode = 123;
var errorMessage = "errorMessage";
var responseBody = JsonDocument.Parse($$"""
@@ -599,14 +614,15 @@ public async Task SendRequest_GetErrorWithCamelCaseData_DeserializeSuccessfully(
public async Task SendRequest_GetErrorWithSnakeCaseData_SerializeSuccessfully()
{
var id = Guid.NewGuid().ToString();
- var expectedRequestJson = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
var errorCode = 123;
var errorMessage = "errorMessage";
var responseBody = JsonDocument.Parse($$"""
@@ -646,14 +662,15 @@ public async Task SendRequest_GetErrorWithSnakeCaseData_SerializeSuccessfully()
public async Task SendRequest_GetErrorWithoutData_SerializeSuccessfully()
{
var id = Guid.NewGuid().ToString();
- var expectedRequestJson = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
var errorCode = 123;
var errorMessage = "errorMessage";
var responseBody = JsonDocument.Parse($$"""
@@ -692,14 +709,15 @@ public async Task SendRequest_GetErrorWithoutData_SerializeSuccessfully()
public async Task SendRequest_GetResponseWithErrorInResult_DeserializeSuccessfully()
{
var id = Guid.NewGuid().ToString();
- var expectedRequestJson = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
var error = "errorValue";
var responseBody = JsonDocument.Parse($$"""
{
@@ -736,14 +754,15 @@ public async Task SendRequest_GetResponseWithErrorInResult_DeserializeSuccessful
public async Task SendRequest_GetResponseWithResultInError_DeserializeSuccessfully()
{
var id = Guid.NewGuid().ToString();
- var expectedRequestJson = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
var errorCode = 123;
var errorMessage = "errorMessage";
var result = "resultValue";
@@ -786,14 +805,15 @@ public async Task SendRequest_GetResponseWithResultInError_DeserializeSuccessful
public async Task SendRequest_GetErrorResponseWithNullId_DeserializeSuccessfully()
{
var id = Guid.NewGuid().ToString();
- var expectedRequestJson = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
var errorCode = 123;
var errorMessage = "errorMessage";
var responseBody = JsonDocument.Parse($$"""
@@ -832,14 +852,15 @@ public async Task SendRequest_GetErrorResponseWithNullId_DeserializeSuccessfully
public async Task SendRequest_GetResponseWithoutId_ThrowJsonRpcFormatException()
{
var id = Guid.NewGuid().ToString();
- var expectedRequestJson = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
var responseBody = JsonDocument.Parse("""
{
"result": {},
@@ -870,14 +891,15 @@ public async Task SendRequest_GetResponseWithoutId_ThrowJsonRpcFormatException()
public async Task SendRequest_GetResponseWithoutResultOrError_ThrowJsonRpcFormatException()
{
var id = Guid.NewGuid().ToString();
- var expectedRequestJson = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
var responseBody = JsonDocument.Parse($$"""
{
"id": "{{id}}",
@@ -908,14 +930,15 @@ public async Task SendRequest_GetResponseWithoutResultOrError_ThrowJsonRpcFormat
public async Task SendRequest_GetResponseWithBothResultAndError_ThrowJsonRpcFormatException()
{
var id = Guid.NewGuid().ToString();
- var expectedRequestJson = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
var errorCode = 123;
var errorMessage = "errorMessage";
var responseBody = JsonDocument.Parse($$"""
@@ -953,14 +976,15 @@ public async Task SendRequest_GetResponseWithBothResultAndError_ThrowJsonRpcForm
public async Task SendRequest_GetResponseNot200Code_ThrowJsonRpcException()
{
var id = Guid.NewGuid().ToString();
- var expectedRequestJson = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
string actualContentType = null;
string actualRequestJson = null;
@@ -985,14 +1009,15 @@ public async Task SendRequest_GetResponseNot200Code_ThrowJsonRpcException()
public async Task SendRequest_GetResponseWithDifferentId_ThrowJsonRpcException()
{
var id = Guid.NewGuid().ToString();
- var expectedRequestJson = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
var responseBody = JsonDocument.Parse($$"""
{
"id": "{{Guid.NewGuid().ToString()}}",
@@ -1024,14 +1049,15 @@ public async Task SendRequest_GetResponseWithDifferentId_ThrowJsonRpcException()
public async Task SendRequest_GetSuccessfulResponseWithNullId_ThrowJsonRpcException()
{
var id = Guid.NewGuid().ToString();
- var expectedRequestJson = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
var responseBody = JsonDocument.Parse("""
{
"id": null,
@@ -1063,16 +1089,17 @@ public async Task SendRequest_GetSuccessfulResponseWithNullId_ThrowJsonRpcExcept
public async Task SendBatch_BatchWithRequestWithStringId_LinkResponseSuccessfully()
{
var id = Guid.NewGuid().ToString();
- var expectedRequestJson = $$"""
- [
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ [
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
var responseBody = JsonDocument.Parse($$"""
[
{
@@ -1110,16 +1137,17 @@ public async Task SendBatch_BatchWithRequestWithStringId_LinkResponseSuccessfull
public async Task SendBatch_BatchWithRequestWithIntId_LinkResponseSuccessfully()
{
var id = 123;
- var expectedRequestJson = $$"""
- [
- {
- "id": {{id}},
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ [
+ {
+ "id": {{id}},
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
var responseBody = JsonDocument.Parse($$"""
[
{
@@ -1156,16 +1184,17 @@ public async Task SendBatch_BatchWithRequestWithIntId_LinkResponseSuccessfully()
[Test]
public async Task SendBatch_BatchWithRequestWithNullId_LinkResponseSuccessfully()
{
- var expectedRequestJson = $$"""
- [
- {
- "id": null,
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ [
+ {
+ "id": null,
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
var responseBody = JsonDocument.Parse("""
[
{
@@ -1204,16 +1233,17 @@ public async Task SendBatch_BatchWith1Request_SerializeSuccessfully()
{
var id = Guid.NewGuid().ToString();
var requestData = TestData.Plain;
- var expectedRequestJson = $$"""
- [
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {{TestData.PlainFullCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ [
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {{TestData.PlainFullCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
var responseBody = JsonDocument.Parse($$"""
[
{
@@ -1255,22 +1285,23 @@ public async Task SendBatch_BatchWithRequests_SerializeSuccessfully()
var id1 = Guid.NewGuid().ToString();
var id2 = Guid.NewGuid().ToString();
var requestData = TestData.Plain;
- var expectedRequestJson = $$"""
- [
- {
- "id": "{{id1}}",
- "method": "{{Method}}",
- "params": {{TestData.PlainFullCamelCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "{{id2}}",
- "method": "{{Method}}",
- "params": {{TestData.PlainFullCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ [
+ {
+ "id": "{{id1}}",
+ "method": "{{Method}}",
+ "params": {{TestData.PlainFullCamelCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "{{id2}}",
+ "method": "{{Method}}",
+ "params": {{TestData.PlainFullCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
var responseBody = JsonDocument.Parse($$"""
[
{
@@ -1318,15 +1349,16 @@ public async Task SendBatch_BatchWithRequests_SerializeSuccessfully()
public async Task SendBatch_BatchWith1Notification_SerializeSuccessfully()
{
var requestData = TestData.Plain;
- var expectedRequestJson = $$"""
- [
- {
- "method": "{{Method}}",
- "params": {{TestData.PlainFullCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ [
+ {
+ "method": "{{Method}}",
+ "params": {{TestData.PlainFullCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
string actualContentType = null;
string actualRequestJson = null;
@@ -1355,20 +1387,21 @@ public async Task SendBatch_BatchWith1Notification_SerializeSuccessfully()
public async Task SendBatch_BatchWithNotifications_SerializeSuccessfully()
{
var requestData = TestData.Plain;
- var expectedRequestJson = $$"""
- [
- {
- "method": "{{Method}}",
- "params": {{TestData.PlainFullCamelCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "method": "{{Method}}",
- "params": {{TestData.PlainFullCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ [
+ {
+ "method": "{{Method}}",
+ "params": {{TestData.PlainFullCamelCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "{{Method}}",
+ "params": {{TestData.PlainFullCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
string actualContentType = null;
string actualRequestJson = null;
@@ -1397,21 +1430,22 @@ public async Task SendBatch_BatchWithRequestsAndNotifications_SerializeSuccessfu
{
var id = Guid.NewGuid().ToString();
var requestData = TestData.Plain;
- var expectedRequestJson = $$"""
- [
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {{TestData.PlainFullCamelCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "method": "{{Method}}",
- "params": {{TestData.PlainFullCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ [
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {{TestData.PlainFullCamelCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "{{Method}}",
+ "params": {{TestData.PlainFullCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
var responseBody = JsonDocument.Parse($$"""
[
{
@@ -1453,16 +1487,17 @@ public async Task SendBatch_GetResponseWith1Error_DeserializeSuccessfully()
{
var id = Guid.NewGuid().ToString();
var requestData = TestData.Plain;
- var expectedRequestJson = $$"""
- [
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {{TestData.PlainFullCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ [
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {{TestData.PlainFullCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
var errorCode = 123;
var errorMessage = "errorMessage";
var responseBody = JsonDocument.Parse($$"""
@@ -1510,22 +1545,23 @@ public async Task SendBatch_GetResponseWithErrors_DeserializeSuccessfully()
var id1 = Guid.NewGuid().ToString();
var id2 = Guid.NewGuid().ToString();
var requestData = TestData.Plain;
- var expectedRequestJson = $$"""
- [
- {
- "id": "{{id1}}",
- "method": "{{Method}}",
- "params": {{TestData.PlainFullCamelCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "{{id2}}",
- "method": "{{Method}}",
- "params": {{TestData.PlainFullCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ [
+ {
+ "id": "{{id1}}",
+ "method": "{{Method}}",
+ "params": {{TestData.PlainFullCamelCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "{{id2}}",
+ "method": "{{Method}}",
+ "params": {{TestData.PlainFullCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
var errorCode = 123;
var errorMessage = "errorMessage";
var responseBody = JsonDocument.Parse($$"""
@@ -1585,22 +1621,23 @@ public async Task SendBatch_GetResponseWithResultsAndErrors_DeserializeSuccessfu
var id1 = Guid.NewGuid().ToString();
var id2 = Guid.NewGuid().ToString();
var requestData = TestData.Plain;
- var expectedRequestJson = $$"""
- [
- {
- "id": "{{id1}}",
- "method": "{{Method}}",
- "params": {{TestData.PlainFullCamelCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "{{id2}}",
- "method": "{{Method}}",
- "params": {{TestData.PlainFullCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ [
+ {
+ "id": "{{id1}}",
+ "method": "{{Method}}",
+ "params": {{TestData.PlainFullCamelCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "{{id2}}",
+ "method": "{{Method}}",
+ "params": {{TestData.PlainFullCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
var errorCode = 123;
var errorMessage = "errorMessage";
var responseBody = JsonDocument.Parse($$"""
@@ -1656,16 +1693,17 @@ public async Task SendBatch_GetSingleErrorResponse_ThrowJsonRpcException()
{
var id = Guid.NewGuid().ToString();
var requestData = TestData.Plain;
- var expectedRequestJson = $$"""
- [
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {{TestData.PlainFullCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ [
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {{TestData.PlainFullCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
var errorCode = 123;
var errorMessage = "errorMessage";
var responseBody = JsonDocument.Parse($$"""
@@ -1708,16 +1746,17 @@ public async Task SendBatch_GetResponseWithDifferentId_ThrowJsonRpcException()
{
var id = Guid.NewGuid().ToString();
var requestData = TestData.Plain;
- var expectedRequestJson = $$"""
- [
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {{TestData.PlainFullCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedRequestJson =
+ $$"""
+ [
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {{TestData.PlainFullCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
var responseBody = JsonDocument.Parse($$"""
[
{
diff --git a/src/tests/Tochka.JsonRpc.Common.Tests/Converters/CallConverterTests.cs b/src/tests/Tochka.JsonRpc.Common.Tests/Converters/CallConverterTests.cs
index 946c84e7..66547772 100644
--- a/src/tests/Tochka.JsonRpc.Common.Tests/Converters/CallConverterTests.cs
+++ b/src/tests/Tochka.JsonRpc.Common.Tests/Converters/CallConverterTests.cs
@@ -21,14 +21,15 @@ public void Serialize_UntypedRequest()
var serialized = JsonSerializer.Serialize(request, JsonRpcSerializerOptions.Headers);
- var expected = $$"""
- {
- "id": "{{id}}",
- "method": "{{method}}",
- "params": null,
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{method}}",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.TrimAllLines().Should().Be(expected);
}
@@ -40,13 +41,14 @@ public void Serialize_UntypedNotification()
var serialized = JsonSerializer.Serialize(request, JsonRpcSerializerOptions.Headers);
- var expected = $$"""
- {
- "method": "{{method}}",
- "params": null,
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "method": "{{method}}",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.TrimAllLines().Should().Be(expected);
}
@@ -63,14 +65,15 @@ public void Deserialize_Request()
{
const string id = "id";
const string method = "method";
- var request = $$"""
- {
- "id": "{{id}}",
- "method": "{{method}}",
- "params": null,
- "jsonrpc": "2.0"
- }
- """;
+ var request =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{method}}",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(request, JsonRpcSerializerOptions.Headers);
@@ -81,13 +84,14 @@ public void Deserialize_Request()
public void Deserialize_Notification()
{
const string method = "method";
- var request = $$"""
- {
- "method": "{{method}}",
- "params": null,
- "jsonrpc": "2.0"
- }
- """;
+ var request =
+ $$"""
+ {
+ "method": "{{method}}",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(request, JsonRpcSerializerOptions.Headers);
@@ -98,13 +102,14 @@ public void Deserialize_Notification()
public void Deserialize_NoMethod_Throw()
{
const string id = "id";
- var request = $$"""
- {
- "id": "{{id}}",
- "params": null,
- "jsonrpc": "2.0"
- }
- """;
+ var request =
+ $$"""
+ {
+ "id": "{{id}}",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ """;
var action = () => JsonSerializer.Deserialize(request, JsonRpcSerializerOptions.Headers);
@@ -116,13 +121,14 @@ public void Deserialize_NoVersion_Throw()
{
const string id = "id";
const string method = "method";
- var request = $$"""
- {
- "id": "{{id}}",
- "method": "{{method}}",
- "params": null
- }
- """;
+ var request =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{method}}",
+ "params": null
+ }
+ """;
var action = () => JsonSerializer.Deserialize(request, JsonRpcSerializerOptions.Headers);
diff --git a/src/tests/Tochka.JsonRpc.Common.Tests/Converters/JsonRpcIdConverterTests.cs b/src/tests/Tochka.JsonRpc.Common.Tests/Converters/JsonRpcIdConverterTests.cs
index a1ab09ee..dc74d439 100644
--- a/src/tests/Tochka.JsonRpc.Common.Tests/Converters/JsonRpcIdConverterTests.cs
+++ b/src/tests/Tochka.JsonRpc.Common.Tests/Converters/JsonRpcIdConverterTests.cs
@@ -143,8 +143,11 @@ public void SerializeDeserialize_RpcIdTheSame(string idJson)
var deserialized = JsonSerializer.Deserialize(idJson, JsonRpcSerializerOptions.Headers);
var serialized = JsonSerializer.Serialize(deserialized, JsonRpcSerializerOptions.Headers);
- deserialized.Should().BeOfType().Subject.Value.ToString(CultureInfo.InvariantCulture)
- .Should().Be(serialized);
+ deserialized.Should()
+ .BeOfType()
+ .Subject.Value.ToString(CultureInfo.InvariantCulture)
+ .Should()
+ .Be(serialized);
}
[Test]
diff --git a/src/tests/Tochka.JsonRpc.Common.Tests/Converters/ResponseConverterTests.cs b/src/tests/Tochka.JsonRpc.Common.Tests/Converters/ResponseConverterTests.cs
index 8492cc0b..77e121e9 100644
--- a/src/tests/Tochka.JsonRpc.Common.Tests/Converters/ResponseConverterTests.cs
+++ b/src/tests/Tochka.JsonRpc.Common.Tests/Converters/ResponseConverterTests.cs
@@ -22,13 +22,14 @@ public void Serialize_UntypedResponse()
var serialized = JsonSerializer.Serialize(request, JsonRpcSerializerOptions.Headers);
- var expected = $$"""
- {
- "id": "{{id}}",
- "result": null,
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{id}}",
+ "result": null,
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.TrimAllLines().Should().Be(expected);
}
@@ -42,17 +43,18 @@ public void Serialize_UntypedErrorResponse()
var serialized = JsonSerializer.Serialize(request, JsonRpcSerializerOptions.Headers);
- var expected = $$"""
- {
- "id": "{{id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": null
- },
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": null
+ },
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.TrimAllLines().Should().Be(expected);
}
@@ -68,13 +70,14 @@ public void Serialize_UnknownType_Throw()
public void Deserialize_Response()
{
const string id = "id";
- var request = $$"""
- {
- "id": "{{id}}",
- "result": null,
- "jsonrpc": "2.0"
- }
- """;
+ var request =
+ $$"""
+ {
+ "id": "{{id}}",
+ "result": null,
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(request, JsonRpcSerializerOptions.Headers);
@@ -88,17 +91,18 @@ public void Deserialize_ErrorResponse()
const string id = "id";
const int errorCode = 123;
const string errorMessage = "message";
- var request = $$"""
- {
- "id": "{{id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": null
- },
- "jsonrpc": "2.0"
- }
- """;
+ var request =
+ $$"""
+ {
+ "id": "{{id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": null
+ },
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(request, JsonRpcSerializerOptions.Headers);
@@ -110,11 +114,11 @@ public void Deserialize_ErrorResponse()
public void Deserialize_NoId_Throw()
{
var request = """
- {
- "result": null,
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "result": null,
+ "jsonrpc": "2.0"
+ }
+ """;
var action = () => JsonSerializer.Deserialize(request, JsonRpcSerializerOptions.Headers);
@@ -125,12 +129,13 @@ public void Deserialize_NoId_Throw()
public void Deserialize_NoVersion_Throw()
{
const string id = "id";
- var request = $$"""
- {
- "id": "{{id}}",
- "result": null
- }
- """;
+ var request =
+ $$"""
+ {
+ "id": "{{id}}",
+ "result": null
+ }
+ """;
var action = () => JsonSerializer.Deserialize(request, JsonRpcSerializerOptions.Headers);
@@ -141,12 +146,13 @@ public void Deserialize_NoVersion_Throw()
public void Deserialize_NoResultAndError_Throw()
{
const string id = "id";
- var request = $$"""
- {
- "id": "{{id}}",
- "jsonrpc": "2.0"
- }
- """;
+ var request =
+ $$"""
+ {
+ "id": "{{id}}",
+ "jsonrpc": "2.0"
+ }
+ """;
var action = () => JsonSerializer.Deserialize(request, JsonRpcSerializerOptions.Headers);
@@ -157,18 +163,19 @@ public void Deserialize_NoResultAndError_Throw()
public void Deserialize_BothResultAndError_Throw()
{
const string id = "id";
- var request = $$"""
- {
- "id": "{{id}}",
- "result": null,
- "error": {
- "code": 123,
- "message": "message",
- "data": null
- },
- "jsonrpc": "2.0"
- }
- """;
+ var request =
+ $$"""
+ {
+ "id": "{{id}}",
+ "result": null,
+ "error": {
+ "code": 123,
+ "message": "message",
+ "data": null
+ },
+ "jsonrpc": "2.0"
+ }
+ """;
var action = () => JsonSerializer.Deserialize(request, JsonRpcSerializerOptions.Headers);
diff --git a/src/tests/Tochka.JsonRpc.Common.Tests/Converters/ResponseWrapperConverterTests.cs b/src/tests/Tochka.JsonRpc.Common.Tests/Converters/ResponseWrapperConverterTests.cs
index 1a297a9b..05554416 100644
--- a/src/tests/Tochka.JsonRpc.Common.Tests/Converters/ResponseWrapperConverterTests.cs
+++ b/src/tests/Tochka.JsonRpc.Common.Tests/Converters/ResponseWrapperConverterTests.cs
@@ -23,13 +23,14 @@ public void Serialize_Single()
var serialized = JsonSerializer.Serialize(wrapper, JsonRpcSerializerOptions.Headers);
- var expected = $$"""
- {
- "id": "{{id}}",
- "result": null,
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{id}}",
+ "result": null,
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.TrimAllLines().Should().Be(expected);
}
@@ -41,15 +42,16 @@ public void Serialize_Batch()
var serialized = JsonSerializer.Serialize(request, JsonRpcSerializerOptions.Headers);
- var expected = $$"""
- [
- {
- "id": "{{id}}",
- "result": null,
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expected =
+ $$"""
+ [
+ {
+ "id": "{{id}}",
+ "result": null,
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
serialized.TrimAllLines().Should().Be(expected);
}
@@ -65,12 +67,12 @@ public void Serialize_UnknownType_Throw()
public void Deserialize_Single()
{
var json = """
- {
- "id": "id",
- "result": null,
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "id": "id",
+ "result": null,
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, JsonRpcSerializerOptions.Headers);
diff --git a/src/tests/Tochka.JsonRpc.Common.Tests/DeserializationTests.cs b/src/tests/Tochka.JsonRpc.Common.Tests/DeserializationTests.cs
index d9b9595d..84ae425d 100644
--- a/src/tests/Tochka.JsonRpc.Common.Tests/DeserializationTests.cs
+++ b/src/tests/Tochka.JsonRpc.Common.Tests/DeserializationTests.cs
@@ -30,13 +30,14 @@ public class DeserializationTests
public void Notification_EmptyObjectParams()
{
var method = "method";
- var json = $$"""
- {
- "method": "{{method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "method": "{{method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -51,13 +52,14 @@ public void Notification_EmptyObjectParams()
public void Notification_EmptyArrayParams()
{
var method = "method";
- var json = $$"""
- {
- "method": "{{method}}",
- "params": [],
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "method": "{{method}}",
+ "params": [],
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -74,13 +76,14 @@ public void Notification_EmptyArrayParams()
public void Notification_NullParams()
{
var method = "method";
- var json = $$"""
- {
- "method": "{{method}}",
- "params": null,
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "method": "{{method}}",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -94,12 +97,13 @@ public void Notification_NullParams()
public void Notification_NoParams()
{
var method = "method";
- var json = $$"""
- {
- "method": "{{method}}",
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "method": "{{method}}",
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -114,13 +118,14 @@ public void Notification_PrimitiveTypeParams()
{
var method = "method";
var parameter = 123;
- var json = $$"""
- {
- "method": "{{method}}",
- "params": {{parameter}},
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "method": "{{method}}",
+ "params": {{parameter}},
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -136,15 +141,16 @@ public void Notification_PrimitiveTypeArrayParams()
{
var method = "method";
var parameter = 123;
- var json = $$"""
- {
- "method": "{{method}}",
- "params": [
- {{parameter}}
- ],
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "method": "{{method}}",
+ "params": [
+ {{parameter}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -161,13 +167,14 @@ public void Notification_PrimitiveTypeArrayParams()
public void Notification_PlainSnakeCaseObjectParams()
{
var method = "method";
- var json = $$"""
- {
- "method": "{{method}}",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "method": "{{method}}",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -182,13 +189,14 @@ public void Notification_PlainSnakeCaseObjectParams()
public void Notification_PlainCamelCaseObjectParams()
{
var method = "method";
- var json = $$"""
- {
- "method": "{{method}}",
- "params": {{TestData.PlainRequiredCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "method": "{{method}}",
+ "params": {{TestData.PlainRequiredCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -203,15 +211,16 @@ public void Notification_PlainCamelCaseObjectParams()
public void Notification_PlainSnakeCaseArrayParams()
{
var method = "method";
- var json = $$"""
- {
- "method": "{{method}}",
- "params": [
- {{TestData.PlainRequiredSnakeCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "method": "{{method}}",
+ "params": [
+ {{TestData.PlainRequiredSnakeCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -229,15 +238,16 @@ public void Notification_PlainSnakeCaseArrayParams()
public void Notification_PlainCamelCaseArrayParams()
{
var method = "method";
- var json = $$"""
- {
- "method": "{{method}}",
- "params": [
- {{TestData.PlainRequiredCamelCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "method": "{{method}}",
+ "params": [
+ {{TestData.PlainRequiredCamelCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -255,13 +265,14 @@ public void Notification_PlainCamelCaseArrayParams()
public void Notification_NestedSnakeCaseObjectParams()
{
var method = "method";
- var json = $$"""
- {
- "method": "{{method}}",
- "params": {{TestData.NestedRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "method": "{{method}}",
+ "params": {{TestData.NestedRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -276,13 +287,14 @@ public void Notification_NestedSnakeCaseObjectParams()
public void Notification_NestedCamelCaseObjectParams()
{
var method = "method";
- var json = $$"""
- {
- "method": "{{method}}",
- "params": {{TestData.NestedRequiredCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "method": "{{method}}",
+ "params": {{TestData.NestedRequiredCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -297,15 +309,16 @@ public void Notification_NestedCamelCaseObjectParams()
public void Notification_NestedSnakeCaseArrayParams()
{
var method = "method";
- var json = $$"""
- {
- "method": "{{method}}",
- "params": [
- {{TestData.NestedRequiredSnakeCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "method": "{{method}}",
+ "params": [
+ {{TestData.NestedRequiredSnakeCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -323,15 +336,16 @@ public void Notification_NestedSnakeCaseArrayParams()
public void Notification_NestedCamelCaseArrayParams()
{
var method = "method";
- var json = $$"""
- {
- "method": "{{method}}",
- "params": [
- {{TestData.NestedRequiredCamelCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "method": "{{method}}",
+ "params": [
+ {{TestData.NestedRequiredCamelCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -354,14 +368,15 @@ public void Request_EmptyObjectParams()
{
var method = "method";
var id = "123";
- var json = $$"""
- {
- "id": "{{id}}",
- "method": "{{method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -378,14 +393,15 @@ public void Request_EmptyArrayParams()
{
var method = "method";
var id = "123";
- var json = $$"""
- {
- "id": "{{id}}",
- "method": "{{method}}",
- "params": [],
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{method}}",
+ "params": [],
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -404,14 +420,15 @@ public void Request_NullParams()
{
var method = "method";
var id = "123";
- var json = $$"""
- {
- "id": "{{id}}",
- "method": "{{method}}",
- "params": null,
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{method}}",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -426,13 +443,14 @@ public void Request_NoParams()
{
var method = "method";
var id = "123";
- var json = $$"""
- {
- "id": "{{id}}",
- "method": "{{method}}",
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{method}}",
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -447,13 +465,14 @@ public void Request_IntId()
{
var method = "method";
var id = 123;
- var json = $$"""
- {
- "id": {{id}},
- "method": "{{method}}",
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": {{id}},
+ "method": "{{method}}",
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -468,13 +487,14 @@ public void Request_FloatId()
{
var method = "method";
var id = 123.565;
- var json = $$"""
- {
- "id": {{id.ToString(CultureInfo.InvariantCulture)}},
- "method": "{{method}}",
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": {{id.ToString(CultureInfo.InvariantCulture)}},
+ "method": "{{method}}",
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -482,7 +502,6 @@ public void Request_FloatId()
var request = ((SingleRequestWrapper) deserialized).Call.Deserialize(headersJsonSerializerOptions);
var expected = new UntypedRequest(new FloatNumberRpcId(id), method, null);
-
request.Should().BeEquivalentTo(expected);
}
@@ -491,13 +510,14 @@ public void Request_StringId()
{
var method = "method";
var id = "123";
- var json = $$"""
- {
- "id": "{{id}}",
- "method": "{{method}}",
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{method}}",
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -511,13 +531,14 @@ public void Request_StringId()
public void Request_NullId()
{
var method = "method";
- var json = $$"""
- {
- "id": null,
- "method": "{{method}}",
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": null,
+ "method": "{{method}}",
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -533,14 +554,15 @@ public void Request_PrimitiveTypeParams()
var method = "method";
var id = "123";
var parameter = 123;
- var json = $$"""
- {
- "id": "{{id}}",
- "method": "{{method}}",
- "params": {{parameter}},
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{method}}",
+ "params": {{parameter}},
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -558,16 +580,17 @@ public void Request_PrimitiveTypeArrayParams()
var method = "method";
var id = "123";
var parameter = 123;
- var json = $$"""
- {
- "id": "{{id}}",
- "method": "{{method}}",
- "params": [
- {{parameter}}
- ],
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{method}}",
+ "params": [
+ {{parameter}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -586,14 +609,15 @@ public void Request_PlainSnakeCaseObjectParams()
{
var method = "method";
var id = "123";
- var json = $$"""
- {
- "id": "{{id}}",
- "method": "{{method}}",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{method}}",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -610,14 +634,15 @@ public void Request_PlainCamelCaseObjectParams()
{
var method = "method";
var id = "123";
- var json = $$"""
- {
- "id": "{{id}}",
- "method": "{{method}}",
- "params": {{TestData.PlainRequiredCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{method}}",
+ "params": {{TestData.PlainRequiredCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -634,16 +659,17 @@ public void Request_PlainSnakeCaseArrayParams()
{
var method = "method";
var id = "123";
- var json = $$"""
- {
- "id": "{{id}}",
- "method": "{{method}}",
- "params": [
- {{TestData.PlainRequiredSnakeCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{method}}",
+ "params": [
+ {{TestData.PlainRequiredSnakeCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -663,16 +689,17 @@ public void Request_PlainCamelCaseArrayParams()
{
var method = "method";
var id = "123";
- var json = $$"""
- {
- "id": "{{id}}",
- "method": "{{method}}",
- "params": [
- {{TestData.PlainRequiredCamelCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{method}}",
+ "params": [
+ {{TestData.PlainRequiredCamelCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -692,14 +719,15 @@ public void Request_NestedSnakeCaseObjectParams()
{
var method = "method";
var id = "123";
- var json = $$"""
- {
- "id": "{{id}}",
- "method": "{{method}}",
- "params": {{TestData.NestedRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{method}}",
+ "params": {{TestData.NestedRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -716,14 +744,15 @@ public void Request_NestedCamelCaseObjectParams()
{
var method = "method";
var id = "123";
- var json = $$"""
- {
- "id": "{{id}}",
- "method": "{{method}}",
- "params": {{TestData.NestedRequiredCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{method}}",
+ "params": {{TestData.NestedRequiredCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -740,16 +769,17 @@ public void Request_NestedSnakeCaseArrayParams()
{
var method = "method";
var id = "123";
- var json = $$"""
- {
- "id": "{{id}}",
- "method": "{{method}}",
- "params": [
- {{TestData.NestedRequiredSnakeCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{method}}",
+ "params": [
+ {{TestData.NestedRequiredSnakeCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -769,16 +799,17 @@ public void Request_NestedCamelCaseArrayParams()
{
var method = "method";
var id = "123";
- var json = $$"""
- {
- "id": "{{id}}",
- "method": "{{method}}",
- "params": [
- {{TestData.NestedRequiredCamelCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{method}}",
+ "params": [
+ {{TestData.NestedRequiredCamelCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -801,13 +832,14 @@ public void Request_NestedCamelCaseArrayParams()
public void RequestResponse_EmptyObjectResult()
{
var id = "123";
- var json = $$"""
- {
- "id": "{{id}}",
- "result": {},
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "result": {},
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -822,13 +854,14 @@ public void RequestResponse_EmptyObjectResult()
public void RequestResponse_EmptyArrayResult()
{
var id = "123";
- var json = $$"""
- {
- "id": "{{id}}",
- "result": [],
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "result": [],
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -845,13 +878,14 @@ public void RequestResponse_EmptyArrayResult()
public void RequestResponse_NullResult()
{
var id = "123";
- var json = $$"""
- {
- "id": "{{id}}",
- "result": null,
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "result": null,
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -863,13 +897,14 @@ public void RequestResponse_NullResult()
public void RequestResponse_IntId()
{
var id = 123;
- var json = $$"""
- {
- "id": {{id}},
- "result": {},
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": {{id}},
+ "result": {},
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -881,13 +916,14 @@ public void RequestResponse_IntId()
public void RequestResponse_FloatId()
{
var id = 123.565;
- var json = $$"""
- {
- "id": {{id.ToString(CultureInfo.InvariantCulture)}},
- "result": {},
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": {{id.ToString(CultureInfo.InvariantCulture)}},
+ "result": {},
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -899,13 +935,14 @@ public void RequestResponse_FloatId()
public void RequestResponse_StringId()
{
var id = "123";
- var json = $$"""
- {
- "id": "{{id}}",
- "result": {},
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "result": {},
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -917,12 +954,12 @@ public void RequestResponse_StringId()
public void RequestResponse_NullId()
{
var json = """
- {
- "id": null,
- "result": {},
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "id": null,
+ "result": {},
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -935,13 +972,14 @@ public void RequestResponse_PrimitiveTypeResult()
{
var id = "123";
var result = 123;
- var json = $$"""
- {
- "id": "{{id}}",
- "result": {{result}},
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "result": {{result}},
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -957,15 +995,16 @@ public void RequestResponse_PrimitiveTypeArrayResult()
{
var id = "123";
var result = 123;
- var json = $$"""
- {
- "id": "{{id}}",
- "result": [
- {{result}}
- ],
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "result": [
+ {{result}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -983,15 +1022,16 @@ public void RequestResponse_ResultWithErrorField()
{
var id = "123";
var error = "errorValue";
- var json = $$"""
- {
- "id": "{{id}}",
- "result": {
- "error": "{{error}}"
- },
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "result": {
+ "error": "{{error}}"
+ },
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1007,13 +1047,14 @@ public void RequestResponse_ResultWithErrorField()
public void RequestResponse_PlainSnakeCaseObjectResult()
{
var id = "123";
- var json = $$"""
- {
- "id": "{{id}}",
- "result": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "result": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1029,13 +1070,14 @@ public void RequestResponse_PlainSnakeCaseObjectResult()
public void RequestResponse_PlainCamelCaseObjectResult()
{
var id = "123";
- var json = $$"""
- {
- "id": "{{id}}",
- "result": {{TestData.PlainRequiredCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "result": {{TestData.PlainRequiredCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1051,15 +1093,16 @@ public void RequestResponse_PlainCamelCaseObjectResult()
public void RequestResponse_PlainSnakeCaseArrayResult()
{
var id = "123";
- var json = $$"""
- {
- "id": "{{id}}",
- "result": [
- {{TestData.PlainRequiredSnakeCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "result": [
+ {{TestData.PlainRequiredSnakeCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1077,15 +1120,16 @@ public void RequestResponse_PlainSnakeCaseArrayResult()
public void RequestResponse_PlainCamelCaseArrayResult()
{
var id = "123";
- var json = $$"""
- {
- "id": "{{id}}",
- "result": [
- {{TestData.PlainRequiredCamelCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "result": [
+ {{TestData.PlainRequiredCamelCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1103,13 +1147,14 @@ public void RequestResponse_PlainCamelCaseArrayResult()
public void RequestResponse_NestedSnakeCaseObjectResult()
{
var id = "123";
- var json = $$"""
- {
- "id": "{{id}}",
- "result": {{TestData.NestedRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "result": {{TestData.NestedRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1125,13 +1170,14 @@ public void RequestResponse_NestedSnakeCaseObjectResult()
public void RequestResponse_NestedCamelCaseObjectResult()
{
var id = "123";
- var json = $$"""
- {
- "id": "{{id}}",
- "result": {{TestData.NestedRequiredCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "result": {{TestData.NestedRequiredCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1147,15 +1193,16 @@ public void RequestResponse_NestedCamelCaseObjectResult()
public void RequestResponse_NestedSnakeCaseArrayResult()
{
var id = "123";
- var json = $$"""
- {
- "id": "{{id}}",
- "result": [
- {{TestData.NestedRequiredSnakeCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "result": [
+ {{TestData.NestedRequiredSnakeCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1173,15 +1220,16 @@ public void RequestResponse_NestedSnakeCaseArrayResult()
public void RequestResponse_NestedCamelCaseArrayResult()
{
var id = "123";
- var json = $$"""
- {
- "id": "{{id}}",
- "result": [
- {{TestData.NestedRequiredCamelCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "result": [
+ {{TestData.NestedRequiredCamelCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1201,17 +1249,18 @@ public void RequestResponse_EmptyObjectErrorData()
var id = "123";
var errorCode = 123;
var errorMessage = "errorMessage";
- var json = $$"""
- {
- "id": "{{id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": {}
- },
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": {}
+ },
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1229,17 +1278,18 @@ public void RequestResponse_EmptyArrayErrorData()
var id = "123";
var errorCode = 123;
var errorMessage = "errorMessage";
- var json = $$"""
- {
- "id": "{{id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": []
- },
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": []
+ },
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1259,17 +1309,18 @@ public void RequestResponse_NullErrorData()
var id = "123";
var errorCode = 123;
var errorMessage = "errorMessage";
- var json = $$"""
- {
- "id": "{{id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": null
- },
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": null
+ },
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1286,16 +1337,17 @@ public void RequestResponse_NoErrorData()
var id = "123";
var errorCode = 123;
var errorMessage = "errorMessage";
- var json = $$"""
- {
- "id": "{{id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}"
- },
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}"
+ },
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1313,17 +1365,18 @@ public void RequestResponse_PrimitiveTypeErrorData()
var errorCode = 123;
var errorMessage = "errorMessage";
var errorData = 123;
- var json = $$"""
- {
- "id": "{{id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": {{errorData}}
- },
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": {{errorData}}
+ },
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1342,19 +1395,20 @@ public void RequestResponse_PrimitiveTypeArrayErrorData()
var errorCode = 123;
var errorMessage = "errorMessage";
var errorData = 123;
- var json = $$"""
- {
- "id": "{{id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": [
- {{errorData}}
- ]
- },
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": [
+ {{errorData}}
+ ]
+ },
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1375,19 +1429,20 @@ public void RequestResponse_ErrorDataWithResultField()
var errorCode = 123;
var errorMessage = "errorMessage";
var result = "resultValue";
- var json = $$"""
- {
- "id": "{{id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": {
- "result": "{{result}}"
- }
- },
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": {
+ "result": "{{result}}"
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1406,17 +1461,18 @@ public void RequestResponse_PlainSnakeCaseObjectErrorData()
var id = "123";
var errorCode = 123;
var errorMessage = "errorMessage";
- var json = $$"""
- {
- "id": "{{id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": {{TestData.PlainRequiredSnakeCaseJson}}
- },
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": {{TestData.PlainRequiredSnakeCaseJson}}
+ },
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1435,17 +1491,18 @@ public void RequestResponse_PlainCamelCaseObjectErrorData()
var id = "123";
var errorCode = 123;
var errorMessage = "errorMessage";
- var json = $$"""
- {
- "id": "{{id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": {{TestData.PlainRequiredCamelCaseJson}}
- },
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": {{TestData.PlainRequiredCamelCaseJson}}
+ },
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1464,19 +1521,20 @@ public void RequestResponse_PlainSnakeCaseArrayErrorData()
var id = "123";
var errorCode = 123;
var errorMessage = "errorMessage";
- var json = $$"""
- {
- "id": "{{id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": [
- {{TestData.PlainRequiredSnakeCaseJson}}
- ]
- },
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": [
+ {{TestData.PlainRequiredSnakeCaseJson}}
+ ]
+ },
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1497,19 +1555,20 @@ public void RequestResponse_PlainCamelCaseArrayErrorData()
var id = "123";
var errorCode = 123;
var errorMessage = "errorMessage";
- var json = $$"""
- {
- "id": "{{id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": [
- {{TestData.PlainRequiredCamelCaseJson}}
- ]
- },
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": [
+ {{TestData.PlainRequiredCamelCaseJson}}
+ ]
+ },
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1530,17 +1589,18 @@ public void RequestResponse_NestedSnakeCaseObjectErrorData()
var id = "123";
var errorCode = 123;
var errorMessage = "errorMessage";
- var json = $$"""
- {
- "id": "{{id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": {{TestData.NestedRequiredSnakeCaseJson}}
- },
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": {{TestData.NestedRequiredSnakeCaseJson}}
+ },
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1559,17 +1619,18 @@ public void RequestResponse_NestedCamelCaseObjectErrorData()
var id = "123";
var errorCode = 123;
var errorMessage = "errorMessage";
- var json = $$"""
- {
- "id": "{{id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": {{TestData.NestedRequiredCamelCaseJson}}
- },
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": {{TestData.NestedRequiredCamelCaseJson}}
+ },
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1588,19 +1649,20 @@ public void RequestResponse_NestedSnakeCaseArrayErrorData()
var id = "123";
var errorCode = 123;
var errorMessage = "errorMessage";
- var json = $$"""
- {
- "id": "{{id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": [
- {{TestData.NestedRequiredSnakeCaseJson}}
- ]
- },
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": [
+ {{TestData.NestedRequiredSnakeCaseJson}}
+ ]
+ },
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1621,19 +1683,20 @@ public void RequestResponse_NestedCamelCaseArrayErrorData()
var id = "123";
var errorCode = 123;
var errorMessage = "errorMessage";
- var json = $$"""
- {
- "id": "{{id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": [
- {{TestData.NestedRequiredCamelCaseJson}}
- ]
- },
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": [
+ {{TestData.NestedRequiredCamelCaseJson}}
+ ]
+ },
+ "jsonrpc": "2.0"
+ }
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1652,12 +1715,13 @@ public void RequestResponse_NestedCamelCaseArrayErrorData()
public void RequestResponse_NeitherResultNorError_ThrowJsonRpcFormatException()
{
var id = "123";
- var json = $$"""
- {
- "id": "{{id}}",
- "jsonrpc": "2.0"
- }
- """;
+ var json =
+ $$"""
+ {
+ "id": "{{id}}",
+ "jsonrpc": "2.0"
+ }
+ """;
var act = () => JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1668,11 +1732,11 @@ public void RequestResponse_NeitherResultNorError_ThrowJsonRpcFormatException()
public void RequestResponse_NoId_ThrowJsonRpcFormatException()
{
var json = """
- {
- "result": {},
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "result": {},
+ "jsonrpc": "2.0"
+ }
+ """;
var act = () => JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1683,8 +1747,8 @@ public void RequestResponse_NoId_ThrowJsonRpcFormatException()
public void RequestResponse_RootElementNotObject_ThrowJsonRpcFormatException()
{
var json = """
- 123
- """;
+ 123
+ """;
var act = () => JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1695,12 +1759,12 @@ public void RequestResponse_RootElementNotObject_ThrowJsonRpcFormatException()
public void RequestResponse_UnsupportedIdType_ThrowJsonRpcFormatException()
{
var json = """
- {
- "id": {},
- "jsonrpc": "2.0",
- "result": {}
- }
- """;
+ {
+ "id": {},
+ "jsonrpc": "2.0",
+ "result": {}
+ }
+ """;
var act = () => JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1715,15 +1779,16 @@ public void RequestResponse_UnsupportedIdType_ThrowJsonRpcFormatException()
public void Batch_1Notification()
{
var method = "method";
- var json = $$"""
- [
- {
- "method": "{{method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ var json =
+ $$"""
+ [
+ {
+ "method": "{{method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1742,20 +1807,21 @@ public void Batch_OnlyNotifications()
{
var method1 = "method1";
var method2 = "method2";
- var json = $$"""
- [
- {
- "method": "{{method1}}",
- "params": {},
- "jsonrpc": "2.0"
- },
- {
- "method": "{{method2}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ var json =
+ $$"""
+ [
+ {
+ "method": "{{method1}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "{{method2}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1775,16 +1841,17 @@ public void Batch_1Request()
{
var id = "123";
var method = "method";
- var json = $$"""
- [
- {
- "id": "{{id}}",
- "method": "{{method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ var json =
+ $$"""
+ [
+ {
+ "id": "{{id}}",
+ "method": "{{method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1805,22 +1872,23 @@ public void Batch_OnlyRequests()
var id2 = "456";
var method1 = "method1";
var method2 = "method2";
- var json = $$"""
- [
- {
- "id": "{{id1}}",
- "method": "{{method1}}",
- "params": {},
- "jsonrpc": "2.0"
- },
- {
- "id": "{{id2}}",
- "method": "{{method2}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ var json =
+ $$"""
+ [
+ {
+ "id": "{{id1}}",
+ "method": "{{method1}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "{{id2}}",
+ "method": "{{method2}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1841,21 +1909,22 @@ public void Batch_NotificationsAndRequests()
var id1 = "123";
var method1 = "method1";
var method2 = "method2";
- var json = $$"""
- [
- {
- "id": "{{id1}}",
- "method": "{{method1}}",
- "params": {},
- "jsonrpc": "2.0"
- },
- {
- "method": "{{method2}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ var json =
+ $$"""
+ [
+ {
+ "id": "{{id1}}",
+ "method": "{{method1}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "{{method2}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1878,15 +1947,16 @@ public void Batch_NotificationsAndRequests()
public void BatchResponse_1Response()
{
var id = "123";
- var json = $$"""
- [
- {
- "id": "{{id}}",
- "result": {},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ var json =
+ $$"""
+ [
+ {
+ "id": "{{id}}",
+ "result": {},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1903,20 +1973,21 @@ public void BatchResponse_OnlyResponses()
{
var id1 = "123";
var id2 = "546";
- var json = $$"""
- [
- {
- "id": "{{id1}}",
- "result": {},
- "jsonrpc": "2.0"
- },
- {
- "id": "{{id2}}",
- "result": {},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ var json =
+ $$"""
+ [
+ {
+ "id": "{{id1}}",
+ "result": {},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "{{id2}}",
+ "result": {},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1935,18 +2006,19 @@ public void BatchResponse_1Error()
var id = "123";
var errorCode = 123;
var errorMessage = "errorMessage";
- var json = $$"""
- [
- {
- "id": "{{id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}"
- },
- "jsonrpc": "2.0"
- }
- ]
- """;
+ var json =
+ $$"""
+ [
+ {
+ "id": "{{id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}"
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -1965,26 +2037,27 @@ public void BatchResponse_OnlyErrors()
var id2 = "456";
var errorCode = 123;
var errorMessage = "errorMessage";
- var json = $$"""
- [
- {
- "id": "{{id1}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}"
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "{{id2}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}"
- },
- "jsonrpc": "2.0"
- }
- ]
- """;
+ var json =
+ $$"""
+ [
+ {
+ "id": "{{id1}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}"
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "{{id2}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}"
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
@@ -2004,23 +2077,24 @@ public void BatchResponse_ResponseAndError()
var id2 = "456";
var errorCode = 123;
var errorMessage = "errorMessage";
- var json = $$"""
- [
- {
- "id": "{{id1}}",
- "result": {},
- "jsonrpc": "2.0"
- },
- {
- "id": "{{id2}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}"
- },
- "jsonrpc": "2.0"
- }
- ]
- """;
+ var json =
+ $$"""
+ [
+ {
+ "id": "{{id1}}",
+ "result": {},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "{{id2}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}"
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var deserialized = JsonSerializer.Deserialize(json, headersJsonSerializerOptions);
diff --git a/src/tests/Tochka.JsonRpc.Common.Tests/SerializationTests.cs b/src/tests/Tochka.JsonRpc.Common.Tests/SerializationTests.cs
index 1d8d06c4..757b2dbd 100644
--- a/src/tests/Tochka.JsonRpc.Common.Tests/SerializationTests.cs
+++ b/src/tests/Tochka.JsonRpc.Common.Tests/SerializationTests.cs
@@ -32,13 +32,14 @@ public void Notification_EmptyObjectParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -51,13 +52,14 @@ public void Notification_EmptyArrayParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "method": "{{Method}}",
- "params": [],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "method": "{{Method}}",
+ "params": [],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -70,13 +72,14 @@ public void Notification_EmptyListParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "method": "{{Method}}",
- "params": [],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "method": "{{Method}}",
+ "params": [],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -87,13 +90,14 @@ public void Notification_NullParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "method": "{{Method}}",
- "params": null,
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "method": "{{Method}}",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -106,15 +110,16 @@ public void Notification_PrimitiveTypeArrayParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "method": "{{Method}}",
- "params": [
- {{data[0]}}
- ],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "method": "{{Method}}",
+ "params": [
+ {{data[0]}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -127,15 +132,16 @@ public void Notification_PrimitiveTypeListParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "method": "{{Method}}",
- "params": [
- {{data[0]}}
- ],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "method": "{{Method}}",
+ "params": [
+ {{data[0]}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -148,13 +154,14 @@ public void Notification_PlainSnakeCaseObjectParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "method": "{{Method}}",
- "params": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "method": "{{Method}}",
+ "params": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -167,13 +174,14 @@ public void Notification_PlainCamelCaseObjectParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "method": "{{Method}}",
- "params": {{TestData.PlainFullCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "method": "{{Method}}",
+ "params": {{TestData.PlainFullCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -186,15 +194,16 @@ public void Notification_PlainSnakeCaseArrayParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "method": "{{Method}}",
- "params": [
- {{TestData.PlainFullSnakeCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "method": "{{Method}}",
+ "params": [
+ {{TestData.PlainFullSnakeCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -207,15 +216,16 @@ public void Notification_PlainCamelCaseArrayParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "method": "{{Method}}",
- "params": [
- {{TestData.PlainFullCamelCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "method": "{{Method}}",
+ "params": [
+ {{TestData.PlainFullCamelCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -228,15 +238,16 @@ public void Notification_PlainSnakeCaseListParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "method": "{{Method}}",
- "params": [
- {{TestData.PlainFullSnakeCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "method": "{{Method}}",
+ "params": [
+ {{TestData.PlainFullSnakeCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -249,15 +260,16 @@ public void Notification_PlainCamelCaseListParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "method": "{{Method}}",
- "params": [
- {{TestData.PlainFullCamelCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "method": "{{Method}}",
+ "params": [
+ {{TestData.PlainFullCamelCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -270,13 +282,14 @@ public void Notification_NestedSnakeCaseObjectParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "method": "{{Method}}",
- "params": {{TestData.NestedFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "method": "{{Method}}",
+ "params": {{TestData.NestedFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -289,13 +302,14 @@ public void Notification_NestedCamelCaseObjectParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "method": "{{Method}}",
- "params": {{TestData.NestedFullCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "method": "{{Method}}",
+ "params": {{TestData.NestedFullCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -308,15 +322,16 @@ public void Notification_NestedSnakeCaseArrayParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "method": "{{Method}}",
- "params": [
- {{TestData.NestedFullSnakeCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "method": "{{Method}}",
+ "params": [
+ {{TestData.NestedFullSnakeCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -329,15 +344,16 @@ public void Notification_NestedCamelCaseArrayParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "method": "{{Method}}",
- "params": [
- {{TestData.NestedFullCamelCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "method": "{{Method}}",
+ "params": [
+ {{TestData.NestedFullCamelCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -350,15 +366,16 @@ public void Notification_NestedSnakeCaseListParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "method": "{{Method}}",
- "params": [
- {{TestData.NestedFullSnakeCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "method": "{{Method}}",
+ "params": [
+ {{TestData.NestedFullSnakeCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -371,15 +388,16 @@ public void Notification_NestedCamelCaseListParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "method": "{{Method}}",
- "params": [
- {{TestData.NestedFullCamelCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "method": "{{Method}}",
+ "params": [
+ {{TestData.NestedFullCamelCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -397,14 +415,15 @@ public void Request_EmptyObjectParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -418,14 +437,15 @@ public void Request_EmptyArrayParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": [],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": [],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -439,14 +459,15 @@ public void Request_EmptyListParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": [],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": [],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -458,14 +479,15 @@ public void Request_NullParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": null,
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -477,14 +499,15 @@ public void Request_IntId()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": {{id}},
- "method": "{{Method}}",
- "params": null,
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": {{id}},
+ "method": "{{Method}}",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -496,14 +519,15 @@ public void Request_StringId()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": null,
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -514,14 +538,15 @@ public void Request_NullId()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": null,
- "method": "{{Method}}",
- "params": null,
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": null,
+ "method": "{{Method}}",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -535,16 +560,17 @@ public void Request_PrimitiveTypeArrayParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": [
- {{data[0]}}
- ],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": [
+ {{data[0]}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -558,16 +584,17 @@ public void Request_PrimitiveTypeListParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": [
- {{data[0]}}
- ],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": [
+ {{data[0]}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -581,14 +608,15 @@ public void Request_PlainSnakeCaseObjectParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -602,14 +630,15 @@ public void Request_PlainCamelCaseObjectParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {{TestData.PlainFullCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {{TestData.PlainFullCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -623,16 +652,17 @@ public void Request_PlainSnakeCaseArrayParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": [
- {{TestData.PlainFullSnakeCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": [
+ {{TestData.PlainFullSnakeCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -646,16 +676,17 @@ public void Request_PlainCamelCaseArrayParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": [
- {{TestData.PlainFullCamelCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": [
+ {{TestData.PlainFullCamelCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -669,16 +700,17 @@ public void Request_PlainSnakeCaseListParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": [
- {{TestData.PlainFullSnakeCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": [
+ {{TestData.PlainFullSnakeCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -692,16 +724,17 @@ public void Request_PlainCamelCaseListParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": [
- {{TestData.PlainFullCamelCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": [
+ {{TestData.PlainFullCamelCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -715,14 +748,15 @@ public void Request_NestedSnakeCaseObjectParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {{TestData.NestedFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {{TestData.NestedFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -736,14 +770,15 @@ public void Request_NestedCamelCaseObjectParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {{TestData.NestedFullCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {{TestData.NestedFullCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -757,16 +792,17 @@ public void Request_NestedSnakeCaseArrayParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": [
- {{TestData.NestedFullSnakeCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": [
+ {{TestData.NestedFullSnakeCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -780,16 +816,17 @@ public void Request_NestedCamelCaseArrayParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": [
- {{TestData.NestedFullCamelCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": [
+ {{TestData.NestedFullCamelCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -803,16 +840,17 @@ public void Request_NestedSnakeCaseListParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": [
- {{TestData.NestedFullSnakeCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": [
+ {{TestData.NestedFullSnakeCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -826,16 +864,17 @@ public void Request_NestedCamelCaseListParams()
var serialized = JsonSerializer.Serialize(notification, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": [
- {{TestData.NestedFullCamelCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": [
+ {{TestData.NestedFullCamelCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -852,13 +891,14 @@ public void RequestResponse_EmptyObjectResult()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{Id}}",
- "result": {},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{Id}}",
+ "result": {},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -871,13 +911,14 @@ public void RequestResponse_EmptyArrayResult()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{Id}}",
- "result": [],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{Id}}",
+ "result": [],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -888,13 +929,14 @@ public void RequestResponse_NullResult()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{Id}}",
- "result": null,
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{Id}}",
+ "result": null,
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -908,13 +950,14 @@ public void RequestResponse_IntId()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": {{id}},
- "result": {},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": {{id}},
+ "result": {},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -928,13 +971,14 @@ public void RequestResponse_StringId()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{id}}",
- "result": {},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{id}}",
+ "result": {},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -948,12 +992,12 @@ public void RequestResponse_NullId()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
var expected = """
- {
- "id": null,
- "result": {},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ {
+ "id": null,
+ "result": {},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -966,13 +1010,14 @@ public void RequestResponse_PrimitiveTypeResult()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{Id}}",
- "result": {{data}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{Id}}",
+ "result": {{data}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -985,15 +1030,16 @@ public void RequestResponse_PrimitiveTypeArrayResult()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{Id}}",
- "result": [
- {{data[0]}}
- ],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{Id}}",
+ "result": [
+ {{data[0]}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1007,15 +1053,16 @@ public void RequestResponse_ResultWithErrorField()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{Id}}",
- "result": {
- "error": "{{error}}"
- },
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{Id}}",
+ "result": {
+ "error": "{{error}}"
+ },
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1028,13 +1075,14 @@ public void RequestResponse_PlainSnakeCaseObjectResult()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{Id}}",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{Id}}",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1047,13 +1095,14 @@ public void RequestResponse_PlainCamelCaseObjectResult()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{Id}}",
- "result": {{TestData.PlainFullCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{Id}}",
+ "result": {{TestData.PlainFullCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1066,15 +1115,16 @@ public void RequestResponse_PlainSnakeCaseArrayResult()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{Id}}",
- "result": [
- {{TestData.PlainFullSnakeCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{Id}}",
+ "result": [
+ {{TestData.PlainFullSnakeCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1087,15 +1137,16 @@ public void RequestResponse_PlainCamelCaseArrayResult()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{Id}}",
- "result": [
- {{TestData.PlainFullCamelCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{Id}}",
+ "result": [
+ {{TestData.PlainFullCamelCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1108,13 +1159,14 @@ public void RequestResponse_NestedSnakeCaseObjectResult()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{Id}}",
- "result": {{TestData.NestedFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{Id}}",
+ "result": {{TestData.NestedFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1127,13 +1179,14 @@ public void RequestResponse_NestedCamelCaseObjectResult()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{Id}}",
- "result": {{TestData.NestedFullCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{Id}}",
+ "result": {{TestData.NestedFullCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1146,15 +1199,16 @@ public void RequestResponse_NestedSnakeCaseArrayResult()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{Id}}",
- "result": [
- {{TestData.NestedFullSnakeCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{Id}}",
+ "result": [
+ {{TestData.NestedFullSnakeCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1167,15 +1221,16 @@ public void RequestResponse_NestedCamelCaseArrayResult()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{Id}}",
- "result": [
- {{TestData.NestedFullCamelCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{Id}}",
+ "result": [
+ {{TestData.NestedFullCamelCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1191,17 +1246,18 @@ public void RequestResponse_EmptyObjectErrorData()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{Id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": {}
- },
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{Id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": {}
+ },
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1217,17 +1273,18 @@ public void RequestResponse_EmptyArrayErrorData()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{Id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": []
- },
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{Id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": []
+ },
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1241,17 +1298,18 @@ public void RequestResponse_NullErrorData()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{Id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": null
- },
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{Id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": null
+ },
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1267,17 +1325,18 @@ public void RequestResponse_PrimitiveTypeErrorData()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{Id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": {{data}}
- },
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{Id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": {{data}}
+ },
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1293,19 +1352,20 @@ public void RequestResponse_PrimitiveTypeArrayErrorData()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{Id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": [
- {{data[0]}}
- ]
- },
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{Id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": [
+ {{data[0]}}
+ ]
+ },
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1322,19 +1382,20 @@ public void RequestResponse_ErrorDataWithResultField()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{Id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": {
- "result": "{{result}}"
- }
- },
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{Id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": {
+ "result": "{{result}}"
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1350,17 +1411,18 @@ public void RequestResponse_PlainSnakeCaseObjectErrorData()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{Id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": {{TestData.PlainFullSnakeCaseJson}}
- },
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{Id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": {{TestData.PlainFullSnakeCaseJson}}
+ },
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1376,17 +1438,18 @@ public void RequestResponse_PlainCamelCaseObjectErrorData()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{Id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": {{TestData.PlainFullCamelCaseJson}}
- },
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{Id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": {{TestData.PlainFullCamelCaseJson}}
+ },
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1402,19 +1465,20 @@ public void RequestResponse_PlainSnakeCaseArrayErrorData()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{Id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": [
- {{TestData.PlainFullSnakeCaseJson}}
- ]
- },
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{Id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": [
+ {{TestData.PlainFullSnakeCaseJson}}
+ ]
+ },
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1430,19 +1494,20 @@ public void RequestResponse_PlainCamelCaseArrayErrorData()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{Id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": [
- {{TestData.PlainFullCamelCaseJson}}
- ]
- },
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{Id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": [
+ {{TestData.PlainFullCamelCaseJson}}
+ ]
+ },
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1458,17 +1523,18 @@ public void RequestResponse_NestedSnakeCaseObjectErrorData()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{Id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": {{TestData.NestedFullSnakeCaseJson}}
- },
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{Id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": {{TestData.NestedFullSnakeCaseJson}}
+ },
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1484,17 +1550,18 @@ public void RequestResponse_NestedCamelCaseObjectErrorData()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{Id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": {{TestData.NestedFullCamelCaseJson}}
- },
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{Id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": {{TestData.NestedFullCamelCaseJson}}
+ },
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1510,19 +1577,20 @@ public void RequestResponse_NestedSnakeCaseArrayErrorData()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{Id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": [
- {{TestData.NestedFullSnakeCaseJson}}
- ]
- },
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{Id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": [
+ {{TestData.NestedFullSnakeCaseJson}}
+ ]
+ },
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1538,19 +1606,20 @@ public void RequestResponse_NestedCamelCaseArrayErrorData()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- {
- "id": "{{Id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": [
- {{TestData.NestedFullCamelCaseJson}}
- ]
- },
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expected =
+ $$"""
+ {
+ "id": "{{Id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": [
+ {{TestData.NestedFullCamelCaseJson}}
+ ]
+ },
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1570,15 +1639,16 @@ public void Batch_IEnumerable()
var serialized = JsonSerializer.Serialize(batch, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- [
- {
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expected =
+ $$"""
+ [
+ {
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1594,15 +1664,16 @@ public void Batch_List()
var serialized = JsonSerializer.Serialize(batch, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- [
- {
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expected =
+ $$"""
+ [
+ {
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1618,15 +1689,16 @@ public void Batch_Array()
var serialized = JsonSerializer.Serialize(batch, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- [
- {
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expected =
+ $$"""
+ [
+ {
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1642,15 +1714,16 @@ public void Batch_1Notification()
var serialized = JsonSerializer.Serialize(batch, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- [
- {
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expected =
+ $$"""
+ [
+ {
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1667,20 +1740,21 @@ public void Batch_OnlyNotifications()
var serialized = JsonSerializer.Serialize(batch, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- [
- {
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- },
- {
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expected =
+ $$"""
+ [
+ {
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1697,16 +1771,17 @@ public void Batch_1Request()
var serialized = JsonSerializer.Serialize(batch, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- [
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expected =
+ $$"""
+ [
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1725,22 +1800,23 @@ public void Batch_OnlyRequests()
var serialized = JsonSerializer.Serialize(batch, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- [
- {
- "id": "{{id1}}",
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- },
- {
- "id": "{{id2}}",
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expected =
+ $$"""
+ [
+ {
+ "id": "{{id1}}",
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "{{id2}}",
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1758,21 +1834,22 @@ public void Batch_NotificationAndRequest()
var serialized = JsonSerializer.Serialize(batch, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- [
- {
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- },
- {
- "id": "{{id}}",
- "method": "{{Method}}",
- "params": {},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expected =
+ $$"""
+ [
+ {
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "{{id}}",
+ "method": "{{Method}}",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1793,15 +1870,16 @@ public void BatchResponse_1Response()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- [
- {
- "id": "{{Id}}",
- "result": {},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expected =
+ $$"""
+ [
+ {
+ "id": "{{Id}}",
+ "result": {},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1821,20 +1899,21 @@ public void BatchResponse_OnlyResponses()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- [
- {
- "id": "{{id1}}",
- "result": {},
- "jsonrpc": "2.0"
- },
- {
- "id": "{{id2}}",
- "result": {},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expected =
+ $$"""
+ [
+ {
+ "id": "{{id1}}",
+ "result": {},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "{{id2}}",
+ "result": {},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1854,19 +1933,20 @@ public void BatchResponse_1Error()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- [
- {
- "id": "{{Id}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": {}
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expected =
+ $$"""
+ [
+ {
+ "id": "{{Id}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": {}
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1889,28 +1969,29 @@ public void BatchResponse_OnlyErrors()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- [
- {
- "id": "{{id1}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": {}
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "{{id2}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": {}
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expected =
+ $$"""
+ [
+ {
+ "id": "{{id1}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": {}
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "{{id2}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": {}
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
@@ -1933,24 +2014,25 @@ public void BatchResponse_ResponseAndError()
var serialized = JsonSerializer.Serialize(response, headersJsonSerializerOptions).TrimAllLines();
- var expected = $$"""
- [
- {
- "id": "{{id1}}",
- "result": {},
- "jsonrpc": "2.0"
- },
- {
- "id": "{{id2}}",
- "error": {
- "code": {{errorCode}},
- "message": "{{errorMessage}}",
- "data": {}
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expected =
+ $$"""
+ [
+ {
+ "id": "{{id1}}",
+ "result": {},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "{{id2}}",
+ "error": {
+ "code": {{errorCode}},
+ "message": "{{errorMessage}}",
+ "data": {}
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
serialized.Should().Be(expected);
}
diff --git a/src/tests/Tochka.JsonRpc.Common.Tests/UtilsTests.cs b/src/tests/Tochka.JsonRpc.Common.Tests/UtilsTests.cs
index 6acdc16a..3120d8da 100644
--- a/src/tests/Tochka.JsonRpc.Common.Tests/UtilsTests.cs
+++ b/src/tests/Tochka.JsonRpc.Common.Tests/UtilsTests.cs
@@ -137,14 +137,15 @@ public void GetPropertyNames_ReturnsOnlyTopLevelProperties()
{
const string property1 = "prop1";
const string property2 = "prop2";
- var json = $$"""
- {
- "{{property1}}": "value1",
- "{{property2}}": {
- "prop3": "value3"
- }
- }
- """;
+ var json =
+ $$"""
+ {
+ "{{property1}}": "value1",
+ "{{property2}}": {
+ "prop3": "value3"
+ }
+ }
+ """;
var reader = new Utf8JsonReader(Encoding.UTF8.GetBytes(json));
reader.Read();
@@ -158,17 +159,18 @@ public void GetPropertyNames_ReturnsOnlyCurrentObjectProperties()
{
const string property1 = "prop1";
const string property2 = "prop2";
- var json = $$"""
- [
- {
- "{{property1}}": "value1",
- "{{property2}}": "value2"
- },
- {
- "prop3": "value3"
- }
- ]
- """;
+ var json =
+ $$"""
+ [
+ {
+ "{{property1}}": "value1",
+ "{{property2}}": "value2"
+ },
+ {
+ "prop3": "value3"
+ }
+ ]
+ """;
var reader = new Utf8JsonReader(Encoding.UTF8.GetBytes(json));
reader.Read(); // to start reading properties from '{'
reader.Read();
diff --git a/src/tests/Tochka.JsonRpc.OpenRpc.Tests/Services/OpenRpcSchemaGeneratorTests.cs b/src/tests/Tochka.JsonRpc.OpenRpc.Tests/Services/OpenRpcSchemaGeneratorTests.cs
index 19b871d3..0bf45525 100644
--- a/src/tests/Tochka.JsonRpc.OpenRpc.Tests/Services/OpenRpcSchemaGeneratorTests.cs
+++ b/src/tests/Tochka.JsonRpc.OpenRpc.Tests/Services/OpenRpcSchemaGeneratorTests.cs
@@ -158,14 +158,14 @@ public void CreateOrRef_NullableEnum_ReturnRef()
var expectedTypeName = $"{MethodName} {nameof(Enum)}";
var expectedSchema = new JsonSchemaBuilder()
- .Ref($"#/components/schemas/{expectedTypeName}")
- .BuildWithoutUri();
+ .Ref($"#/components/schemas/{expectedTypeName}")
+ .BuildWithoutUri();
result.Should().BeEquivalentTo(expectedSchema);
var expectedRegistrations = new Dictionary
{
[expectedTypeName] = new JsonSchemaBuilder()
- .Enum("one", "two")
- .BuildWithoutUri()
+ .Enum("one", "two")
+ .BuildWithoutUri()
};
schemaGenerator.GetAllSchemas().Should().BeEquivalentTo(expectedRegistrations);
}
@@ -395,14 +395,14 @@ public void CreateOrRef_EnumValuesFormatedAsDeclared()
var expectedTypeName = $"{MethodName} {nameof(Enum2)}";
var expectedSchema = new JsonSchemaBuilder()
- .Ref($"#/components/schemas/{expectedTypeName}")
- .BuildWithoutUri();
+ .Ref($"#/components/schemas/{expectedTypeName}")
+ .BuildWithoutUri();
actualSchema.Should().BeEquivalentTo(expectedSchema);
var expectedRegistrations = new Dictionary
{
[expectedTypeName] = new JsonSchemaBuilder()
- .Enum("Value1", "ValueValue2", "value3", "value_value4")
- .BuildWithoutUri()
+ .Enum("Value1", "ValueValue2", "value3", "value_value4")
+ .BuildWithoutUri()
};
schemaGenerator.GetAllSchemas().Should().BeEquivalentTo(expectedRegistrations);
}
@@ -417,24 +417,24 @@ public void CreateOrRef_DefaultSimpleTypesFormattedAsString()
var expectedTypeName = $"{MethodName} {nameof(TypeWithSimpleProperties)}";
var expectedSchema = new JsonSchemaBuilder()
- .Ref($"#/components/schemas/{expectedTypeName}")
- .BuildWithoutUri();
+ .Ref($"#/components/schemas/{expectedTypeName}")
+ .BuildWithoutUri();
actualSchema.Should().BeEquivalentTo(expectedSchema);
var expectedRegistrations = new Dictionary
{
[expectedTypeName] = new JsonSchemaBuilder()
- .Type(SchemaValueType.Object)
- .Properties(new Dictionary
- {
- ["date_time"] = new JsonSchemaBuilder().Type(SchemaValueType.String).Format(Formats.DateTime).BuildWithoutUri(),
- ["date_time_offset"] = new JsonSchemaBuilder().Type(SchemaValueType.String).Format(Formats.DateTime).BuildWithoutUri(),
- ["date_only"] = new JsonSchemaBuilder().Type(SchemaValueType.String).Format(Formats.Date).BuildWithoutUri(),
- ["time_only"] = new JsonSchemaBuilder().Type(SchemaValueType.String).Format(Formats.Time).BuildWithoutUri(),
- ["time_span"] = new JsonSchemaBuilder().Type(SchemaValueType.String).Format(Formats.Duration).BuildWithoutUri(),
- ["guid"] = new JsonSchemaBuilder().Type(SchemaValueType.String).Format(Formats.Uuid).BuildWithoutUri()
- })
- .Required("date_time", "date_time_offset", "date_only", "time_only", "time_span", "guid")
- .BuildWithoutUri()
+ .Type(SchemaValueType.Object)
+ .Properties(new Dictionary
+ {
+ ["date_time"] = new JsonSchemaBuilder().Type(SchemaValueType.String).Format(Formats.DateTime).BuildWithoutUri(),
+ ["date_time_offset"] = new JsonSchemaBuilder().Type(SchemaValueType.String).Format(Formats.DateTime).BuildWithoutUri(),
+ ["date_only"] = new JsonSchemaBuilder().Type(SchemaValueType.String).Format(Formats.Date).BuildWithoutUri(),
+ ["time_only"] = new JsonSchemaBuilder().Type(SchemaValueType.String).Format(Formats.Time).BuildWithoutUri(),
+ ["time_span"] = new JsonSchemaBuilder().Type(SchemaValueType.String).Format(Formats.Duration).BuildWithoutUri(),
+ ["guid"] = new JsonSchemaBuilder().Type(SchemaValueType.String).Format(Formats.Uuid).BuildWithoutUri()
+ })
+ .Required("date_time", "date_time_offset", "date_only", "time_only", "time_span", "guid")
+ .BuildWithoutUri()
};
schemaGenerator.GetAllSchemas().Should().BeEquivalentTo(expectedRegistrations);
}
@@ -451,52 +451,53 @@ public void CreateOrRef_SummariesFromResultObjectPropertiesCollectedAsTitlesOnJs
var expectedTypeNameInner = $"{MethodName} {nameof(TypeWithSummariesInner)}";
var expectedTypeNameInnerEnum = $"{MethodName} {nameof(TypeWithSummariesInnerEnum)}";
- actualSchema.Should().BeEquivalentTo(new JsonSchemaBuilder()
- .Ref($"#/components/schemas/{expectedTypeName}")
- .BuildWithoutUri());
+ actualSchema.Should()
+ .BeEquivalentTo(new JsonSchemaBuilder()
+ .Ref($"#/components/schemas/{expectedTypeName}")
+ .BuildWithoutUri());
var actualSchemas = schemaGenerator.GetAllSchemas();
var expectedSchemas = new Dictionary
{
[expectedTypeNameInner] = new JsonSchemaBuilder()
- .Type(SchemaValueType.Object)
- .Properties(new Dictionary
- {
- ["inner_prop1"] = new JsonSchemaBuilder().Type(SchemaValueType.String)
- .Title("InnerProp1")
- .BuildWithoutUri()
- })
- .Required("inner_prop1")
- .BuildWithoutUri(),
+ .Type(SchemaValueType.Object)
+ .Properties(new Dictionary
+ {
+ ["inner_prop1"] = new JsonSchemaBuilder().Type(SchemaValueType.String)
+ .Title("InnerProp1")
+ .BuildWithoutUri()
+ })
+ .Required("inner_prop1")
+ .BuildWithoutUri(),
[expectedTypeNameInnerEnum] = new JsonSchemaBuilder()
- .Enum("bla")
- .BuildWithoutUri(),
+ .Enum("bla")
+ .BuildWithoutUri(),
[expectedTypeName] = new JsonSchemaBuilder()
- .Type(SchemaValueType.Object)
- .Properties(new Dictionary
- {
- ["prop1"] = new JsonSchemaBuilder().Ref($"#/components/schemas/{expectedTypeNameInner}")
- .Title("Prop1")
- .BuildWithoutUri(),
- ["prop2"] = new JsonSchemaBuilder().Ref($"#/components/schemas/{expectedTypeNameInner}")
- .Title("Prop2")
- .BuildWithoutUri(),
- ["prop3"] = new JsonSchemaBuilder().Type(SchemaValueType.Array)
- .Items(new JsonSchemaBuilder().Ref($"#/components/schemas/{expectedTypeNameInner}")
- .BuildWithoutUri())
- .Title("Prop3")
- .BuildWithoutUri(),
- ["prop4"] = new JsonSchemaBuilder().Ref($"#/components/schemas/{expectedTypeNameInnerEnum}")
- .Title("Prop4")
- .BuildWithoutUri(),
- ["prop5"] = new JsonSchemaBuilder().Type(SchemaValueType.String)
- .Format(Formats.Duration)
- .Title("Prop5")
- .BuildWithoutUri()
- })
- .Required("prop1", "prop2", "prop3", "prop4", "prop5")
- .BuildWithoutUri(),
+ .Type(SchemaValueType.Object)
+ .Properties(new Dictionary
+ {
+ ["prop1"] = new JsonSchemaBuilder().Ref($"#/components/schemas/{expectedTypeNameInner}")
+ .Title("Prop1")
+ .BuildWithoutUri(),
+ ["prop2"] = new JsonSchemaBuilder().Ref($"#/components/schemas/{expectedTypeNameInner}")
+ .Title("Prop2")
+ .BuildWithoutUri(),
+ ["prop3"] = new JsonSchemaBuilder().Type(SchemaValueType.Array)
+ .Items(new JsonSchemaBuilder().Ref($"#/components/schemas/{expectedTypeNameInner}")
+ .BuildWithoutUri())
+ .Title("Prop3")
+ .BuildWithoutUri(),
+ ["prop4"] = new JsonSchemaBuilder().Ref($"#/components/schemas/{expectedTypeNameInnerEnum}")
+ .Title("Prop4")
+ .BuildWithoutUri(),
+ ["prop5"] = new JsonSchemaBuilder().Type(SchemaValueType.String)
+ .Format(Formats.Duration)
+ .Title("Prop5")
+ .BuildWithoutUri()
+ })
+ .Required("prop1", "prop2", "prop3", "prop4", "prop5")
+ .BuildWithoutUri()
};
actualSchemas.Count.Should().Be(expectedSchemas.Count);
@@ -550,51 +551,51 @@ public void CreateOrRef_TypeWithGenericPropertyParsedCorrectly_OneTypeArgument()
var expectedSecondEnumTypeName = $"{MethodName} {nameof(TypeWithGenericPropertiesSecondEnum)}";
var expectedSchema = new JsonSchemaBuilder()
- .Ref($"#/components/schemas/{expectedParentTypeName}")
- .BuildWithoutUri();
+ .Ref($"#/components/schemas/{expectedParentTypeName}")
+ .BuildWithoutUri();
actualSchema.Should().BeEquivalentTo(expectedSchema);
var expectedRegistrations = new Dictionary
{
[expectedFirstEnumTypeName] = new JsonSchemaBuilder()
- .Enum("type_with_generic_properties_first_enum")
- .BuildWithoutUri(),
+ .Enum("type_with_generic_properties_first_enum")
+ .BuildWithoutUri(),
[expectedSecondEnumTypeName] = new JsonSchemaBuilder()
- .Enum("type_with_generic_properties_second_enum")
- .BuildWithoutUri(),
+ .Enum("type_with_generic_properties_second_enum")
+ .BuildWithoutUri(),
[expectedProperty1Name] = new JsonSchemaBuilder()
- .Type(SchemaValueType.Object)
- .Properties(new Dictionary
- {
- ["generic_property"] = new JsonSchemaBuilder()
- .Ref($"#/components/schemas/{expectedFirstEnumTypeName}")
- .BuildWithoutUri()
- })
- .Required("generic_property")
- .BuildWithoutUri(),
+ .Type(SchemaValueType.Object)
+ .Properties(new Dictionary
+ {
+ ["generic_property"] = new JsonSchemaBuilder()
+ .Ref($"#/components/schemas/{expectedFirstEnumTypeName}")
+ .BuildWithoutUri()
+ })
+ .Required("generic_property")
+ .BuildWithoutUri(),
[expectedProperty2Name] = new JsonSchemaBuilder()
- .Type(SchemaValueType.Object)
- .Properties(new Dictionary
- {
- ["generic_property"] = new JsonSchemaBuilder()
- .Ref($"#/components/schemas/{expectedSecondEnumTypeName}")
- .BuildWithoutUri()
- })
- .BuildWithoutUri(),
+ .Type(SchemaValueType.Object)
+ .Properties(new Dictionary
+ {
+ ["generic_property"] = new JsonSchemaBuilder()
+ .Ref($"#/components/schemas/{expectedSecondEnumTypeName}")
+ .BuildWithoutUri()
+ })
+ .BuildWithoutUri(),
[expectedParentTypeName] = new JsonSchemaBuilder()
- .Type(SchemaValueType.Object)
- .Properties(new Dictionary
- {
- ["property1"] = new JsonSchemaBuilder()
- .Ref($"#/components/schemas/{expectedProperty1Name}")
- .BuildWithoutUri(),
- ["property2"] = new JsonSchemaBuilder()
- .Ref($"#/components/schemas/{expectedProperty2Name}")
- .BuildWithoutUri()
- })
- .Required("property1", "property2")
- .BuildWithoutUri()
+ .Type(SchemaValueType.Object)
+ .Properties(new Dictionary
+ {
+ ["property1"] = new JsonSchemaBuilder()
+ .Ref($"#/components/schemas/{expectedProperty1Name}")
+ .BuildWithoutUri(),
+ ["property2"] = new JsonSchemaBuilder()
+ .Ref($"#/components/schemas/{expectedProperty2Name}")
+ .BuildWithoutUri()
+ })
+ .Required("property1", "property2")
+ .BuildWithoutUri()
};
schemaGenerator.GetAllSchemas().Should().BeEquivalentTo(expectedRegistrations);
}
@@ -614,51 +615,51 @@ public void CreateOrRef_TypeWithSomeNullableGenericPropertiesHasCorrectRequiredS
var expectedSecondEnumTypeName = $"{MethodName} {nameof(TypeWithGenericPropertiesSecondEnum)}";
var expectedSchema = new JsonSchemaBuilder()
- .Ref($"#/components/schemas/{expectedParentTypeName}")
- .BuildWithoutUri();
+ .Ref($"#/components/schemas/{expectedParentTypeName}")
+ .BuildWithoutUri();
actualSchema.Should().BeEquivalentTo(expectedSchema);
var expectedRegistrations = new Dictionary
{
[expectedFirstEnumTypeName] = new JsonSchemaBuilder()
- .Enum("type_with_generic_properties_first_enum")
- .BuildWithoutUri(),
+ .Enum("type_with_generic_properties_first_enum")
+ .BuildWithoutUri(),
[expectedSecondEnumTypeName] = new JsonSchemaBuilder()
- .Enum("type_with_generic_properties_second_enum")
- .BuildWithoutUri(),
+ .Enum("type_with_generic_properties_second_enum")
+ .BuildWithoutUri(),
[expectedProperty1Name] = new JsonSchemaBuilder()
- .Type(SchemaValueType.Object)
- .Properties(new Dictionary
- {
- ["generic_property"] = new JsonSchemaBuilder()
- .Ref($"#/components/schemas/{expectedFirstEnumTypeName}")
- .BuildWithoutUri()
- })
- .Required("generic_property")
- .BuildWithoutUri(),
+ .Type(SchemaValueType.Object)
+ .Properties(new Dictionary
+ {
+ ["generic_property"] = new JsonSchemaBuilder()
+ .Ref($"#/components/schemas/{expectedFirstEnumTypeName}")
+ .BuildWithoutUri()
+ })
+ .Required("generic_property")
+ .BuildWithoutUri(),
[expectedProperty2Name] = new JsonSchemaBuilder()
- .Type(SchemaValueType.Object)
- .Properties(new Dictionary
- {
- ["generic_property"] = new JsonSchemaBuilder()
- .Ref($"#/components/schemas/{expectedSecondEnumTypeName}")
- .BuildWithoutUri()
- })
- .BuildWithoutUri(),
+ .Type(SchemaValueType.Object)
+ .Properties(new Dictionary
+ {
+ ["generic_property"] = new JsonSchemaBuilder()
+ .Ref($"#/components/schemas/{expectedSecondEnumTypeName}")
+ .BuildWithoutUri()
+ })
+ .BuildWithoutUri(),
[expectedParentTypeName] = new JsonSchemaBuilder()
- .Type(SchemaValueType.Object)
- .Properties(new Dictionary
- {
- ["property1"] = new JsonSchemaBuilder()
- .Ref($"#/components/schemas/{expectedProperty1Name}")
- .BuildWithoutUri(),
- ["property2"] = new JsonSchemaBuilder()
- .Ref($"#/components/schemas/{expectedProperty2Name}")
- .BuildWithoutUri()
- })
- .Required("property2")
- .BuildWithoutUri()
+ .Type(SchemaValueType.Object)
+ .Properties(new Dictionary
+ {
+ ["property1"] = new JsonSchemaBuilder()
+ .Ref($"#/components/schemas/{expectedProperty1Name}")
+ .BuildWithoutUri(),
+ ["property2"] = new JsonSchemaBuilder()
+ .Ref($"#/components/schemas/{expectedProperty2Name}")
+ .BuildWithoutUri()
+ })
+ .Required("property2")
+ .BuildWithoutUri()
};
schemaGenerator.GetAllSchemas().Should().BeEquivalentTo(expectedRegistrations);
}
@@ -675,36 +676,36 @@ public void CreateOrRef_TypeWithGenericPropertyParsedCorrectly_TwoTypeArgument()
var expectedProperty1TypeName = $"{MethodName} GenericTwoType`2[String,Boolean]";
var expectedSchema = new JsonSchemaBuilder()
- .Ref($"#/components/schemas/{expectedParentTypeName}")
- .BuildWithoutUri();
+ .Ref($"#/components/schemas/{expectedParentTypeName}")
+ .BuildWithoutUri();
actualSchema.Should().BeEquivalentTo(expectedSchema);
var expectedRegistrations = new Dictionary
{
[expectedProperty1TypeName] = new JsonSchemaBuilder()
- .Type(SchemaValueType.Object)
- .Properties(new Dictionary
- {
- ["generic_property1"] = new JsonSchemaBuilder()
- .Type(SchemaValueType.String)
- .BuildWithoutUri(),
- ["generic_property2"] = new JsonSchemaBuilder()
- .Type(SchemaValueType.Boolean)
- .BuildWithoutUri()
- })
- .Required("generic_property1", "generic_property2")
- .BuildWithoutUri(),
+ .Type(SchemaValueType.Object)
+ .Properties(new Dictionary
+ {
+ ["generic_property1"] = new JsonSchemaBuilder()
+ .Type(SchemaValueType.String)
+ .BuildWithoutUri(),
+ ["generic_property2"] = new JsonSchemaBuilder()
+ .Type(SchemaValueType.Boolean)
+ .BuildWithoutUri()
+ })
+ .Required("generic_property1", "generic_property2")
+ .BuildWithoutUri(),
[expectedParentTypeName] = new JsonSchemaBuilder()
- .Type(SchemaValueType.Object)
- .Properties(new Dictionary
- {
- ["property1"] = new JsonSchemaBuilder()
- .Ref($"#/components/schemas/{expectedProperty1TypeName}")
- .BuildWithoutUri()
- })
- .Required("property1")
- .BuildWithoutUri()
+ .Type(SchemaValueType.Object)
+ .Properties(new Dictionary
+ {
+ ["property1"] = new JsonSchemaBuilder()
+ .Ref($"#/components/schemas/{expectedProperty1TypeName}")
+ .BuildWithoutUri()
+ })
+ .Required("property1")
+ .BuildWithoutUri()
};
schemaGenerator.GetAllSchemas().Should().BeEquivalentTo(expectedRegistrations);
}
@@ -721,34 +722,34 @@ public void CreateOrRef_TypeWithSomeNullableGenericPropertiesHasCorrectRequiredS
var expectedProperty1TypeName = $"{MethodName} GenericTwoType`2[String,Boolean]";
var expectedSchema = new JsonSchemaBuilder()
- .Ref($"#/components/schemas/{expectedParentTypeName}")
- .BuildWithoutUri();
+ .Ref($"#/components/schemas/{expectedParentTypeName}")
+ .BuildWithoutUri();
actualSchema.Should().BeEquivalentTo(expectedSchema);
var expectedRegistrations = new Dictionary
{
[expectedProperty1TypeName] = new JsonSchemaBuilder()
- .Type(SchemaValueType.Object)
- .Properties(new Dictionary
- {
- ["generic_property1"] = new JsonSchemaBuilder()
- .Type(SchemaValueType.String)
- .BuildWithoutUri(),
- ["generic_property2"] = new JsonSchemaBuilder()
- .Type(SchemaValueType.Boolean)
- .BuildWithoutUri()
- })
- .BuildWithoutUri(),
+ .Type(SchemaValueType.Object)
+ .Properties(new Dictionary
+ {
+ ["generic_property1"] = new JsonSchemaBuilder()
+ .Type(SchemaValueType.String)
+ .BuildWithoutUri(),
+ ["generic_property2"] = new JsonSchemaBuilder()
+ .Type(SchemaValueType.Boolean)
+ .BuildWithoutUri()
+ })
+ .BuildWithoutUri(),
[expectedParentTypeName] = new JsonSchemaBuilder()
- .Type(SchemaValueType.Object)
- .Properties(new Dictionary
- {
- ["property1"] = new JsonSchemaBuilder()
- .Ref($"#/components/schemas/{expectedProperty1TypeName}")
- .BuildWithoutUri()
- })
- .BuildWithoutUri()
+ .Type(SchemaValueType.Object)
+ .Properties(new Dictionary
+ {
+ ["property1"] = new JsonSchemaBuilder()
+ .Ref($"#/components/schemas/{expectedProperty1TypeName}")
+ .BuildWithoutUri()
+ })
+ .BuildWithoutUri()
};
schemaGenerator.GetAllSchemas().Should().BeEquivalentTo(expectedRegistrations);
}
@@ -766,46 +767,46 @@ public void CreateOrRef_TypeWithGenericPropertyParsedCorrectly_ChildGeneric()
var expectedProperty1ChildGenericTypeName = $"{MethodName} GenericOneType`1[Boolean]";
var expectedSchema = new JsonSchemaBuilder()
- .Ref($"#/components/schemas/{expectedParentTypeName}")
- .BuildWithoutUri();
+ .Ref($"#/components/schemas/{expectedParentTypeName}")
+ .BuildWithoutUri();
actualSchema.Should().BeEquivalentTo(expectedSchema);
var expectedRegistrations = new Dictionary
{
[expectedProperty1ChildGenericTypeName] = new JsonSchemaBuilder()
- .Type(SchemaValueType.Object)
- .Properties(new Dictionary
- {
- ["generic_property"] = new JsonSchemaBuilder()
- .Type(SchemaValueType.Boolean)
- .BuildWithoutUri()
- })
- .Required("generic_property")
- .BuildWithoutUri(),
+ .Type(SchemaValueType.Object)
+ .Properties(new Dictionary
+ {
+ ["generic_property"] = new JsonSchemaBuilder()
+ .Type(SchemaValueType.Boolean)
+ .BuildWithoutUri()
+ })
+ .Required("generic_property")
+ .BuildWithoutUri(),
[expectedProperty1Name] = new JsonSchemaBuilder()
- .Type(SchemaValueType.Object)
- .Properties(new Dictionary
- {
- ["generic_property1"] = new JsonSchemaBuilder()
- .Type(SchemaValueType.String)
- .BuildWithoutUri(),
- ["generic_property2"] = new JsonSchemaBuilder()
- .Ref($"#/components/schemas/{expectedProperty1ChildGenericTypeName}")
- .BuildWithoutUri()
- })
- .Required("generic_property1", "generic_property2")
- .BuildWithoutUri(),
+ .Type(SchemaValueType.Object)
+ .Properties(new Dictionary
+ {
+ ["generic_property1"] = new JsonSchemaBuilder()
+ .Type(SchemaValueType.String)
+ .BuildWithoutUri(),
+ ["generic_property2"] = new JsonSchemaBuilder()
+ .Ref($"#/components/schemas/{expectedProperty1ChildGenericTypeName}")
+ .BuildWithoutUri()
+ })
+ .Required("generic_property1", "generic_property2")
+ .BuildWithoutUri(),
[expectedParentTypeName] = new JsonSchemaBuilder()
- .Type(SchemaValueType.Object)
- .Properties(new Dictionary
- {
- ["property1"] = new JsonSchemaBuilder()
- .Ref($"#/components/schemas/{expectedProperty1Name}")
- .BuildWithoutUri()
- })
- .Required("property1")
- .BuildWithoutUri()
+ .Type(SchemaValueType.Object)
+ .Properties(new Dictionary
+ {
+ ["property1"] = new JsonSchemaBuilder()
+ .Ref($"#/components/schemas/{expectedProperty1Name}")
+ .BuildWithoutUri()
+ })
+ .Required("property1")
+ .BuildWithoutUri()
};
schemaGenerator.GetAllSchemas().Should().BeEquivalentTo(expectedRegistrations);
@@ -824,46 +825,46 @@ public void CreateOrRef_TypeWithGenericPropertyHasCorrectRequiredState_ChildGene
var expectedProperty1ChildGenericTypeName = $"{MethodName} GenericOneType`1[Boolean]";
var expectedSchema = new JsonSchemaBuilder()
- .Ref($"#/components/schemas/{expectedParentTypeName}")
- .BuildWithoutUri();
+ .Ref($"#/components/schemas/{expectedParentTypeName}")
+ .BuildWithoutUri();
actualSchema.Should().BeEquivalentTo(expectedSchema);
var expectedRegistrations = new Dictionary
{
[expectedProperty1ChildGenericTypeName] = new JsonSchemaBuilder()
- .Type(SchemaValueType.Object)
- .Properties(new Dictionary
- {
- ["generic_property"] = new JsonSchemaBuilder()
- .Type(SchemaValueType.Boolean)
- .BuildWithoutUri()
- })
- .Required("generic_property")
- .BuildWithoutUri(),
+ .Type(SchemaValueType.Object)
+ .Properties(new Dictionary
+ {
+ ["generic_property"] = new JsonSchemaBuilder()
+ .Type(SchemaValueType.Boolean)
+ .BuildWithoutUri()
+ })
+ .Required("generic_property")
+ .BuildWithoutUri(),
[expectedProperty1Name] = new JsonSchemaBuilder()
- .Type(SchemaValueType.Object)
- .Properties(new Dictionary
- {
- ["generic_property1"] = new JsonSchemaBuilder()
- .Type(SchemaValueType.String)
- .BuildWithoutUri(),
- ["generic_property2"] = new JsonSchemaBuilder()
- .Ref($"#/components/schemas/{expectedProperty1ChildGenericTypeName}")
- .BuildWithoutUri()
- })
- .Required("generic_property1")
- .BuildWithoutUri(),
+ .Type(SchemaValueType.Object)
+ .Properties(new Dictionary
+ {
+ ["generic_property1"] = new JsonSchemaBuilder()
+ .Type(SchemaValueType.String)
+ .BuildWithoutUri(),
+ ["generic_property2"] = new JsonSchemaBuilder()
+ .Ref($"#/components/schemas/{expectedProperty1ChildGenericTypeName}")
+ .BuildWithoutUri()
+ })
+ .Required("generic_property1")
+ .BuildWithoutUri(),
[expectedParentTypeName] = new JsonSchemaBuilder()
- .Type(SchemaValueType.Object)
- .Properties(new Dictionary
- {
- ["property1"] = new JsonSchemaBuilder()
- .Ref($"#/components/schemas/{expectedProperty1Name}")
- .BuildWithoutUri()
- })
- .Required("property1")
- .BuildWithoutUri()
+ .Type(SchemaValueType.Object)
+ .Properties(new Dictionary
+ {
+ ["property1"] = new JsonSchemaBuilder()
+ .Ref($"#/components/schemas/{expectedProperty1Name}")
+ .BuildWithoutUri()
+ })
+ .Required("property1")
+ .BuildWithoutUri()
};
schemaGenerator.GetAllSchemas().Should().BeEquivalentTo(expectedRegistrations);
@@ -887,13 +888,20 @@ private enum Enum2
value_value4
}
- private sealed record TypeWithProperties(int IntProperty, string StringProperty, TypeWithProperties NestedProperty, AnotherTypeWithProperties AnotherProperty);
-
- private sealed record TypeWithSomeNullableProperties(int? IntProperty, string StringProperty, TypeWithSomeNullableProperties NestedProperty, AnotherTypeWithProperties? AnotherProperty);
+ private enum TypeWithSummariesInnerEnum
+ {
+ Bla
+ }
- private sealed record AnotherTypeWithProperties(bool BoolProperty);
+ private enum TypeWithGenericPropertiesFirstEnum
+ {
+ TypeWithGenericPropertiesFirstEnum
+ }
- private sealed record TypeWithSimpleProperties(DateTime DateTime, DateTimeOffset DateTimeOffset, DateOnly DateOnly, TimeOnly TimeOnly, TimeSpan TimeSpan, Guid Guid);
+ private enum TypeWithGenericPropertiesSecondEnum
+ {
+ TypeWithGenericPropertiesSecondEnum
+ }
private sealed class TypeWithSummaries
{
@@ -922,6 +930,7 @@ private sealed class TypeWithSummaries
///
public TimeSpan Prop5 { get; set; }
}
+
private sealed class TypeWithSummariesInner
{
///
@@ -929,12 +938,6 @@ private sealed class TypeWithSummariesInner
///
public string InnerProp1 { get; set; }
}
- private enum TypeWithSummariesInnerEnum
- {
- Bla
- }
-
- private sealed record CustomSimpleType;
private sealed class TypeWithGenericProperties
{
@@ -948,16 +951,6 @@ private sealed class TypeWithSomeNullableGenericProperties
public GenericOneType Property2 { get; set; }
}
- private enum TypeWithGenericPropertiesFirstEnum
- {
- TypeWithGenericPropertiesFirstEnum
- }
-
- private enum TypeWithGenericPropertiesSecondEnum
- {
- TypeWithGenericPropertiesSecondEnum
- }
-
private sealed class GenericOneType
{
public T GenericProperty { get; set; }
@@ -973,7 +966,7 @@ private sealed class TypeWithNullableGenericTwoTypesProperty
public GenericTwoType? Property1 { get; set; }
}
- private sealed class GenericTwoType
+ private sealed class GenericTwoType
{
public T GenericProperty1 { get; set; }
public U GenericProperty2 { get; set; }
@@ -988,4 +981,14 @@ private sealed class TypeWithNullableChildGenericTypyProperty
{
public GenericTwoType?> Property1 { get; set; }
}
+
+ private sealed record TypeWithProperties(int IntProperty, string StringProperty, TypeWithProperties NestedProperty, AnotherTypeWithProperties AnotherProperty);
+
+ private sealed record TypeWithSomeNullableProperties(int? IntProperty, string StringProperty, TypeWithSomeNullableProperties NestedProperty, AnotherTypeWithProperties? AnotherProperty);
+
+ private sealed record AnotherTypeWithProperties(bool BoolProperty);
+
+ private sealed record TypeWithSimpleProperties(DateTime DateTime, DateTimeOffset DateTimeOffset, DateOnly DateOnly, TimeOnly TimeOnly, TimeSpan TimeSpan, Guid Guid);
+
+ private sealed record CustomSimpleType;
}
diff --git a/src/tests/Tochka.JsonRpc.Server.Tests.Integration/BatchTests.cs b/src/tests/Tochka.JsonRpc.Server.Tests.Integration/BatchTests.cs
index 7709acd6..3ec5710a 100644
--- a/src/tests/Tochka.JsonRpc.Server.Tests.Integration/BatchTests.cs
+++ b/src/tests/Tochka.JsonRpc.Server.Tests.Integration/BatchTests.cs
@@ -35,38 +35,40 @@ protected override void SetupServices(IServiceCollection services)
[Test]
public async Task StringId_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- [
- {
- "method": "process_anything",
- "id": "123",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "method": "process_anything",
- "id": "456",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ const string requestJson =
+ $$"""
+ [
+ {
+ "method": "process_anything",
+ "id": "123",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "process_anything",
+ "id": "456",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedRequestData = TestData.Plain;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- [
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
var actualRequestData = new List();
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -86,38 +88,40 @@ public async Task StringId_DeserializeSuccessfully()
[Test]
public async Task IntId_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- [
- {
- "method": "process_anything",
- "id": 123,
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "method": "process_anything",
- "id": 456,
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ const string requestJson =
+ $$"""
+ [
+ {
+ "method": "process_anything",
+ "id": 123,
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "process_anything",
+ "id": 456,
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedRequestData = TestData.Plain;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- [
- {
- "id": 123,
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": 456,
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": 123,
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": 456,
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
var actualRequestData = new List();
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -137,38 +141,40 @@ public async Task IntId_DeserializeSuccessfully()
[Test]
public async Task FloatId_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- [
- {
- "method": "process_anything",
- "id": 123.23,
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "method": "process_anything",
- "id": 456.23,
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ const string requestJson =
+ $$"""
+ [
+ {
+ "method": "process_anything",
+ "id": 123.23,
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "process_anything",
+ "id": 456.23,
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedRequestData = TestData.Plain;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- [
- {
- "id": 123.23,
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": 456.23,
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": 123.23,
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": 456.23,
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
var actualRequestData = new List();
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -188,27 +194,29 @@ public async Task FloatId_DeserializeSuccessfully()
[Test]
public async Task NullId_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- [
- {
- "method": "process_anything",
- "id": null,
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ const string requestJson =
+ $$"""
+ [
+ {
+ "method": "process_anything",
+ "id": null,
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedRequestData = TestData.Plain;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- [
- {
- "id": null,
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": null,
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
var actualRequestData = new List();
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -228,38 +236,40 @@ public async Task NullId_DeserializeSuccessfully()
[Test]
public async Task ActionOnly_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- [
- {
- "method": "action_only",
- "id": "123",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "method": "action_only",
- "id": "456",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ const string requestJson =
+ $$"""
+ [
+ {
+ "method": "action_only",
+ "id": "123",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "action_only",
+ "id": "456",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedRequestData = TestData.Plain;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- [
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
var actualRequestData = new List();
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -279,38 +289,40 @@ public async Task ActionOnly_DeserializeSuccessfully()
[Test]
public async Task ControllerAndAction_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- [
- {
- "method": "simple_json_rpc.controller_and_action",
- "id": "123",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "method": "simple_json_rpc.controller_and_action",
- "id": "456",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ const string requestJson =
+ $$"""
+ [
+ {
+ "method": "simple_json_rpc.controller_and_action",
+ "id": "123",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "simple_json_rpc.controller_and_action",
+ "id": "456",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedRequestData = TestData.Plain;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- [
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
var actualRequestData = new List();
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -330,42 +342,44 @@ public async Task ControllerAndAction_DeserializeSuccessfully()
[Test]
public async Task BindingStyleDefault_ObjectParams_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- [
- {
- "method": "binding_style_default",
- "id": "123",
- "params": {
- "data": {{TestData.PlainRequiredSnakeCaseJson}}
- },
- "jsonrpc": "2.0"
- },
- {
- "method": "binding_style_default",
- "id": "456",
- "params": {
- "data": {{TestData.PlainRequiredSnakeCaseJson}}
- },
- "jsonrpc": "2.0"
- }
- ]
- """;
+ const string requestJson =
+ $$"""
+ [
+ {
+ "method": "binding_style_default",
+ "id": "123",
+ "params": {
+ "data": {{TestData.PlainRequiredSnakeCaseJson}}
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "binding_style_default",
+ "id": "456",
+ "params": {
+ "data": {{TestData.PlainRequiredSnakeCaseJson}}
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedRequestData = TestData.Plain;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- [
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
var actualRequestData = new List();
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -385,42 +399,44 @@ public async Task BindingStyleDefault_ObjectParams_DeserializeSuccessfully()
[Test]
public async Task BindingStyleDefault_ArrayParams_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- [
- {
- "method": "binding_style_default",
- "id": "123",
- "params": [
- {{TestData.PlainRequiredSnakeCaseJson}}
- ],
- "jsonrpc": "2.0"
- },
- {
- "method": "binding_style_default",
- "id": "456",
- "params": [
- {{TestData.PlainRequiredSnakeCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- ]
- """;
+ const string requestJson =
+ $$"""
+ [
+ {
+ "method": "binding_style_default",
+ "id": "123",
+ "params": [
+ {{TestData.PlainRequiredSnakeCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "binding_style_default",
+ "id": "456",
+ "params": [
+ {{TestData.PlainRequiredSnakeCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedRequestData = TestData.Plain;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- [
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
var actualRequestData = new List();
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -441,51 +457,51 @@ public async Task BindingStyleDefault_ArrayParams_DeserializeSuccessfully()
public async Task BindingStyleDefault_NullParams_ReturnError()
{
const string requestJson = """
- [
- {
- "method": "binding_style_default",
- "id": "123",
- "params": null,
- "jsonrpc": "2.0"
- },
- {
- "method": "binding_style_default",
- "id": "456",
- "params": null,
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "binding_style_default",
+ "id": "123",
+ "params": null,
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "binding_style_default",
+ "id": "456",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Error while binding value by JSON key = [params] - Can't bind method arguments from null json params"
- ]
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Error while binding value by JSON key = [params] - Can't bind method arguments from null json params"
- ]
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Error while binding value by JSON key = [params] - Can't bind method arguments from null json params"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Error while binding value by JSON key = [params] - Can't bind method arguments from null json params"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -499,49 +515,49 @@ public async Task BindingStyleDefault_NullParams_ReturnError()
public async Task BindingStyleDefault_WithoutParams_ReturnError()
{
const string requestJson = """
- [
- {
- "method": "binding_style_default",
- "id": "123",
- "jsonrpc": "2.0"
- },
- {
- "method": "binding_style_default",
- "id": "456",
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "binding_style_default",
+ "id": "123",
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "binding_style_default",
+ "id": "456",
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Error while binding value by JSON key = [params] - Can't bind method arguments from missing json params"
- ]
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Error while binding value by JSON key = [params] - Can't bind method arguments from missing json params"
- ]
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Error while binding value by JSON key = [params] - Can't bind method arguments from missing json params"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Error while binding value by JSON key = [params] - Can't bind method arguments from missing json params"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -555,51 +571,51 @@ public async Task BindingStyleDefault_WithoutParams_ReturnError()
public async Task BindingStyleDefault_EmptyObjectParams_ReturnError()
{
const string requestJson = """
- [
- {
- "method": "binding_style_default",
- "id": "123",
- "params": {},
- "jsonrpc": "2.0"
- },
- {
- "method": "binding_style_default",
- "id": "456",
- "params": {},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "binding_style_default",
+ "id": "123",
+ "params": {},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "binding_style_default",
+ "id": "456",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Bind value not found (expected JSON key = [params.data])"
- ]
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Bind value not found (expected JSON key = [params.data])"
- ]
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Bind value not found (expected JSON key = [params.data])"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Bind value not found (expected JSON key = [params.data])"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -613,51 +629,51 @@ public async Task BindingStyleDefault_EmptyObjectParams_ReturnError()
public async Task BindingStyleDefault_EmptyArrayParams_ReturnError()
{
const string requestJson = """
- [
- {
- "method": "binding_style_default",
- "id": "123",
- "params": [],
- "jsonrpc": "2.0"
- },
- {
- "method": "binding_style_default",
- "id": "456",
- "params": [],
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "binding_style_default",
+ "id": "123",
+ "params": [],
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "binding_style_default",
+ "id": "456",
+ "params": [],
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Bind value not found (expected JSON key = [params[0]])"
- ]
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Bind value not found (expected JSON key = [params[0]])"
- ]
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Bind value not found (expected JSON key = [params[0]])"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Bind value not found (expected JSON key = [params[0]])"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -670,38 +686,40 @@ public async Task BindingStyleDefault_EmptyArrayParams_ReturnError()
[Test]
public async Task BindingStyleObject_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- [
- {
- "method": "binding_style_object",
- "id": "123",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "method": "binding_style_object",
- "id": "456",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ const string requestJson =
+ $$"""
+ [
+ {
+ "method": "binding_style_object",
+ "id": "123",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "binding_style_object",
+ "id": "456",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedRequestData = TestData.Plain;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- [
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
var actualRequestData = new List();
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -722,51 +740,51 @@ public async Task BindingStyleObject_DeserializeSuccessfully()
public async Task BindingStyleObject_NullParams_ReturnError()
{
const string requestJson = """
- [
- {
- "method": "binding_style_object",
- "id": "123",
- "params": null,
- "jsonrpc": "2.0"
- },
- {
- "method": "binding_style_object",
- "id": "456",
- "params": null,
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "binding_style_object",
+ "id": "123",
+ "params": null,
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "binding_style_object",
+ "id": "456",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Can't bind value = [null] by JSON key = [params] to required parameter"
- ]
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Can't bind value = [null] by JSON key = [params] to required parameter"
- ]
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Can't bind value = [null] by JSON key = [params] to required parameter"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Can't bind value = [null] by JSON key = [params] to required parameter"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -780,49 +798,49 @@ public async Task BindingStyleObject_NullParams_ReturnError()
public async Task BindingStyleObject_WithoutParams_ReturnError()
{
const string requestJson = """
- [
- {
- "method": "binding_style_object",
- "id": "123",
- "jsonrpc": "2.0"
- },
- {
- "method": "binding_style_object",
- "id": "456",
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "binding_style_object",
+ "id": "123",
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "binding_style_object",
+ "id": "456",
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Bind value not found (expected JSON key = [params])"
- ]
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Bind value not found (expected JSON key = [params])"
- ]
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Bind value not found (expected JSON key = [params])"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Bind value not found (expected JSON key = [params])"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -836,57 +854,57 @@ public async Task BindingStyleObject_WithoutParams_ReturnError()
public async Task BindingStyleObject_EmptyObjectParams_ReturnError()
{
const string requestJson = """
- [
- {
- "method": "binding_style_object",
- "id": "123",
- "params": {},
- "jsonrpc": "2.0"
- },
- {
- "method": "binding_style_object",
- "id": "456",
- "params": {},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "binding_style_object",
+ "id": "123",
+ "params": {},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "binding_style_object",
+ "id": "456",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "ArrayField": [
- "The ArrayField field is required."
- ],
- "StringField": [
- "The StringField field is required."
- ]
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "ArrayField": [
- "The ArrayField field is required."
- ],
- "StringField": [
- "The StringField field is required."
- ]
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "ArrayField": [
+ "The ArrayField field is required."
+ ],
+ "StringField": [
+ "The StringField field is required."
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "ArrayField": [
+ "The ArrayField field is required."
+ ],
+ "StringField": [
+ "The StringField field is required."
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -900,51 +918,51 @@ public async Task BindingStyleObject_EmptyObjectParams_ReturnError()
public async Task BindingStyleObject_EmptyArrayParams_ReturnError()
{
const string requestJson = """
- [
- {
- "method": "binding_style_object",
- "id": "123",
- "params": [],
- "jsonrpc": "2.0"
- },
- {
- "method": "binding_style_object",
- "id": "456",
- "params": [],
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "binding_style_object",
+ "id": "123",
+ "params": [],
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "binding_style_object",
+ "id": "456",
+ "params": [],
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Error while binding value by JSON key = [params] - Can't bind array to object parameter"
- ]
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Error while binding value by JSON key = [params] - Can't bind array to object parameter"
- ]
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Error while binding value by JSON key = [params] - Can't bind array to object parameter"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Error while binding value by JSON key = [params] - Can't bind array to object parameter"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -957,42 +975,44 @@ public async Task BindingStyleObject_EmptyArrayParams_ReturnError()
[Test]
public async Task BindingStyleArray_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- [
- {
- "method": "binding_style_array",
- "id": "123",
- "params": [
- {{TestData.PlainRequiredSnakeCaseJson}}
- ],
- "jsonrpc": "2.0"
- },
- {
- "method": "binding_style_array",
- "id": "456",
- "params": [
- {{TestData.PlainRequiredSnakeCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- ]
- """;
+ const string requestJson =
+ $$"""
+ [
+ {
+ "method": "binding_style_array",
+ "id": "123",
+ "params": [
+ {{TestData.PlainRequiredSnakeCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "binding_style_array",
+ "id": "456",
+ "params": [
+ {{TestData.PlainRequiredSnakeCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedRequestData = TestData.Plain;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- [
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
var actualRequestData = new List();
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -1013,51 +1033,51 @@ public async Task BindingStyleArray_DeserializeSuccessfully()
public async Task BindingStyleArray_NullParams_ReturnError()
{
const string requestJson = """
- [
- {
- "method": "binding_style_array",
- "id": "123",
- "params": null,
- "jsonrpc": "2.0"
- },
- {
- "method": "binding_style_array",
- "id": "456",
- "params": null,
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "binding_style_array",
+ "id": "123",
+ "params": null,
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "binding_style_array",
+ "id": "456",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Can't bind value = [null] by JSON key = [params] to required parameter"
- ]
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Can't bind value = [null] by JSON key = [params] to required parameter"
- ]
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Can't bind value = [null] by JSON key = [params] to required parameter"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Can't bind value = [null] by JSON key = [params] to required parameter"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -1071,49 +1091,49 @@ public async Task BindingStyleArray_NullParams_ReturnError()
public async Task BindingStyleArray_WithoutParams_ReturnError()
{
const string requestJson = """
- [
- {
- "method": "binding_style_array",
- "id": "123",
- "jsonrpc": "2.0"
- },
- {
- "method": "binding_style_array",
- "id": "456",
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "binding_style_array",
+ "id": "123",
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "binding_style_array",
+ "id": "456",
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Bind value not found (expected JSON key = [params])"
- ]
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Bind value not found (expected JSON key = [params])"
- ]
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Bind value not found (expected JSON key = [params])"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Bind value not found (expected JSON key = [params])"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -1127,51 +1147,51 @@ public async Task BindingStyleArray_WithoutParams_ReturnError()
public async Task BindingStyleArray_EmptyObjectParams_ReturnError()
{
const string requestJson = """
- [
- {
- "method": "binding_style_array",
- "id": "123",
- "params": {},
- "jsonrpc": "2.0"
- },
- {
- "method": "binding_style_array",
- "id": "456",
- "params": {},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "binding_style_array",
+ "id": "123",
+ "params": {},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "binding_style_array",
+ "id": "456",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Error while binding value by JSON key = [params] - Can't bind object to collection parameter"
- ]
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Error while binding value by JSON key = [params] - Can't bind object to collection parameter"
- ]
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Error while binding value by JSON key = [params] - Can't bind object to collection parameter"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Error while binding value by JSON key = [params] - Can't bind object to collection parameter"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -1185,37 +1205,38 @@ public async Task BindingStyleArray_EmptyObjectParams_ReturnError()
public async Task BindingStyleArray_EmptyArrayParams_SetEmptyArray()
{
const string requestJson = """
- [
- {
- "method": "binding_style_array",
- "id": "123",
- "params": [],
- "jsonrpc": "2.0"
- },
- {
- "method": "binding_style_array",
- "id": "456",
- "params": [],
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "binding_style_array",
+ "id": "123",
+ "params": [],
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "binding_style_array",
+ "id": "456",
+ "params": [],
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedRequestData = new List();
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- [
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
object? actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -1238,51 +1259,51 @@ public async Task BindingStyleArray_EmptyArrayParams_SetEmptyArray()
public async Task NullableDefaultParams_NullParams_ReturnError()
{
const string requestJson = """
- [
- {
- "method": "nullable_default_params",
- "id": "123",
- "params": null,
- "jsonrpc": "2.0"
- },
- {
- "method": "nullable_default_params",
- "id": "456",
- "params": null,
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "nullable_default_params",
+ "id": "123",
+ "params": null,
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "nullable_default_params",
+ "id": "456",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Error while binding value by JSON key = [params] - Can't bind method arguments from null json params"
- ]
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Error while binding value by JSON key = [params] - Can't bind method arguments from null json params"
- ]
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Error while binding value by JSON key = [params] - Can't bind method arguments from null json params"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Error while binding value by JSON key = [params] - Can't bind method arguments from null json params"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -1296,49 +1317,49 @@ public async Task NullableDefaultParams_NullParams_ReturnError()
public async Task NullableDefaultParams_WithoutParams_ReturnError()
{
const string requestJson = """
- [
- {
- "method": "nullable_default_params",
- "id": "123",
- "jsonrpc": "2.0"
- },
- {
- "method": "nullable_default_params",
- "id": "456",
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "nullable_default_params",
+ "id": "123",
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "nullable_default_params",
+ "id": "456",
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Error while binding value by JSON key = [params] - Can't bind method arguments from missing json params"
- ]
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Error while binding value by JSON key = [params] - Can't bind method arguments from missing json params"
- ]
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Error while binding value by JSON key = [params] - Can't bind method arguments from missing json params"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Error while binding value by JSON key = [params] - Can't bind method arguments from missing json params"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -1352,51 +1373,51 @@ public async Task NullableDefaultParams_WithoutParams_ReturnError()
public async Task NullableDefaultParams_EmptyObjectParams_ReturnError()
{
const string requestJson = """
- [
- {
- "method": "nullable_default_params",
- "id": "123",
- "params": {},
- "jsonrpc": "2.0"
- },
- {
- "method": "nullable_default_params",
- "id": "456",
- "params": {},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "nullable_default_params",
+ "id": "123",
+ "params": {},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "nullable_default_params",
+ "id": "456",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Bind value not found (expected JSON key = [params.data])"
- ]
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Bind value not found (expected JSON key = [params.data])"
- ]
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Bind value not found (expected JSON key = [params.data])"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Bind value not found (expected JSON key = [params.data])"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -1410,51 +1431,51 @@ public async Task NullableDefaultParams_EmptyObjectParams_ReturnError()
public async Task NullableDefaultParams_EmptyArrayParams_ReturnError()
{
const string requestJson = """
- [
- {
- "method": "nullable_default_params",
- "id": "123",
- "params": [],
- "jsonrpc": "2.0"
- },
- {
- "method": "nullable_default_params",
- "id": "456",
- "params": [],
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "nullable_default_params",
+ "id": "123",
+ "params": [],
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "nullable_default_params",
+ "id": "456",
+ "params": [],
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Bind value not found (expected JSON key = [params[0]])"
- ]
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Bind value not found (expected JSON key = [params[0]])"
- ]
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Bind value not found (expected JSON key = [params[0]])"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Bind value not found (expected JSON key = [params[0]])"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -1468,37 +1489,38 @@ public async Task NullableDefaultParams_EmptyArrayParams_ReturnError()
public async Task NullableObjectParams_NullParams_SetNull()
{
const string requestJson = """
- [
- {
- "method": "nullable_object_params",
- "id": "123",
- "params": null,
- "jsonrpc": "2.0"
- },
- {
- "method": "nullable_object_params",
- "id": "456",
- "params": null,
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "nullable_object_params",
+ "id": "123",
+ "params": null,
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "nullable_object_params",
+ "id": "456",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
object? expectedRequestData = null;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- [
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
object? actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -1521,49 +1543,49 @@ public async Task NullableObjectParams_NullParams_SetNull()
public async Task NullableObjectParams_WithoutParams_ReturnError()
{
const string requestJson = """
- [
- {
- "method": "nullable_object_params",
- "id": "123",
- "jsonrpc": "2.0"
- },
- {
- "method": "nullable_object_params",
- "id": "456",
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "nullable_object_params",
+ "id": "123",
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "nullable_object_params",
+ "id": "456",
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Bind value not found (expected JSON key = [params])"
- ]
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Bind value not found (expected JSON key = [params])"
- ]
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Bind value not found (expected JSON key = [params])"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Bind value not found (expected JSON key = [params])"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -1577,36 +1599,37 @@ public async Task NullableObjectParams_WithoutParams_ReturnError()
public async Task NullableObjectParams_EmptyObjectParams_SetEmptyObject()
{
const string requestJson = """
- [
- {
- "method": "nullable_object_params",
- "id": "123",
- "params": {},
- "jsonrpc": "2.0"
- },
- {
- "method": "nullable_object_params",
- "id": "456",
- "params": {},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "nullable_object_params",
+ "id": "123",
+ "params": {},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "nullable_object_params",
+ "id": "456",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- [
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
object? actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -1629,51 +1652,51 @@ public async Task NullableObjectParams_EmptyObjectParams_SetEmptyObject()
public async Task NullableObjectParams_EmptyArrayParams_ReturnError()
{
const string requestJson = """
- [
- {
- "method": "nullable_object_params",
- "id": "123",
- "params": [],
- "jsonrpc": "2.0"
- },
- {
- "method": "nullable_object_params",
- "id": "456",
- "params": [],
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "nullable_object_params",
+ "id": "123",
+ "params": [],
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "nullable_object_params",
+ "id": "456",
+ "params": [],
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Error while binding value by JSON key = [params] - Can't bind array to object parameter"
- ]
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Error while binding value by JSON key = [params] - Can't bind array to object parameter"
- ]
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Error while binding value by JSON key = [params] - Can't bind array to object parameter"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Error while binding value by JSON key = [params] - Can't bind array to object parameter"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -1687,37 +1710,38 @@ public async Task NullableObjectParams_EmptyArrayParams_ReturnError()
public async Task NullableArrayParams_NullParams_SetNull()
{
const string requestJson = """
- [
- {
- "method": "nullable_array_params",
- "id": "123",
- "params": null,
- "jsonrpc": "2.0"
- },
- {
- "method": "nullable_array_params",
- "id": "456",
- "params": null,
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "nullable_array_params",
+ "id": "123",
+ "params": null,
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "nullable_array_params",
+ "id": "456",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
object? expectedRequestData = null;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- [
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
object? actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -1740,49 +1764,49 @@ public async Task NullableArrayParams_NullParams_SetNull()
public async Task NullableArrayParams_WithoutParams_ReturnError()
{
const string requestJson = """
- [
- {
- "method": "nullable_array_params",
- "id": "123",
- "jsonrpc": "2.0"
- },
- {
- "method": "nullable_array_params",
- "id": "456",
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "nullable_array_params",
+ "id": "123",
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "nullable_array_params",
+ "id": "456",
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Bind value not found (expected JSON key = [params])"
- ]
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Bind value not found (expected JSON key = [params])"
- ]
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Bind value not found (expected JSON key = [params])"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Bind value not found (expected JSON key = [params])"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -1796,51 +1820,51 @@ public async Task NullableArrayParams_WithoutParams_ReturnError()
public async Task NullableArrayParams_EmptyObjectParams_ReturnError()
{
const string requestJson = """
- [
- {
- "method": "nullable_array_params",
- "id": "123",
- "params": {},
- "jsonrpc": "2.0"
- },
- {
- "method": "nullable_array_params",
- "id": "456",
- "params": {},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "nullable_array_params",
+ "id": "123",
+ "params": {},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "nullable_array_params",
+ "id": "456",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Error while binding value by JSON key = [params] - Can't bind object to collection parameter"
- ]
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Error while binding value by JSON key = [params] - Can't bind object to collection parameter"
- ]
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Error while binding value by JSON key = [params] - Can't bind object to collection parameter"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Error while binding value by JSON key = [params] - Can't bind object to collection parameter"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -1854,37 +1878,38 @@ public async Task NullableArrayParams_EmptyObjectParams_ReturnError()
public async Task NullableArrayParams_EmptyArrayParams_SetEmptyArray()
{
const string requestJson = """
- [
- {
- "method": "nullable_array_params",
- "id": "123",
- "params": [],
- "jsonrpc": "2.0"
- },
- {
- "method": "nullable_array_params",
- "id": "456",
- "params": [],
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "nullable_array_params",
+ "id": "123",
+ "params": [],
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "nullable_array_params",
+ "id": "456",
+ "params": [],
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
object? expectedRequestData = new List();
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- [
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
object? actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -1907,51 +1932,51 @@ public async Task NullableArrayParams_EmptyArrayParams_SetEmptyArray()
public async Task DefaultParams_NullParams_ReturnError()
{
const string requestJson = """
- [
- {
- "method": "default_params",
- "id": "123",
- "params": null,
- "jsonrpc": "2.0"
- },
- {
- "method": "default_params",
- "id": "456",
- "params": null,
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "default_params",
+ "id": "123",
+ "params": null,
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "default_params",
+ "id": "456",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Error while binding value by JSON key = [params] - Can't bind method arguments from null json params"
- ]
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Error while binding value by JSON key = [params] - Can't bind method arguments from null json params"
- ]
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Error while binding value by JSON key = [params] - Can't bind method arguments from null json params"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Error while binding value by JSON key = [params] - Can't bind method arguments from null json params"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -1965,49 +1990,49 @@ public async Task DefaultParams_NullParams_ReturnError()
public async Task DefaultParams_WithoutParams_ReturnError()
{
const string requestJson = """
- [
- {
- "method": "default_params",
- "id": "123",
- "jsonrpc": "2.0"
- },
- {
- "method": "default_params",
- "id": "456",
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "default_params",
+ "id": "123",
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "default_params",
+ "id": "456",
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Error while binding value by JSON key = [params] - Can't bind method arguments from missing json params"
- ]
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Error while binding value by JSON key = [params] - Can't bind method arguments from missing json params"
- ]
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Error while binding value by JSON key = [params] - Can't bind method arguments from missing json params"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Error while binding value by JSON key = [params] - Can't bind method arguments from missing json params"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -2021,37 +2046,38 @@ public async Task DefaultParams_WithoutParams_ReturnError()
public async Task DefaultParams_EmptyObjectParams_SetDefault()
{
const string requestJson = """
- [
- {
- "method": "default_params",
- "id": "123",
- "params": {},
- "jsonrpc": "2.0"
- },
- {
- "method": "default_params",
- "id": "456",
- "params": {},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "default_params",
+ "id": "123",
+ "params": {},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "default_params",
+ "id": "456",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
object? expectedRequestData = "123";
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- [
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
object? actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -2074,37 +2100,38 @@ public async Task DefaultParams_EmptyObjectParams_SetDefault()
public async Task DefaultParams_EmptyArrayParams_SetDefault()
{
const string requestJson = """
- [
- {
- "method": "default_params",
- "id": "123",
- "params": [],
- "jsonrpc": "2.0"
- },
- {
- "method": "default_params",
- "id": "456",
- "params": [],
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "default_params",
+ "id": "123",
+ "params": [],
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "default_params",
+ "id": "456",
+ "params": [],
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
object? expectedRequestData = "123";
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- [
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
object? actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -2127,37 +2154,38 @@ public async Task DefaultParams_EmptyArrayParams_SetDefault()
public async Task DefaultObjectParams_NullParams_SetDefault()
{
const string requestJson = """
- [
- {
- "method": "default_object_params",
- "id": "123",
- "params": null,
- "jsonrpc": "2.0"
- },
- {
- "method": "default_object_params",
- "id": "456",
- "params": null,
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "default_object_params",
+ "id": "123",
+ "params": null,
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "default_object_params",
+ "id": "456",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
object? expectedRequestData = "123";
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- [
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
object? actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -2180,35 +2208,36 @@ public async Task DefaultObjectParams_NullParams_SetDefault()
public async Task DefaultObjectParams_WithoutParams_SetDefault()
{
const string requestJson = """
- [
- {
- "method": "default_object_params",
- "id": "123",
- "jsonrpc": "2.0"
- },
- {
- "method": "default_object_params",
- "id": "456",
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "default_object_params",
+ "id": "123",
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "default_object_params",
+ "id": "456",
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
object? expectedRequestData = "123";
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- [
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
object? actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -2231,51 +2260,51 @@ public async Task DefaultObjectParams_WithoutParams_SetDefault()
public async Task DefaultObjectParams_EmptyObjectParams_ReturnError()
{
const string requestJson = """
- [
- {
- "method": "default_object_params",
- "id": "123",
- "params": {},
- "jsonrpc": "2.0"
- },
- {
- "method": "default_object_params",
- "id": "456",
- "params": {},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "default_object_params",
+ "id": "123",
+ "params": {},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "default_object_params",
+ "id": "456",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Error while binding value = [{}] (JSON key = [params]) - JsonException: The JSON value could not be converted to System.String. Path: $ | LineNumber: 0 | BytePositionInLine: 1."
- ]
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Error while binding value = [{}] (JSON key = [params]) - JsonException: The JSON value could not be converted to System.String. Path: $ | LineNumber: 0 | BytePositionInLine: 1."
- ]
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Error while binding value = [{}] (JSON key = [params]) - JsonException: The JSON value could not be converted to System.String. Path: $ | LineNumber: 0 | BytePositionInLine: 1."
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Error while binding value = [{}] (JSON key = [params]) - JsonException: The JSON value could not be converted to System.String. Path: $ | LineNumber: 0 | BytePositionInLine: 1."
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -2289,51 +2318,51 @@ public async Task DefaultObjectParams_EmptyObjectParams_ReturnError()
public async Task DefaultObjectParams_EmptyArrayParams_ReturnError()
{
const string requestJson = """
- [
- {
- "method": "default_object_params",
- "id": "123",
- "params": [],
- "jsonrpc": "2.0"
- },
- {
- "method": "default_object_params",
- "id": "456",
- "params": [],
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "default_object_params",
+ "id": "123",
+ "params": [],
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "default_object_params",
+ "id": "456",
+ "params": [],
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Error while binding value by JSON key = [params] - Can't bind array to object parameter"
- ]
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Error while binding value by JSON key = [params] - Can't bind array to object parameter"
- ]
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Error while binding value by JSON key = [params] - Can't bind array to object parameter"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Error while binding value by JSON key = [params] - Can't bind array to object parameter"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -2347,37 +2376,38 @@ public async Task DefaultObjectParams_EmptyArrayParams_ReturnError()
public async Task DefaultArrayParams_NullParams_SetNull()
{
const string requestJson = """
- [
- {
- "method": "default_array_params",
- "id": "123",
- "params": null,
- "jsonrpc": "2.0"
- },
- {
- "method": "default_array_params",
- "id": "456",
- "params": null,
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "default_array_params",
+ "id": "123",
+ "params": null,
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "default_array_params",
+ "id": "456",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
object? expectedRequestData = null;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- [
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
object? actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -2400,35 +2430,36 @@ public async Task DefaultArrayParams_NullParams_SetNull()
public async Task DefaultArrayParams_WithoutParams_SetDefault()
{
const string requestJson = """
- [
- {
- "method": "default_array_params",
- "id": "123",
- "jsonrpc": "2.0"
- },
- {
- "method": "default_array_params",
- "id": "456",
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "default_array_params",
+ "id": "123",
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "default_array_params",
+ "id": "456",
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
object? expectedRequestData = null;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- [
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
object? actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -2451,51 +2482,51 @@ public async Task DefaultArrayParams_WithoutParams_SetDefault()
public async Task DefaultArrayParams_EmptyObjectParams_ReturnError()
{
const string requestJson = """
- [
- {
- "method": "default_array_params",
- "id": "123",
- "params": {},
- "jsonrpc": "2.0"
- },
- {
- "method": "default_array_params",
- "id": "456",
- "params": {},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "default_array_params",
+ "id": "123",
+ "params": {},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "default_array_params",
+ "id": "456",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Error while binding value by JSON key = [params] - Can't bind object to collection parameter"
- ]
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "data": [
- "Error while binding value by JSON key = [params] - Can't bind object to collection parameter"
- ]
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Error while binding value by JSON key = [params] - Can't bind object to collection parameter"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "data": [
+ "Error while binding value by JSON key = [params] - Can't bind object to collection parameter"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -2509,37 +2540,38 @@ public async Task DefaultArrayParams_EmptyObjectParams_ReturnError()
public async Task DefaultArrayParams_EmptyArrayParams_SetEmptyArray()
{
const string requestJson = """
- [
- {
- "method": "default_array_params",
- "id": "123",
- "params": [],
- "jsonrpc": "2.0"
- },
- {
- "method": "default_array_params",
- "id": "456",
- "params": [],
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "default_array_params",
+ "id": "123",
+ "params": [],
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "default_array_params",
+ "id": "456",
+ "params": [],
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
object? expectedRequestData = new List();
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- [
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
object? actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -2562,34 +2594,35 @@ public async Task DefaultArrayParams_EmptyArrayParams_SetEmptyArray()
public async Task NoParams_ProcessSuccessfully()
{
const string requestJson = """
- [
- {
- "method": "no_params",
- "id": "123",
- "jsonrpc": "2.0"
- },
- {
- "method": "no_params",
- "id": "456",
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "no_params",
+ "id": "123",
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "no_params",
+ "id": "456",
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- [
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
responseProviderMock.Setup(static p => p.GetJsonRpcResponse())
.Returns(responseData);
@@ -2605,38 +2638,40 @@ public async Task NoParams_ProcessSuccessfully()
[Test]
public async Task SnakeCaseParams_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- [
- {
- "method": "snake_case_params",
- "id": "123",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "method": "snake_case_params",
- "id": "456",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ const string requestJson =
+ $$"""
+ [
+ {
+ "method": "snake_case_params",
+ "id": "123",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "snake_case_params",
+ "id": "456",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedRequestData = TestData.Plain;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- [
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
var actualRequestData = new List();
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -2656,38 +2691,40 @@ public async Task SnakeCaseParams_DeserializeSuccessfully()
[Test]
public async Task CamelCaseParams_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- [
- {
- "method": "camelCaseParams",
- "id": "123",
- "params": {{TestData.PlainRequiredCamelCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "method": "camelCaseParams",
- "id": "456",
- "params": {{TestData.PlainRequiredCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ const string requestJson =
+ $$"""
+ [
+ {
+ "method": "camelCaseParams",
+ "id": "123",
+ "params": {{TestData.PlainRequiredCamelCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "camelCaseParams",
+ "id": "456",
+ "params": {{TestData.PlainRequiredCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedRequestData = TestData.Plain;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- [
- {
- "id": "123",
- "result": {{TestData.PlainFullCamelCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "result": {{TestData.PlainFullCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullCamelCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "result": {{TestData.PlainFullCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
var actualRequestData = new List();
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -2707,38 +2744,40 @@ public async Task CamelCaseParams_DeserializeSuccessfully()
[Test]
public async Task NestedSnakeCaseParams_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- [
- {
- "method": "snake_case_params",
- "id": "123",
- "params": {{TestData.NestedRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "method": "snake_case_params",
- "id": "456",
- "params": {{TestData.NestedRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ const string requestJson =
+ $$"""
+ [
+ {
+ "method": "snake_case_params",
+ "id": "123",
+ "params": {{TestData.NestedRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "snake_case_params",
+ "id": "456",
+ "params": {{TestData.NestedRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedRequestData = TestData.Nested;
var responseData = TestData.Nested;
- var expectedResponseJson = $$"""
- [
- {
- "id": "123",
- "result": {{TestData.NestedFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "result": {{TestData.NestedFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": "123",
+ "result": {{TestData.NestedFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "result": {{TestData.NestedFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
var actualRequestData = new List();
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -2758,38 +2797,40 @@ public async Task NestedSnakeCaseParams_DeserializeSuccessfully()
[Test]
public async Task NestedCamelCaseParams_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- [
- {
- "method": "camelCaseParams",
- "id": "123",
- "params": {{TestData.NestedRequiredCamelCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "method": "camelCaseParams",
- "id": "456",
- "params": {{TestData.NestedRequiredCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ const string requestJson =
+ $$"""
+ [
+ {
+ "method": "camelCaseParams",
+ "id": "123",
+ "params": {{TestData.NestedRequiredCamelCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "camelCaseParams",
+ "id": "456",
+ "params": {{TestData.NestedRequiredCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedRequestData = TestData.Nested;
var responseData = TestData.Nested;
- var expectedResponseJson = $$"""
- [
- {
- "id": "123",
- "result": {{TestData.NestedFullCamelCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "result": {{TestData.NestedFullCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": "123",
+ "result": {{TestData.NestedFullCamelCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "result": {{TestData.NestedFullCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
var actualRequestData = new List();
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -2810,63 +2851,64 @@ public async Task NestedCamelCaseParams_DeserializeSuccessfully()
public async Task AdditionalParams_DeserializeSuccessfully()
{
const string requestJson = """
- [
- {
- "method": "process_anything",
- "id": "123",
- "params": {
- "bool_field": true,
- "string_field": "123",
- "int_field": 123,
- "double_field": 1.23,
- "enum_field": "two",
- "array_field": [
- 1,
- 2,
- 3
- ],
- "nullable_field": null,
- "additional_field": "something"
- },
- "jsonrpc": "2.0"
- },
- {
- "method": "process_anything",
- "id": "456",
- "params": {
- "bool_field": true,
- "string_field": "123",
- "int_field": 123,
- "double_field": 1.23,
- "enum_field": "two",
- "array_field": [
- 1,
- 2,
- 3
- ],
- "nullable_field": null,
- "additional_field": "something"
- },
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "process_anything",
+ "id": "123",
+ "params": {
+ "bool_field": true,
+ "string_field": "123",
+ "int_field": 123,
+ "double_field": 1.23,
+ "enum_field": "two",
+ "array_field": [
+ 1,
+ 2,
+ 3
+ ],
+ "nullable_field": null,
+ "additional_field": "something"
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "process_anything",
+ "id": "456",
+ "params": {
+ "bool_field": true,
+ "string_field": "123",
+ "int_field": 123,
+ "double_field": 1.23,
+ "enum_field": "two",
+ "array_field": [
+ 1,
+ 2,
+ 3
+ ],
+ "nullable_field": null,
+ "additional_field": "something"
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedRequestData = TestData.Plain;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- [
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
var actualRequestData = new List();
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -2886,38 +2928,40 @@ public async Task AdditionalParams_DeserializeSuccessfully()
[Test]
public async Task CustomActionRoute_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- [
- {
- "method": "custom_action_route",
- "id": "123",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "method": "custom_action_route",
- "id": "456",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ const string requestJson =
+ $$"""
+ [
+ {
+ "method": "custom_action_route",
+ "id": "123",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "custom_action_route",
+ "id": "456",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedRequestData = TestData.Plain;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- [
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
var actualRequestData = new List();
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -2937,38 +2981,40 @@ public async Task CustomActionRoute_DeserializeSuccessfully()
[Test]
public async Task CustomControllerRoute_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- [
- {
- "method": "custom_controller_route",
- "id": "123",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "method": "custom_controller_route",
- "id": "456",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ const string requestJson =
+ $$"""
+ [
+ {
+ "method": "custom_controller_route",
+ "id": "123",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "custom_controller_route",
+ "id": "456",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedRequestData = TestData.Plain;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- [
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
var actualRequestData = new List();
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -2988,32 +3034,34 @@ public async Task CustomControllerRoute_DeserializeSuccessfully()
[Test]
public async Task RequestAndNotification_ReturnOnlyRequestResponse()
{
- const string requestJson = $$"""
- [
- {
- "method": "process_anything",
- "id": "123",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "method": "process_anything",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ const string requestJson =
+ $$"""
+ [
+ {
+ "method": "process_anything",
+ "id": "123",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "process_anything",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedRequestData = TestData.Plain;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- [
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ [
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
var actualRequestData = new List();
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -3034,49 +3082,49 @@ public async Task RequestAndNotification_ReturnOnlyRequestResponse()
public async Task ThrowException_SerializeSuccessfully()
{
const string requestJson = """
- [
- {
- "method": "throw_exception",
- "id": "123",
- "jsonrpc": "2.0"
- },
- {
- "method": "throw_exception",
- "id": "456",
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "throw_exception",
+ "id": "123",
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "throw_exception",
+ "id": "456",
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32000,
- "message": "Server error",
- "data": {
- "type": "System.ArgumentException",
- "message": "Value does not fall within the expected range.",
- "details": null
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32000,
- "message": "Server error",
- "data": {
- "type": "System.ArgumentException",
- "message": "Value does not fall within the expected range.",
- "details": null
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32000,
+ "message": "Server error",
+ "data": {
+ "type": "System.ArgumentException",
+ "message": "Value does not fall within the expected range.",
+ "details": null
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32000,
+ "message": "Server error",
+ "data": {
+ "type": "System.ArgumentException",
+ "message": "Value does not fall within the expected range.",
+ "details": null
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -3090,41 +3138,41 @@ public async Task ThrowException_SerializeSuccessfully()
public async Task ReturnErrorFromFactory_SerializeSuccessfully()
{
const string requestJson = """
- [
- {
- "method": "return_error_from_factory",
- "id": "123",
- "jsonrpc": "2.0"
- },
- {
- "method": "return_error_from_factory",
- "id": "456",
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "return_error_from_factory",
+ "id": "123",
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "return_error_from_factory",
+ "id": "456",
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": "errorMessage"
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": "errorMessage"
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": "errorMessage"
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": "errorMessage"
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -3138,41 +3186,41 @@ public async Task ReturnErrorFromFactory_SerializeSuccessfully()
public async Task ReturnMvcError_SerializeSuccessfully()
{
const string requestJson = """
- [
- {
- "method": "return_mvc_error",
- "id": "123",
- "jsonrpc": "2.0"
- },
- {
- "method": "return_mvc_error",
- "id": "456",
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "return_mvc_error",
+ "id": "123",
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "return_mvc_error",
+ "id": "456",
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": "errorMessage"
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": "errorMessage"
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": "errorMessage"
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": "errorMessage"
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -3186,41 +3234,41 @@ public async Task ReturnMvcError_SerializeSuccessfully()
public async Task ErrorThrowAsResponseException_SerializeSuccessfully()
{
const string requestJson = """
- [
- {
- "method": "error_throw_as_response_exception",
- "id": "123",
- "jsonrpc": "2.0"
- },
- {
- "method": "error_throw_as_response_exception",
- "id": "456",
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "error_throw_as_response_exception",
+ "id": "123",
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "error_throw_as_response_exception",
+ "id": "456",
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": "errorMessage"
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": "errorMessage"
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": "errorMessage"
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": "errorMessage"
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -3234,45 +3282,45 @@ public async Task ErrorThrowAsResponseException_SerializeSuccessfully()
public async Task UnknownMethod_ReturnError()
{
const string requestJson = """
- [
- {
- "method": "some_not_existing_method",
- "id": "123",
- "jsonrpc": "2.0"
- },
- {
- "method": "some_not_existing_method",
- "id": "456",
- "jsonrpc": "2.0"
- }
- ]
- """;
+ [
+ {
+ "method": "some_not_existing_method",
+ "id": "123",
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "some_not_existing_method",
+ "id": "456",
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32601,
- "message": "Method not found",
- "data": {
- "method": "some_not_existing_method"
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32601,
- "message": "Method not found",
- "data": {
- "method": "some_not_existing_method"
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32601,
+ "message": "Method not found",
+ "data": {
+ "method": "some_not_existing_method"
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32601,
+ "message": "Method not found",
+ "data": {
+ "method": "some_not_existing_method"
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -3285,50 +3333,51 @@ public async Task UnknownMethod_ReturnError()
[Test]
public async Task NoMethod_ReturnError()
{
- const string requestJson = $$"""
- [
- {
- "id": "123",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ const string requestJson =
+ $$"""
+ [
+ {
+ "id": "123",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": null,
- "error": {
- "code": -32600,
- "message": "Invalid Request",
- "data": {
- "type": "Tochka.JsonRpc.Common.JsonRpcFormatException",
- "message": "JSON Rpc call does not have [method] property",
- "details": null
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": null,
- "error": {
- "code": -32600,
- "message": "Invalid Request",
- "data": {
- "type": "Tochka.JsonRpc.Common.JsonRpcFormatException",
- "message": "JSON Rpc call does not have [method] property",
- "details": null
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": null,
+ "error": {
+ "code": -32600,
+ "message": "Invalid Request",
+ "data": {
+ "type": "Tochka.JsonRpc.Common.JsonRpcFormatException",
+ "message": "JSON Rpc call does not have [method] property",
+ "details": null
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": null,
+ "error": {
+ "code": -32600,
+ "message": "Invalid Request",
+ "data": {
+ "type": "Tochka.JsonRpc.Common.JsonRpcFormatException",
+ "message": "JSON Rpc call does not have [method] property",
+ "details": null
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -3341,52 +3390,53 @@ public async Task NoMethod_ReturnError()
[Test]
public async Task MethodNull_ReturnError()
{
- const string requestJson = $$"""
- [
- {
- "method": null,
- "id": "123",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "method": null,
- "id": "456",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ const string requestJson =
+ $$"""
+ [
+ {
+ "method": null,
+ "id": "123",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": null,
+ "id": "456",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32600,
- "message": "Invalid Request",
- "data": {
- "type": "Tochka.JsonRpc.Common.JsonRpcFormatException",
- "message": "Method is null or empty",
- "details": null
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32600,
- "message": "Invalid Request",
- "data": {
- "type": "Tochka.JsonRpc.Common.JsonRpcFormatException",
- "message": "Method is null or empty",
- "details": null
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32600,
+ "message": "Invalid Request",
+ "data": {
+ "type": "Tochka.JsonRpc.Common.JsonRpcFormatException",
+ "message": "Method is null or empty",
+ "details": null
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32600,
+ "message": "Invalid Request",
+ "data": {
+ "type": "Tochka.JsonRpc.Common.JsonRpcFormatException",
+ "message": "Method is null or empty",
+ "details": null
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -3399,52 +3449,53 @@ public async Task MethodNull_ReturnError()
[Test]
public async Task MethodEmpty_ReturnError()
{
- const string requestJson = $$"""
- [
- {
- "method": "",
- "id": "123",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "method": "",
- "id": "456",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ const string requestJson =
+ $$"""
+ [
+ {
+ "method": "",
+ "id": "123",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": "",
+ "id": "456",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32600,
- "message": "Invalid Request",
- "data": {
- "type": "Tochka.JsonRpc.Common.JsonRpcFormatException",
- "message": "Method is null or empty",
- "details": null
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32600,
- "message": "Invalid Request",
- "data": {
- "type": "Tochka.JsonRpc.Common.JsonRpcFormatException",
- "message": "Method is null or empty",
- "details": null
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32600,
+ "message": "Invalid Request",
+ "data": {
+ "type": "Tochka.JsonRpc.Common.JsonRpcFormatException",
+ "message": "Method is null or empty",
+ "details": null
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32600,
+ "message": "Invalid Request",
+ "data": {
+ "type": "Tochka.JsonRpc.Common.JsonRpcFormatException",
+ "message": "Method is null or empty",
+ "details": null
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -3457,52 +3508,53 @@ public async Task MethodEmpty_ReturnError()
[Test]
public async Task MethodWhiteSpace_ReturnError()
{
- const string requestJson = $$"""
- [
- {
- "method": " ",
- "id": "123",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- "method": " ",
- "id": "456",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ const string requestJson =
+ $$"""
+ [
+ {
+ "method": " ",
+ "id": "123",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ "method": " ",
+ "id": "456",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32600,
- "message": "Invalid Request",
- "data": {
- "type": "Tochka.JsonRpc.Common.JsonRpcFormatException",
- "message": "Method is null or empty",
- "details": null
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32600,
- "message": "Invalid Request",
- "data": {
- "type": "Tochka.JsonRpc.Common.JsonRpcFormatException",
- "message": "Method is null or empty",
- "details": null
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32600,
+ "message": "Invalid Request",
+ "data": {
+ "type": "Tochka.JsonRpc.Common.JsonRpcFormatException",
+ "message": "Method is null or empty",
+ "details": null
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32600,
+ "message": "Invalid Request",
+ "data": {
+ "type": "Tochka.JsonRpc.Common.JsonRpcFormatException",
+ "message": "Method is null or empty",
+ "details": null
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -3515,52 +3567,53 @@ public async Task MethodWhiteSpace_ReturnError()
[Test]
public async Task InvalidJsonRpcVersion_ReturnError()
{
- const string requestJson = $$"""
- [
- {
- "method": "process_anything",
- "id": "123",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "3.0"
- },
- {
- "method": "process_anything",
- "id": "456",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "3.0"
- }
- ]
- """;
+ const string requestJson =
+ $$"""
+ [
+ {
+ "method": "process_anything",
+ "id": "123",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "3.0"
+ },
+ {
+ "method": "process_anything",
+ "id": "456",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "3.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": "123",
- "error": {
- "code": -32600,
- "message": "Invalid Request",
- "data": {
- "type": "Tochka.JsonRpc.Common.JsonRpcFormatException",
- "message": "Only [2.0] version supported. Got [3.0]",
- "details": null
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": "456",
- "error": {
- "code": -32600,
- "message": "Invalid Request",
- "data": {
- "type": "Tochka.JsonRpc.Common.JsonRpcFormatException",
- "message": "Only [2.0] version supported. Got [3.0]",
- "details": null
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": "123",
+ "error": {
+ "code": -32600,
+ "message": "Invalid Request",
+ "data": {
+ "type": "Tochka.JsonRpc.Common.JsonRpcFormatException",
+ "message": "Only [2.0] version supported. Got [3.0]",
+ "details": null
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": "456",
+ "error": {
+ "code": -32600,
+ "message": "Invalid Request",
+ "data": {
+ "type": "Tochka.JsonRpc.Common.JsonRpcFormatException",
+ "message": "Only [2.0] version supported. Got [3.0]",
+ "details": null
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -3573,39 +3626,40 @@ public async Task InvalidJsonRpcVersion_ReturnError()
[Test]
public async Task InvalidJson_ReturnError()
{
- const string requestJson = $$"""
- [
- {
- 123
- "method": "process_anything",
- "id": "123",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- },
- {
- 123
- "method": "process_anything",
- "id": "123",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- ]
- """;
+ const string requestJson =
+ $$"""
+ [
+ {
+ 123
+ "method": "process_anything",
+ "id": "123",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ },
+ {
+ 123
+ "method": "process_anything",
+ "id": "123",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ ]
+ """;
var expectedResponseJson = """
- {
- "id": null,
- "error": {
- "code": -32700,
- "message": "Parse error",
- "data": {
- "type": "System.Text.Json.JsonException",
- "message": "'1' is an invalid start of a property name. Expected a '\"'. Path: $ | LineNumber: 2 | BytePositionInLine: 8.",
- "details": null
- }
- },
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ {
+ "id": null,
+ "error": {
+ "code": -32700,
+ "message": "Parse error",
+ "data": {
+ "type": "System.Text.Json.JsonException",
+ "message": "'1' is an invalid start of a property name. Expected a '\"'. Path: $ | LineNumber: 2 | BytePositionInLine: 8.",
+ "details": null
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -3618,50 +3672,51 @@ public async Task InvalidJson_ReturnError()
[Test]
public async Task NoJsonRpc_ReturnError()
{
- const string requestJson = $$"""
- [
- {
- "method": "process_anything",
- "id": "123",
- "params": {{TestData.PlainRequiredSnakeCaseJson}}
- },
- {
- "method": "process_anything",
- "id": "456",
- "params": {{TestData.PlainRequiredSnakeCaseJson}}
- }
- ]
- """;
+ const string requestJson =
+ $$"""
+ [
+ {
+ "method": "process_anything",
+ "id": "123",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}}
+ },
+ {
+ "method": "process_anything",
+ "id": "456",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}}
+ }
+ ]
+ """;
var expectedResponseJson = """
- [
- {
- "id": null,
- "error": {
- "code": -32600,
- "message": "Invalid Request",
- "data": {
- "type": "Tochka.JsonRpc.Common.JsonRpcFormatException",
- "message": "JSON Rpc call does not have [jsonrpc] property",
- "details": null
- }
- },
- "jsonrpc": "2.0"
- },
- {
- "id": null,
- "error": {
- "code": -32600,
- "message": "Invalid Request",
- "data": {
- "type": "Tochka.JsonRpc.Common.JsonRpcFormatException",
- "message": "JSON Rpc call does not have [jsonrpc] property",
- "details": null
- }
- },
- "jsonrpc": "2.0"
- }
- ]
- """.TrimAllLines();
+ [
+ {
+ "id": null,
+ "error": {
+ "code": -32600,
+ "message": "Invalid Request",
+ "data": {
+ "type": "Tochka.JsonRpc.Common.JsonRpcFormatException",
+ "message": "JSON Rpc call does not have [jsonrpc] property",
+ "details": null
+ }
+ },
+ "jsonrpc": "2.0"
+ },
+ {
+ "id": null,
+ "error": {
+ "code": -32600,
+ "message": "Invalid Request",
+ "data": {
+ "type": "Tochka.JsonRpc.Common.JsonRpcFormatException",
+ "message": "JSON Rpc call does not have [jsonrpc] property",
+ "details": null
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ ]
+ """.TrimAllLines();
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
diff --git a/src/tests/Tochka.JsonRpc.Server.Tests.Integration/CompatibilityTests.cs b/src/tests/Tochka.JsonRpc.Server.Tests.Integration/CompatibilityTests.cs
index e8192e1d..a3c59d4e 100644
--- a/src/tests/Tochka.JsonRpc.Server.Tests.Integration/CompatibilityTests.cs
+++ b/src/tests/Tochka.JsonRpc.Server.Tests.Integration/CompatibilityTests.cs
@@ -102,21 +102,22 @@ public async Task FluentValidation_InvalidModel_ReturnJsonRpcResponseWithError()
using var request = new StringContent(requestContent, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcConstants.DefaultRoutePrefix, request);
- var expectedResponse = $$"""
- {
- "id": 123,
- "error": {
- "code": -32602,
- "message": "Invalid params",
- "data": {
- "Str": [
- "{{ModelValidator.Error}}"
- ]
- }
- },
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedResponse =
+ $$"""
+ {
+ "id": 123,
+ "error": {
+ "code": -32602,
+ "message": "Invalid params",
+ "data": {
+ "Str": [
+ "{{ModelValidator.Error}}"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
response.StatusCode.Should().Be(HttpStatusCode.OK);
var responseContent = await response.Content.ReadAsStringAsync();
responseContent.TrimAllLines().Should().Be(expectedResponse);
@@ -139,21 +140,22 @@ public async Task FluentValidation_ManualValidationError_ReturnJsonRpcResponseWi
using var request = new StringContent(requestContent, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcConstants.DefaultRoutePrefix, request);
- var expectedResponse = $$"""
- {
- "id": 123,
- "error": {
- "code": -32603,
- "message": "Internal error",
- "data": {
- "": [
- "{{StringValidator.Error}}"
- ]
- }
- },
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedResponse =
+ $$"""
+ {
+ "id": 123,
+ "error": {
+ "code": -32603,
+ "message": "Internal error",
+ "data": {
+ "": [
+ "{{StringValidator.Error}}"
+ ]
+ }
+ },
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
response.StatusCode.Should().Be(HttpStatusCode.OK);
var responseContent = await response.Content.ReadAsStringAsync();
responseContent.TrimAllLines().Should().Be(expectedResponse);
@@ -163,27 +165,29 @@ public async Task FluentValidation_ManualValidationError_ReturnJsonRpcResponseWi
public async Task FluentValidation_ValidRequest_ReturnJsonRpcResponse()
{
var str = "123";
- var requestContent = $$"""
- {
- "id": 123,
- "method": "validate",
- "jsonrpc": "2.0",
- "params": {
- "str": "{{str}}"
- }
- }
- """;
+ var requestContent =
+ $$"""
+ {
+ "id": 123,
+ "method": "validate",
+ "jsonrpc": "2.0",
+ "params": {
+ "str": "{{str}}"
+ }
+ }
+ """;
using var request = new StringContent(requestContent, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcConstants.DefaultRoutePrefix, request);
- var expectedResponse = $$"""
- {
- "id": 123,
- "result": "{{str}}",
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedResponse =
+ $$"""
+ {
+ "id": 123,
+ "result": "{{str}}",
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
response.StatusCode.Should().Be(HttpStatusCode.OK);
var responseContent = await response.Content.ReadAsStringAsync();
responseContent.TrimAllLines().Should().Be(expectedResponse);
diff --git a/src/tests/Tochka.JsonRpc.Server.Tests.Integration/IntegrationTests.cs b/src/tests/Tochka.JsonRpc.Server.Tests.Integration/IntegrationTests.cs
index 84dd7213..c0e22c27 100644
--- a/src/tests/Tochka.JsonRpc.Server.Tests.Integration/IntegrationTests.cs
+++ b/src/tests/Tochka.JsonRpc.Server.Tests.Integration/IntegrationTests.cs
@@ -63,17 +63,18 @@ public async Task CustomExceptionFilter_ExpectedException_HandleOnlyWithCustomFi
using var request = new StringContent(requestContent, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcConstants.DefaultRoutePrefix, request);
- var expectedResponse = $$"""
- {
- "id": 123,
- "error": {
- "code": -32603,
- "message": "Internal error",
- "data": "{{BusinessLogicExceptionWrappingFilter.ErrorData}}"
- },
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedResponse =
+ $$"""
+ {
+ "id": 123,
+ "error": {
+ "code": -32603,
+ "message": "Internal error",
+ "data": "{{BusinessLogicExceptionWrappingFilter.ErrorData}}"
+ },
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
response.StatusCode.Should().Be(HttpStatusCode.OK);
var responseContent = await response.Content.ReadAsStringAsync();
responseContent.TrimAllLines().Should().Be(expectedResponse);
diff --git a/src/tests/Tochka.JsonRpc.Server.Tests.Integration/NotificationTests.cs b/src/tests/Tochka.JsonRpc.Server.Tests.Integration/NotificationTests.cs
index 7058d02d..9d0aa69c 100644
--- a/src/tests/Tochka.JsonRpc.Server.Tests.Integration/NotificationTests.cs
+++ b/src/tests/Tochka.JsonRpc.Server.Tests.Integration/NotificationTests.cs
@@ -35,13 +35,14 @@ protected override void SetupServices(IServiceCollection services)
[Test]
public async Task ActionOnly_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- {
- "method": "action_only",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """;
+ const string requestJson =
+ $$"""
+ {
+ "method": "action_only",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """;
var expectedRequestData = TestData.Plain;
TestData actualRequestData = null;
@@ -58,13 +59,14 @@ public async Task ActionOnly_DeserializeSuccessfully()
[Test]
public async Task ControllerAndAction_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- {
- "method": "simple_json_rpc.controller_and_action",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """;
+ const string requestJson =
+ $$"""
+ {
+ "method": "simple_json_rpc.controller_and_action",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """;
var expectedRequestData = TestData.Plain;
TestData actualRequestData = null;
@@ -81,15 +83,16 @@ public async Task ControllerAndAction_DeserializeSuccessfully()
[Test]
public async Task BindingStyleDefault_ObjectParams_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- {
- "method": "binding_style_default",
- "params": {
- "data": {{TestData.PlainRequiredSnakeCaseJson}}
- },
- "jsonrpc": "2.0"
- }
- """;
+ const string requestJson =
+ $$"""
+ {
+ "method": "binding_style_default",
+ "params": {
+ "data": {{TestData.PlainRequiredSnakeCaseJson}}
+ },
+ "jsonrpc": "2.0"
+ }
+ """;
var expectedRequestData = TestData.Plain;
TestData actualRequestData = null;
@@ -106,15 +109,16 @@ public async Task BindingStyleDefault_ObjectParams_DeserializeSuccessfully()
[Test]
public async Task BindingStyleDefault_ArrayParams_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- {
- "method": "binding_style_default",
- "params": [
- {{TestData.PlainRequiredSnakeCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """;
+ const string requestJson =
+ $$"""
+ {
+ "method": "binding_style_default",
+ "params": [
+ {{TestData.PlainRequiredSnakeCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """;
var expectedRequestData = TestData.Plain;
TestData actualRequestData = null;
@@ -132,12 +136,12 @@ public async Task BindingStyleDefault_ArrayParams_DeserializeSuccessfully()
public async Task BindingStyleDefault_NullParams_DontProcess()
{
const string requestJson = """
- {
- "method": "binding_style_default",
- "params": null,
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "binding_style_default",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ """;
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -150,11 +154,11 @@ public async Task BindingStyleDefault_NullParams_DontProcess()
public async Task BindingStyleDefault_WithoutParams_DontProcess()
{
const string requestJson = """
- {
- "method": "binding_style_default",
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "binding_style_default",
+ "jsonrpc": "2.0"
+ }
+ """;
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -167,12 +171,12 @@ public async Task BindingStyleDefault_WithoutParams_DontProcess()
public async Task BindingStyleDefault_EmptyObjectParams_DontProcess()
{
const string requestJson = """
- {
- "method": "binding_style_default",
- "params": {},
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "binding_style_default",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ """;
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -185,12 +189,12 @@ public async Task BindingStyleDefault_EmptyObjectParams_DontProcess()
public async Task BindingStyleDefault_EmptyArrayParams_DontProcess()
{
const string requestJson = """
- {
- "method": "binding_style_default",
- "params": [],
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "binding_style_default",
+ "params": [],
+ "jsonrpc": "2.0"
+ }
+ """;
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -202,13 +206,14 @@ public async Task BindingStyleDefault_EmptyArrayParams_DontProcess()
[Test]
public async Task BindingStyleObject_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- {
- "method": "binding_style_object",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """;
+ const string requestJson =
+ $$"""
+ {
+ "method": "binding_style_object",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """;
var expectedRequestData = TestData.Plain;
TestData actualRequestData = null;
@@ -226,12 +231,12 @@ public async Task BindingStyleObject_DeserializeSuccessfully()
public async Task BindingStyleObject_NullParams_DontProcess()
{
const string requestJson = """
- {
- "method": "binding_style_object",
- "params": null,
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "binding_style_object",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ """;
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -244,11 +249,11 @@ public async Task BindingStyleObject_NullParams_DontProcess()
public async Task BindingStyleObject_WithoutParams_DontProcess()
{
const string requestJson = """
- {
- "method": "binding_style_object",
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "binding_style_object",
+ "jsonrpc": "2.0"
+ }
+ """;
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -261,12 +266,12 @@ public async Task BindingStyleObject_WithoutParams_DontProcess()
public async Task BindingStyleObject_EmptyObjectParams_DontProcess()
{
const string requestJson = """
- {
- "method": "binding_style_object",
- "params": {},
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "binding_style_object",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ """;
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -279,12 +284,12 @@ public async Task BindingStyleObject_EmptyObjectParams_DontProcess()
public async Task BindingStyleObject_EmptyArrayParams_DontProcess()
{
const string requestJson = """
- {
- "method": "binding_style_object",
- "params": [],
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "binding_style_object",
+ "params": [],
+ "jsonrpc": "2.0"
+ }
+ """;
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -296,15 +301,16 @@ public async Task BindingStyleObject_EmptyArrayParams_DontProcess()
[Test]
public async Task BindingStyleArray_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- {
- "method": "binding_style_array",
- "params": [
- {{TestData.PlainRequiredSnakeCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """;
+ const string requestJson =
+ $$"""
+ {
+ "method": "binding_style_array",
+ "params": [
+ {{TestData.PlainRequiredSnakeCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """;
var expectedRequestData = new List { TestData.Plain };
object? actualRequestData = null;
@@ -322,12 +328,12 @@ public async Task BindingStyleArray_DeserializeSuccessfully()
public async Task BindingStyleArray_NullParams_DontProcess()
{
const string requestJson = """
- {
- "method": "binding_style_array",
- "params": null,
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "binding_style_array",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ """;
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -340,11 +346,11 @@ public async Task BindingStyleArray_NullParams_DontProcess()
public async Task BindingStyleArray_WithoutParams_DontProcess()
{
const string requestJson = """
- {
- "method": "binding_style_array",
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "binding_style_array",
+ "jsonrpc": "2.0"
+ }
+ """;
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -357,12 +363,12 @@ public async Task BindingStyleArray_WithoutParams_DontProcess()
public async Task BindingStyleArray_EmptyObjectParams_DontProcess()
{
const string requestJson = """
- {
- "method": "binding_style_array",
- "params": {},
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "binding_style_array",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ """;
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -375,12 +381,12 @@ public async Task BindingStyleArray_EmptyObjectParams_DontProcess()
public async Task BindingStyleArray_EmptyArrayParams_DeserializeSuccessfully()
{
const string requestJson = """
- {
- "method": "binding_style_array",
- "params": [],
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "binding_style_array",
+ "params": [],
+ "jsonrpc": "2.0"
+ }
+ """;
var expectedRequestData = new List();
object? actualRequestData = null;
@@ -398,12 +404,12 @@ public async Task BindingStyleArray_EmptyArrayParams_DeserializeSuccessfully()
public async Task NullableDefaultParams_NullParams_DontProcess()
{
const string requestJson = """
- {
- "method": "nullable_default_params",
- "params": null,
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "nullable_default_params",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ """;
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -416,11 +422,11 @@ public async Task NullableDefaultParams_NullParams_DontProcess()
public async Task NullableDefaultParams_WithoutParams_DontProcess()
{
const string requestJson = """
- {
- "method": "nullable_default_params",
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "nullable_default_params",
+ "jsonrpc": "2.0"
+ }
+ """;
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -433,12 +439,12 @@ public async Task NullableDefaultParams_WithoutParams_DontProcess()
public async Task NullableDefaultParams_EmptyObjectParams_DontProcess()
{
const string requestJson = """
- {
- "method": "nullable_default_params",
- "params": {},
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "nullable_default_params",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ """;
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -451,12 +457,12 @@ public async Task NullableDefaultParams_EmptyObjectParams_DontProcess()
public async Task NullableDefaultParams_EmptyArrayParams_DontProcess()
{
const string requestJson = """
- {
- "method": "nullable_default_params",
- "params": [],
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "nullable_default_params",
+ "params": [],
+ "jsonrpc": "2.0"
+ }
+ """;
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -469,12 +475,12 @@ public async Task NullableDefaultParams_EmptyArrayParams_DontProcess()
public async Task NullableObjectParams_NullParams_SetNull()
{
const string requestJson = """
- {
- "method": "nullable_object_params",
- "params": null,
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "nullable_object_params",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ """;
object? expectedRequestData = null;
object? actualRequestData = null;
@@ -494,11 +500,11 @@ public async Task NullableObjectParams_NullParams_SetNull()
public async Task NullableObjectParams_WithoutParams_DontProcess()
{
const string requestJson = """
- {
- "method": "nullable_object_params",
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "nullable_object_params",
+ "jsonrpc": "2.0"
+ }
+ """;
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -511,12 +517,12 @@ public async Task NullableObjectParams_WithoutParams_DontProcess()
public async Task NullableObjectParams_EmptyObjectParams_SetEmptyObject()
{
const string requestJson = """
- {
- "method": "nullable_object_params",
- "params": {},
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "nullable_object_params",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ """;
object? actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -535,12 +541,12 @@ public async Task NullableObjectParams_EmptyObjectParams_SetEmptyObject()
public async Task NullableObjectParams_EmptyArrayParams_DontProcess()
{
const string requestJson = """
- {
- "method": "nullable_object_params",
- "params": ,
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "nullable_object_params",
+ "params": ,
+ "jsonrpc": "2.0"
+ }
+ """;
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -553,12 +559,12 @@ public async Task NullableObjectParams_EmptyArrayParams_DontProcess()
public async Task NullableArrayParams_NullParams_SetNull()
{
const string requestJson = """
- {
- "method": "nullable_array_params",
- "params": null,
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "nullable_array_params",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ """;
object? expectedRequestData = null;
object? actualRequestData = null;
@@ -578,11 +584,11 @@ public async Task NullableArrayParams_NullParams_SetNull()
public async Task NullableArrayParams_WithoutParams_DontProcess()
{
const string requestJson = """
- {
- "method": "nullable_array_params",
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "nullable_array_params",
+ "jsonrpc": "2.0"
+ }
+ """;
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -595,12 +601,12 @@ public async Task NullableArrayParams_WithoutParams_DontProcess()
public async Task NullableArrayParams_EmptyObjectParams_DontProcess()
{
const string requestJson = """
- {
- "method": "nullable_array_params",
- "params": {},
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "nullable_array_params",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ """;
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -613,12 +619,12 @@ public async Task NullableArrayParams_EmptyObjectParams_DontProcess()
public async Task NullableArrayParams_EmptyArrayParams_SetEmptyArray()
{
const string requestJson = """
- {
- "method": "nullable_array_params",
- "params": [],
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "nullable_array_params",
+ "params": [],
+ "jsonrpc": "2.0"
+ }
+ """;
object? expectedRequestData = new List();
object? actualRequestData = null;
@@ -638,12 +644,12 @@ public async Task NullableArrayParams_EmptyArrayParams_SetEmptyArray()
public async Task DefaultParams_NullParams_DontProcess()
{
const string requestJson = """
- {
- "method": "default_params",
- "params": null,
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "default_params",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ """;
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -656,11 +662,11 @@ public async Task DefaultParams_NullParams_DontProcess()
public async Task DefaultParams_WithoutParams_DontProcess()
{
const string requestJson = """
- {
- "method": "default_params",
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "default_params",
+ "jsonrpc": "2.0"
+ }
+ """;
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -673,12 +679,12 @@ public async Task DefaultParams_WithoutParams_DontProcess()
public async Task DefaultParams_EmptyObjectParams_SetDefaultValue()
{
const string requestJson = """
- {
- "method": "default_params",
- "params": {},
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "default_params",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ """;
object? expectedRequestData = "123";
object? actualRequestData = null;
@@ -698,12 +704,12 @@ public async Task DefaultParams_EmptyObjectParams_SetDefaultValue()
public async Task DefaultParams_EmptyArrayParams_SetDefaultValue()
{
const string requestJson = """
- {
- "method": "default_params",
- "params": [],
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "default_params",
+ "params": [],
+ "jsonrpc": "2.0"
+ }
+ """;
object? expectedRequestData = "123";
object? actualRequestData = null;
@@ -723,12 +729,12 @@ public async Task DefaultParams_EmptyArrayParams_SetDefaultValue()
public async Task DefaultObjectParams_NullParams_SetDefault()
{
const string requestJson = """
- {
- "method": "default_object_params",
- "params": null,
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "default_object_params",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ """;
object? expectedRequestData = "123";
object? actualRequestData = null;
@@ -748,11 +754,11 @@ public async Task DefaultObjectParams_NullParams_SetDefault()
public async Task DefaultObjectParams_WithoutParams_SetDefaultValue()
{
const string requestJson = """
- {
- "method": "default_object_params",
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "default_object_params",
+ "jsonrpc": "2.0"
+ }
+ """;
object? expectedRequestData = "123";
object? actualRequestData = null;
@@ -772,12 +778,12 @@ public async Task DefaultObjectParams_WithoutParams_SetDefaultValue()
public async Task DefaultObjectParams_EmptyObjectParams_DontProcess()
{
const string requestJson = """
- {
- "method": "default_object_params",
- "params": {},
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "default_object_params",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ """;
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -790,12 +796,12 @@ public async Task DefaultObjectParams_EmptyObjectParams_DontProcess()
public async Task DefaultObjectParams_EmptyArrayParams_DontProcess()
{
const string requestJson = """
- {
- "method": "default_object_params",
- "params": [],
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "default_object_params",
+ "params": [],
+ "jsonrpc": "2.0"
+ }
+ """;
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -808,12 +814,12 @@ public async Task DefaultObjectParams_EmptyArrayParams_DontProcess()
public async Task DefaultArrayParams_NullParams_SetNull()
{
const string requestJson = """
- {
- "method": "default_array_params",
- "params": null,
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "default_array_params",
+ "params": null,
+ "jsonrpc": "2.0"
+ }
+ """;
object? expectedRequestData = null;
object? actualRequestData = null;
@@ -833,11 +839,11 @@ public async Task DefaultArrayParams_NullParams_SetNull()
public async Task DefaultArrayParams_WithoutParams_SetDefault()
{
const string requestJson = """
- {
- "method": "default_array_params",
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "default_array_params",
+ "jsonrpc": "2.0"
+ }
+ """;
object? expectedRequestData = null;
object? actualRequestData = null;
@@ -857,12 +863,12 @@ public async Task DefaultArrayParams_WithoutParams_SetDefault()
public async Task DefaultArrayParams_EmptyObjectParams_DontProcess()
{
const string requestJson = """
- {
- "method": "default_array_params",
- "params": {},
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "default_array_params",
+ "params": {},
+ "jsonrpc": "2.0"
+ }
+ """;
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -875,12 +881,12 @@ public async Task DefaultArrayParams_EmptyObjectParams_DontProcess()
public async Task DefaultArrayParams_EmptyArrayParams_SetEmptyArray()
{
const string requestJson = """
- {
- "method": "default_array_params",
- "params": [],
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "default_array_params",
+ "params": [],
+ "jsonrpc": "2.0"
+ }
+ """;
object? expectedRequestData = new List();
object? actualRequestData = null;
@@ -900,11 +906,11 @@ public async Task DefaultArrayParams_EmptyArrayParams_SetEmptyArray()
public async Task NoParams_ProcessSuccessfully()
{
const string requestJson = """
- {
- "method": "no_params",
- "jsonrpc": "2.0"
- }
- """;
+ {
+ "method": "no_params",
+ "jsonrpc": "2.0"
+ }
+ """;
using var request = new StringContent(requestJson, Encoding.UTF8, "application/json");
var response = await ApiClient.PostAsync(JsonRpcUrl, request);
@@ -915,13 +921,14 @@ public async Task NoParams_ProcessSuccessfully()
[Test]
public async Task SnakeCaseParams_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- {
- "method": "snake_case_params",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """;
+ const string requestJson =
+ $$"""
+ {
+ "method": "snake_case_params",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """;
var expectedRequestData = TestData.Plain;
TestData actualRequestData = null;
@@ -938,13 +945,14 @@ public async Task SnakeCaseParams_DeserializeSuccessfully()
[Test]
public async Task CamelCaseParams_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- {
- "method": "camelCaseParams",
- "params": {{TestData.PlainRequiredCamelCaseJson}},
- "jsonrpc": "2.0"
- }
- """;
+ const string requestJson =
+ $$"""
+ {
+ "method": "camelCaseParams",
+ "params": {{TestData.PlainRequiredCamelCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """;
var expectedRequestData = TestData.Plain;
TestData actualRequestData = null;
@@ -961,13 +969,14 @@ public async Task CamelCaseParams_DeserializeSuccessfully()
[Test]
public async Task CustomActionRoute_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- {
- "method": "custom_action_route",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """;
+ const string requestJson =
+ $$"""
+ {
+ "method": "custom_action_route",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """;
var expectedRequestData = TestData.Plain;
TestData actualRequestData = null;
@@ -984,13 +993,14 @@ public async Task CustomActionRoute_DeserializeSuccessfully()
[Test]
public async Task CustomControllerRoute_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- {
- "method": "custom_controller_route",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """;
+ const string requestJson =
+ $$"""
+ {
+ "method": "custom_controller_route",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """;
var expectedRequestData = TestData.Plain;
TestData actualRequestData = null;
diff --git a/src/tests/Tochka.JsonRpc.Server.Tests.Integration/RequestTests.cs b/src/tests/Tochka.JsonRpc.Server.Tests.Integration/RequestTests.cs
index 1091c185..9cf140c5 100644
--- a/src/tests/Tochka.JsonRpc.Server.Tests.Integration/RequestTests.cs
+++ b/src/tests/Tochka.JsonRpc.Server.Tests.Integration/RequestTests.cs
@@ -35,23 +35,25 @@ protected override void SetupServices(IServiceCollection services)
[Test]
public async Task StringId_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- {
- "method": "process_anything",
- "id": "123",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """;
+ const string requestJson =
+ $$"""
+ {
+ "method": "process_anything",
+ "id": "123",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """;
var expectedRequestData = TestData.Plain;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
TestData actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -71,23 +73,25 @@ public async Task StringId_DeserializeSuccessfully()
[Test]
public async Task IntId_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- {
- "method": "process_anything",
- "id": 123,
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """;
+ const string requestJson =
+ $$"""
+ {
+ "method": "process_anything",
+ "id": 123,
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """;
var expectedRequestData = TestData.Plain;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- {
- "id": 123,
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ {
+ "id": 123,
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
TestData actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -107,23 +111,25 @@ public async Task IntId_DeserializeSuccessfully()
[Test]
public async Task NullId_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- {
- "method": "process_anything",
- "id": null,
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """;
+ const string requestJson =
+ $$"""
+ {
+ "method": "process_anything",
+ "id": null,
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """;
var expectedRequestData = TestData.Plain;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- {
- "id": null,
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ {
+ "id": null,
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
TestData actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -143,23 +149,25 @@ public async Task NullId_DeserializeSuccessfully()
[Test]
public async Task ActionOnly_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- {
- "method": "action_only",
- "id": "123",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """;
+ const string requestJson =
+ $$"""
+ {
+ "method": "action_only",
+ "id": "123",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """;
var expectedRequestData = TestData.Plain;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
TestData actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -179,23 +187,25 @@ public async Task ActionOnly_DeserializeSuccessfully()
[Test]
public async Task ControllerAndAction_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- {
- "method": "simple_json_rpc.controller_and_action",
- "id": "123",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """;
+ const string requestJson =
+ $$"""
+ {
+ "method": "simple_json_rpc.controller_and_action",
+ "id": "123",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """;
var expectedRequestData = TestData.Plain;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
TestData actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -215,25 +225,27 @@ public async Task ControllerAndAction_DeserializeSuccessfully()
[Test]
public async Task BindingStyleDefault_ObjectParams_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- {
- "method": "binding_style_default",
- "id": "123",
- "params": {
- "data": {{TestData.PlainRequiredSnakeCaseJson}}
- },
- "jsonrpc": "2.0"
- }
- """;
+ const string requestJson =
+ $$"""
+ {
+ "method": "binding_style_default",
+ "id": "123",
+ "params": {
+ "data": {{TestData.PlainRequiredSnakeCaseJson}}
+ },
+ "jsonrpc": "2.0"
+ }
+ """;
var expectedRequestData = TestData.Plain;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
TestData actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -253,25 +265,27 @@ public async Task BindingStyleDefault_ObjectParams_DeserializeSuccessfully()
[Test]
public async Task BindingStyleDefault_ArrayParams_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- {
- "method": "binding_style_default",
- "id": "123",
- "params": [
- {{TestData.PlainRequiredSnakeCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """;
+ const string requestJson =
+ $$"""
+ {
+ "method": "binding_style_default",
+ "id": "123",
+ "params": [
+ {{TestData.PlainRequiredSnakeCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """;
var expectedRequestData = TestData.Plain;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
TestData actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -430,23 +444,25 @@ public async Task BindingStyleDefault_EmptyArrayParams_ReturnError()
[Test]
public async Task BindingStyleObject_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- {
- "method": "binding_style_object",
- "id": "123",
- "params": {{TestData.PlainRequiredSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """;
+ const string requestJson =
+ $$"""
+ {
+ "method": "binding_style_object",
+ "id": "123",
+ "params": {{TestData.PlainRequiredSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """;
var expectedRequestData = TestData.Plain;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
TestData actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -608,25 +624,27 @@ public async Task BindingStyleObject_EmptyArrayParams_ReturnError()
[Test]
public async Task BindingStyleArray_DeserializeSuccessfully()
{
- const string requestJson = $$"""
- {
- "method": "binding_style_array",
- "id": "123",
- "params": [
- {{TestData.PlainRequiredSnakeCaseJson}}
- ],
- "jsonrpc": "2.0"
- }
- """;
+ const string requestJson =
+ $$"""
+ {
+ "method": "binding_style_array",
+ "id": "123",
+ "params": [
+ {{TestData.PlainRequiredSnakeCaseJson}}
+ ],
+ "jsonrpc": "2.0"
+ }
+ """;
var expectedRequestData = new List { TestData.Plain };
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
object? actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -762,13 +780,14 @@ public async Task BindingStyleArray_EmptyArrayParams_SetEmptyArray()
""";
var expectedRequestData = new List();
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
object? actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -939,13 +958,14 @@ public async Task NullableObjectParams_NullParams_SetNull()
""";
object? expectedRequestData = null;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
object? actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -1010,13 +1030,14 @@ public async Task NullableObjectParams_EmptyObjectParams_SetEmptyObject()
}
""";
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
object? actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -1083,13 +1104,14 @@ public async Task NullableArrayParams_NullParams_SetNull()
""";
object? expectedRequestData = null;
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
object? actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -1190,13 +1212,14 @@ public async Task NullableArrayParams_EmptyArrayParams_SetEmptyArray()
""";
object? expectedRequestData = new List();
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
object? actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -1297,13 +1320,14 @@ public async Task DefaultParams_EmptyObjectParams_SetDefault()
""";
object? expectedRequestData = "123";
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
object? actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -1335,13 +1359,14 @@ public async Task DefaultParams_EmptyArrayParams_SetDefault()
""";
object? expectedRequestData = "123";
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
object? actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -1373,13 +1398,14 @@ public async Task DefaultObjectParams_NullParams_SetDefault()
""";
object? expectedRequestData = "123";
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
object? actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny()))
@@ -1410,13 +1436,14 @@ public async Task DefaultObjectParams_WithoutParams_SetDefault()
""";
object? expectedRequestData = "123";
var responseData = TestData.Plain;
- var expectedResponseJson = $$"""
- {
- "id": "123",
- "result": {{TestData.PlainFullSnakeCaseJson}},
- "jsonrpc": "2.0"
- }
- """.TrimAllLines();
+ var expectedResponseJson =
+ $$"""
+ {
+ "id": "123",
+ "result": {{TestData.PlainFullSnakeCaseJson}},
+ "jsonrpc": "2.0"
+ }
+ """.TrimAllLines();
object? actualRequestData = null;
requestValidatorMock.Setup(static v => v.Validate(It.IsAny