docs(tests): fix CommentChecker findings across tests/ — 13,392 → 0 (repo-wide scan clean)
Comment/XML-doc changes only: - add summaries to ~10k test methods, fixtures, fakes and helpers (+ <param> on theories, <returns> on async Task methods, <inheritdoc/> on interface implementations the checker can resolve) - strip ~2.6k project-tracking references (WP*, P*-*, row-NN, Task N, #NN, Component-0NN) from comments, keeping the explanatory text; reword false positives in comments only - real docs on fakes implementing BCL/library interfaces (IDisposable, ILogger, IOptionsMonitor, IAsyncLifetime) - reword the last 5 src/ false positives (CWE-1236, failures-1, year-0001, M365) Only non-comment edits: four one-line nested classes split across lines so members can carry docs. Build 0 errors / 0 warnings.
This commit is contained in:
@@ -4,7 +4,7 @@ using ZB.MOM.WW.ScadaBridge.Commons.Types.InboundApi;
|
||||
namespace ZB.MOM.WW.ScadaBridge.InboundAPI.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// WP-2 / InboundAPI-M2.6: tests for parameter validation — type checking,
|
||||
/// Tests for parameter validation — type checking,
|
||||
/// required fields, the extended type system, and RECURSIVE (nested Object /
|
||||
/// List element) type validation with path-qualified errors.
|
||||
///
|
||||
@@ -25,6 +25,7 @@ public class ParameterValidatorTests
|
||||
|
||||
// ── No / empty definitions ────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Verifies that a missing body with no parameter definitions is valid.</summary>
|
||||
[Fact]
|
||||
public void NoDefinitions_NoBody_ReturnsValid()
|
||||
{
|
||||
@@ -33,6 +34,7 @@ public class ParameterValidatorTests
|
||||
Assert.Empty(result.Parameters);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that an empty object schema is valid.</summary>
|
||||
[Fact]
|
||||
public void EmptyObjectSchema_ReturnsValid()
|
||||
{
|
||||
@@ -40,6 +42,7 @@ public class ParameterValidatorTests
|
||||
Assert.True(result.IsValid);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that an empty legacy array definition is valid.</summary>
|
||||
[Fact]
|
||||
public void EmptyLegacyArray_ReturnsValid()
|
||||
{
|
||||
@@ -49,6 +52,7 @@ public class ParameterValidatorTests
|
||||
|
||||
// ── Required / body shape ──────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Verifies that a missing required parameter is invalid.</summary>
|
||||
[Fact]
|
||||
public void RequiredParameterMissing_ReturnsInvalid()
|
||||
{
|
||||
@@ -59,6 +63,7 @@ public class ParameterValidatorTests
|
||||
Assert.Contains("Missing required parameter", result.ErrorMessage);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a body that is not an object is invalid.</summary>
|
||||
[Fact]
|
||||
public void BodyNotObject_ReturnsInvalid()
|
||||
{
|
||||
@@ -69,6 +74,7 @@ public class ParameterValidatorTests
|
||||
Assert.Contains("must be a JSON object", result.ErrorMessage);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a missing body is valid when the parameter is optional.</summary>
|
||||
[Fact]
|
||||
public void OptionalParameter_MissingBody_ReturnsValid()
|
||||
{
|
||||
@@ -80,6 +86,10 @@ public class ParameterValidatorTests
|
||||
|
||||
// ── Scalar coercion ────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Verifies that a valid value of each scalar type is coerced successfully.</summary>
|
||||
/// <param name="type">The JSON Schema type name.</param>
|
||||
/// <param name="jsonValue">The JSON text of the value.</param>
|
||||
/// <param name="expected">The expected coerced CLR value.</param>
|
||||
[Theory]
|
||||
[InlineData("boolean", "true", true)]
|
||||
[InlineData("integer", "42", (long)42)]
|
||||
@@ -94,6 +104,7 @@ public class ParameterValidatorTests
|
||||
Assert.Equal(expected, result.Parameters["val"]);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a wrong scalar type is invalid.</summary>
|
||||
[Fact]
|
||||
public void WrongScalarType_ReturnsInvalid()
|
||||
{
|
||||
@@ -105,6 +116,7 @@ public class ParameterValidatorTests
|
||||
Assert.Contains("Integer", result.ErrorMessage);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that an unknown type is invalid.</summary>
|
||||
[Fact]
|
||||
public void UnknownType_ReturnsInvalid()
|
||||
{
|
||||
@@ -117,6 +129,7 @@ public class ParameterValidatorTests
|
||||
|
||||
// ── Object / List shape + materialization ──────────────────────────────────
|
||||
|
||||
/// <summary>Verifies that an object type with no declared fields is materialized shape-only.</summary>
|
||||
[Fact]
|
||||
public void ObjectType_NoDeclaredFields_ShapeOnly_Materialized()
|
||||
{
|
||||
@@ -127,6 +140,7 @@ public class ParameterValidatorTests
|
||||
Assert.IsType<Dictionary<string, object?>>(result.Parameters["data"]);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a list type with no declared element type is materialized shape-only.</summary>
|
||||
[Fact]
|
||||
public void ListType_NoDeclaredElement_ShapeOnly_Materialized()
|
||||
{
|
||||
@@ -139,6 +153,7 @@ public class ParameterValidatorTests
|
||||
|
||||
// ── Undeclared / unexpected fields (rejected, recursively) ─────────────────
|
||||
|
||||
/// <summary>Verifies that an unexpected top-level field is invalid.</summary>
|
||||
[Fact]
|
||||
public void UnexpectedTopLevelField_ReturnsInvalid()
|
||||
{
|
||||
@@ -152,6 +167,7 @@ public class ParameterValidatorTests
|
||||
Assert.Contains("not a declared field", result.ErrorMessage);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a body containing only declared fields is still valid.</summary>
|
||||
[Fact]
|
||||
public void OnlyDeclaredFields_StillValid()
|
||||
{
|
||||
@@ -163,6 +179,7 @@ public class ParameterValidatorTests
|
||||
Assert.Equal((long)1, result.Parameters["value"]);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that an undeclared nested field is invalid with a path-qualified error.</summary>
|
||||
[Fact]
|
||||
public void UndeclaredNestedField_ReturnsInvalid_PathQualified()
|
||||
{
|
||||
@@ -180,7 +197,7 @@ public class ParameterValidatorTests
|
||||
Assert.Contains("not a declared field", result.ErrorMessage);
|
||||
}
|
||||
|
||||
// ── Nested validation: the M2.6 core ───────────────────────────────────────
|
||||
// ── Nested validation: the core cases ───────────────────────────────────────
|
||||
|
||||
private const string NestedDef = """
|
||||
{
|
||||
@@ -211,6 +228,7 @@ public class ParameterValidatorTests
|
||||
}
|
||||
""";
|
||||
|
||||
/// <summary>Verifies that a valid nested payload passes.</summary>
|
||||
[Fact]
|
||||
public void ValidNestedPayload_Passes()
|
||||
{
|
||||
@@ -229,6 +247,7 @@ public class ParameterValidatorTests
|
||||
Assert.True(result.IsValid);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a wrong scalar two levels deep is invalid with the exact path.</summary>
|
||||
[Fact]
|
||||
public void WrongScalarTwoLevelsDeep_ReturnsInvalid_WithExactPath()
|
||||
{
|
||||
@@ -247,6 +266,7 @@ public class ParameterValidatorTests
|
||||
Assert.Contains("Boolean", result.ErrorMessage);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a wrong scalar inside a list element is invalid with the element index in the path.</summary>
|
||||
[Fact]
|
||||
public void WrongScalarInsideListElement_ReturnsInvalid_WithElementIndexInPath()
|
||||
{
|
||||
@@ -268,6 +288,7 @@ public class ParameterValidatorTests
|
||||
Assert.Contains("Integer", result.ErrorMessage);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a list element of the wrong shape is invalid with the element index in the path.</summary>
|
||||
[Fact]
|
||||
public void ListElementWrongShape_ReturnsInvalid_WithElementIndexInPath()
|
||||
{
|
||||
@@ -286,6 +307,7 @@ public class ParameterValidatorTests
|
||||
Assert.Contains("Object", result.ErrorMessage);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a missing required nested field is invalid with a path-qualified error.</summary>
|
||||
[Fact]
|
||||
public void MissingRequiredNestedField_ReturnsInvalid_PathQualified()
|
||||
{
|
||||
@@ -306,6 +328,7 @@ public class ParameterValidatorTests
|
||||
|
||||
// ── Empty / null edge cases ────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Verifies that an empty list against a typed element passes.</summary>
|
||||
[Fact]
|
||||
public void EmptyList_AgainstTypedElement_Passes()
|
||||
{
|
||||
@@ -317,6 +340,7 @@ public class ParameterValidatorTests
|
||||
Assert.True(result.IsValid);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a null for an optional nested scalar passes.</summary>
|
||||
[Fact]
|
||||
public void NullForOptionalNestedScalar_Passes()
|
||||
{
|
||||
@@ -333,6 +357,7 @@ public class ParameterValidatorTests
|
||||
Assert.True(result.IsValid);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a null for a required nested scalar passes.</summary>
|
||||
[Fact]
|
||||
public void NullForRequiredNestedScalar_Passes()
|
||||
{
|
||||
@@ -350,7 +375,7 @@ public class ParameterValidatorTests
|
||||
Assert.True(result.IsValid);
|
||||
}
|
||||
|
||||
// ── Recursive materialization: nested values coerced to typed CLR (#55) ─────
|
||||
// ── Recursive materialization: nested values coerced to typed CLR ─────
|
||||
|
||||
/// <summary>
|
||||
/// Recursively asserts that no value anywhere in a materialized parameter
|
||||
@@ -382,6 +407,7 @@ public class ParameterValidatorTests
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a nested object field scalar is materialized as a typed CLR value rather than a JSON element.</summary>
|
||||
[Fact]
|
||||
public void NestedObjectFieldScalar_IsTypedClr_NotJsonElement()
|
||||
{
|
||||
@@ -410,6 +436,7 @@ public class ParameterValidatorTests
|
||||
Assert.IsType<long>(order["id"]);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a list of scalars is fully coerced with no JSON element left.</summary>
|
||||
[Fact]
|
||||
public void ListOfScalars_FullyCoerced_NoJsonElement()
|
||||
{
|
||||
@@ -424,6 +451,7 @@ public class ParameterValidatorTests
|
||||
AssertNoJsonElement(nums);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the element fields of a list of objects are coerced with no JSON element left.</summary>
|
||||
[Fact]
|
||||
public void ListOfObjects_ElementFieldsCoerced_NoJsonElement()
|
||||
{
|
||||
@@ -453,6 +481,7 @@ public class ParameterValidatorTests
|
||||
Assert.IsType<double>(first["price"]);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that an object in a list in an object is fully coerced with no JSON element left.</summary>
|
||||
[Fact]
|
||||
public void DeeplyNested_ObjectInListInObject_FullyCoerced_NoJsonElement()
|
||||
{
|
||||
@@ -512,6 +541,7 @@ public class ParameterValidatorTests
|
||||
Assert.Equal(false, tag1["active"]);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a shape-only nested object is still fully coerced.</summary>
|
||||
[Fact]
|
||||
public void ShapeOnlyNestedObject_StillFullyCoerced_NoJsonElement()
|
||||
{
|
||||
@@ -540,6 +570,7 @@ public class ParameterValidatorTests
|
||||
|
||||
// ── Legacy flat-array backward-compat ──────────────────────────────────────
|
||||
|
||||
/// <summary>Verifies that a legacy flat array definition is still accepted.</summary>
|
||||
[Fact]
|
||||
public void LegacyFlatArrayDefinition_StillAccepted()
|
||||
{
|
||||
@@ -556,6 +587,8 @@ public class ParameterValidatorTests
|
||||
|
||||
// FIX 1: legacy "required":"false" string → field is optional ─────────────
|
||||
|
||||
/// <summary>Verifies that a legacy flat array field with required set to a string false is treated as optional.</summary>
|
||||
/// <param name="def">The legacy flat array definition JSON.</param>
|
||||
[Theory]
|
||||
[InlineData("""[{"name":"opt","type":"String","required":"false"}]""")]
|
||||
[InlineData("""[{"name":"opt","type":"String","required":"False"}]""")]
|
||||
@@ -569,6 +602,7 @@ public class ParameterValidatorTests
|
||||
Assert.True(result.IsValid, $"Expected optional field to be valid when absent; error: {result.ErrorMessage}");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a legacy flat array field with required false that is present and correctly typed passes.</summary>
|
||||
[Fact]
|
||||
public void LegacyFlatArray_RequiredStringFalse_FieldPresentAndTypedCorrectly_Passes()
|
||||
{
|
||||
@@ -597,6 +631,7 @@ public class ParameterValidatorTests
|
||||
return schema;
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a schema at the depth ceiling parses successfully.</summary>
|
||||
[Fact]
|
||||
public void SchemaAtDepthCeiling_ParsesSuccessfully()
|
||||
{
|
||||
@@ -606,6 +641,7 @@ public class ParameterValidatorTests
|
||||
Assert.NotNull(schema);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a schema exceeding the depth ceiling throws a JSON exception rather than overflowing the stack.</summary>
|
||||
[Fact]
|
||||
public void SchemaExceedingDepthCeiling_ThrowsJsonException_NotStackOverflow()
|
||||
{
|
||||
@@ -615,6 +651,7 @@ public class ParameterValidatorTests
|
||||
Assert.Throws<System.Text.Json.JsonException>(() => InboundApiSchema.Parse(def));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the parameter validator returns invalid for a schema exceeding the depth ceiling.</summary>
|
||||
[Fact]
|
||||
public void SchemaExceedingDepthCeiling_ParameterValidator_ReturnsInvalid()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user