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:
Joseph Doherty
2026-10-07 15:05:49 -04:00
parent 0ffd4bdbea
commit 513fa1aa16
998 changed files with 17896 additions and 2395 deletions
@@ -5,7 +5,7 @@ using ZB.MOM.WW.ScadaBridge.Transport.Serialization;
namespace ZB.MOM.WW.ScadaBridge.Transport.Tests.Serialization;
/// <summary>
/// Round-trip + forward-compat coverage for the M8 site/instance-scoped bundle
/// Round-trip + forward-compat coverage for the site/instance-scoped bundle
/// DTOs (<see cref="SiteDto"/>, <see cref="DataConnectionDto"/>,
/// <see cref="InstanceDto"/> and the extended <see cref="BundleContentDto"/>).
/// </summary>
@@ -90,6 +90,7 @@ public sealed class BundleDtoSerializationTests
},
};
/// <summary>Verifies that full content round-trips with deep equality.</summary>
[Fact]
public void FullContent_RoundTrips_WithDeepEquality()
{
@@ -136,6 +137,7 @@ public sealed class BundleDtoSerializationTests
Assert.Equal(original.Instances[0].ConnectionBindings[0], inst.ConnectionBindings[0]);
}
/// <summary>Verifies that enums serialize as strings for a human-readable wire format.</summary>
[Fact]
public void EnumsSerializeAsStrings_ForHumanReadableWire()
{
@@ -147,10 +149,11 @@ public sealed class BundleDtoSerializationTests
Assert.Contains("\"Double\"", json, StringComparison.Ordinal);
}
/// <summary>Verifies that legacy content missing the new arrays deserializes to empty collections rather than null.</summary>
[Fact]
public void LegacyContent_MissingNewArrays_DeserializesToEmpty_NotNull()
{
// A pre-M8 bundle content blob: only the original central-config arrays
// A legacy bundle content blob: only the original central-config arrays
// are present; sites/dataConnections/instances fields are entirely absent
// from the JSON text.
const string legacyJson = """
@@ -178,10 +181,11 @@ public sealed class BundleDtoSerializationTests
Assert.Empty(content.Instances);
}
/// <summary>Verifies that a default-constructed content has empty, non-null new arrays.</summary>
[Fact]
public void DefaultConstructed_NewArrays_AreEmpty_NotNull()
{
// Existing positional callers that never set the M8 members still get
// Existing positional callers that never set the site/instance members still get
// empty (not null) collections, so consumers can enumerate unconditionally.
var content = new BundleContentDto(
TemplateFolders: Array.Empty<TemplateFolderDto>(),
@@ -201,7 +205,7 @@ public sealed class BundleDtoSerializationTests
Assert.Empty(content.Instances);
}
// --- arch-review 2026-08-19 P7-1: ExternalSystem TimeoutSeconds wire format ---
// --- ExternalSystem TimeoutSeconds wire format ---
/// <summary>
/// Pins the old-bundle semantics: a bundle written before <c>TimeoutSeconds</c>
@@ -249,6 +253,7 @@ public sealed class BundleDtoSerializationTests
// --- S10: SMS recipient PhoneNumber + SmsConfig wire format ---------------
/// <summary>Verifies that a legacy recipient missing a phone number deserializes to null.</summary>
[Fact]
public void LegacyRecipient_MissingPhoneNumber_DeserializesToNull()
{
@@ -283,11 +288,12 @@ public sealed class BundleDtoSerializationTests
Assert.Null(recipient.PhoneNumber);
}
/// <summary>Verifies that legacy content missing the SMS configs array deserializes to an empty collection rather than null.</summary>
[Fact]
public void LegacyContent_MissingSmsConfigsArray_DeserializesToEmpty_NotNull()
{
// A pre-SMS bundle has no smsConfigs field; the importer must see an empty
// (never null) collection — same forward-compat invariant as the M8 arrays.
// (never null) collection — same forward-compat invariant as the site/instance arrays.
const string legacyJson = """
{
"TemplateFolders": [],
@@ -308,6 +314,7 @@ public sealed class BundleDtoSerializationTests
Assert.Empty(content.SmsConfigs);
}
/// <summary>Verifies that a default-constructed content has an empty, non-null SMS configs collection.</summary>
[Fact]
public void DefaultConstructed_SmsConfigs_IsEmpty_NotNull()
{
@@ -325,6 +332,7 @@ public sealed class BundleDtoSerializationTests
Assert.Empty(content.SmsConfigs);
}
/// <summary>Verifies that the SMS config auth token rides the secrets block rather than cleartext public fields.</summary>
[Fact]
public void SmsConfig_AuthToken_RidesSecretsBlock_NotCleartextPublicFields()
{
@@ -8,7 +8,7 @@ namespace ZB.MOM.WW.ScadaBridge.Transport.Tests.Serialization;
public sealed class BundleSerializerTests
{
// Commons-015 sets the documented PBKDF2 floor to 100_000 (OWASP minimum).
// The documented PBKDF2 floor is 100_000 (OWASP minimum).
// Using the floor keeps the suite fast while passing EncryptionMetadata
// validation.
private const int TestIterations = EncryptionMetadata.MinPbkdf2Iterations;
@@ -33,6 +33,7 @@ public sealed class BundleSerializerTests
contents: Array.Empty<ManifestContentEntry>(),
contentBytes: contentBytes);
/// <summary>Verifies that packing without a passphrase emits a manifest and plain JSON content.</summary>
[Fact]
public void Pack_emits_manifest_and_content_json_when_no_passphrase()
{
@@ -49,6 +50,7 @@ public sealed class BundleSerializerTests
Assert.Null(archive.GetEntry("content.enc"));
}
/// <summary>Verifies that packing with a passphrase emits a manifest and encrypted content.</summary>
[Fact]
public void Pack_emits_manifest_and_content_enc_when_passphrase_supplied()
{
@@ -67,6 +69,7 @@ public sealed class BundleSerializerTests
Assert.NotNull(archive.GetEntry("content.enc"));
}
/// <summary>Verifies that a round trip through a temporary stream recovers identical content.</summary>
[Fact]
public void Roundtrip_through_temp_stream_recovers_identical_content()
{
@@ -91,6 +94,7 @@ public sealed class BundleSerializerTests
Assert.Equal("return 42;", shared.Code);
}
/// <summary>Verifies that reading the manifest throws when the archive has no manifest file.</summary>
[Fact]
public void ReadManifest_throws_when_zip_missing_manifest_json()
{
@@ -107,6 +111,7 @@ public sealed class BundleSerializerTests
Assert.Throws<InvalidDataException>(() => sut.ReadManifest(ms));
}
/// <summary>Verifies that unpacking throws a CryptographicException when the passphrase is wrong.</summary>
[Fact]
public void UnpackContent_throws_CryptographicException_on_wrong_passphrase()
{
@@ -24,6 +24,8 @@ public sealed class EntitySerializerTests
SmtpConfigurations: Array.Empty<SmtpConfiguration>(),
ApiMethods: Array.Empty<ApiMethod>());
/// <summary>Verifies that converting an external system to a DTO carves its credentials into the secrets block.</summary>
/// <returns>The result.</returns>
[Fact]
public void ToDto_carves_external_system_credentials_into_secrets_block()
{
@@ -47,6 +49,8 @@ public sealed class EntitySerializerTests
Assert.Equal("ApiKey", dtoSys.AuthType);
}
/// <summary>Verifies that converting an SMTP config to a DTO carves its password into the secrets block.</summary>
/// <returns>The result.</returns>
[Fact]
public void ToDto_carves_smtp_password_into_secrets_block()
{
@@ -67,6 +71,8 @@ public sealed class EntitySerializerTests
Assert.Equal(587, dtoSmtp.Port);
}
/// <summary>Verifies that a template round trip preserves its attributes, alarms, scripts and compositions.</summary>
/// <returns>The result.</returns>
[Fact]
public void Roundtrip_template_preserves_attributes_alarms_scripts_composition()
{
@@ -99,7 +105,7 @@ public sealed class EntitySerializerTests
TriggerType = AlarmTriggerType.RangeViolation,
TriggerConfiguration = "{\"threshold\":100}",
IsLocked = false,
// FU-B / #37 — alarm fires "OnUpdate" script when triggered. The FK is
// Alarm fires "OnUpdate" script when triggered. The FK is
// an in-aggregate script id; the DTO carries the name and the
// importer resolves the FK on the way back in.
OnTriggerScriptId = 1,
@@ -122,7 +128,7 @@ public sealed class EntitySerializerTests
var sut = new EntitySerializer();
var dto = sut.ToBundleContent(aggregate);
// FU-B / #37 — verify the DTO carries OnTriggerScriptName by NAME (not id).
// Verify the DTO carries OnTriggerScriptName by NAME (not id).
// The bundle is portable across environments so a script-id FK can't
// survive a round-trip; resolution back to a script id is the importer's
// job once the parent template's scripts have been re-persisted.
@@ -159,6 +165,8 @@ public sealed class EntitySerializerTests
Assert.Equal("MotorA", rtComp.InstanceName);
}
/// <summary>Verifies that a template round trip preserves the locked-in-derived flag on attributes, alarms and scripts.</summary>
/// <returns>The result.</returns>
[Fact]
public void Roundtrip_template_preserves_LockedInDerived_on_attribute_alarm_script()
{
@@ -202,6 +210,8 @@ public sealed class EntitySerializerTests
Assert.True(Assert.Single(rtBasic.Scripts).LockedInDerived);
}
/// <summary>Verifies that a template round trip preserves its native alarm sources.</summary>
/// <returns>The result.</returns>
[Fact]
public void Roundtrip_template_preserves_NativeAlarmSources()
{
@@ -244,6 +254,8 @@ public sealed class EntitySerializerTests
Assert.True(rtSrc.LockedInDerived);
}
/// <summary>Verifies that old-form bundle JSON without the locked-in-derived field deserializes it as false.</summary>
/// <returns>The result.</returns>
[Fact]
public void OldForm_bundle_json_without_LockedInDerived_deserializes_to_false()
{
@@ -294,6 +306,8 @@ public sealed class EntitySerializerTests
Assert.False(Assert.Single(template.Scripts).LockedInDerived);
}
/// <summary>Verifies that a round trip preserves the MES-reportable flag on alarms and instance overrides.</summary>
/// <returns>The result.</returns>
[Fact]
public void Roundtrip_preserves_IsMesReportable_on_alarm_and_instance_override()
{
@@ -332,6 +346,8 @@ public sealed class EntitySerializerTests
Assert.False(Assert.Single(Assert.Single(restored.Instances).AlarmOverrides).IsMesReportableOverride);
}
/// <summary>Verifies that old-form bundle JSON without the MES-reportable field deserializes it as false on alarms and null on overrides.</summary>
/// <returns>The result.</returns>
[Fact]
public void OldForm_bundle_json_without_IsMesReportable_deserializes_to_false_and_null()
{
@@ -394,6 +410,8 @@ public sealed class EntitySerializerTests
Assert.Null(over.IsMesReportableOverride);
}
/// <summary>Verifies that a template folder round trip preserves the folder hierarchy.</summary>
/// <returns>The result.</returns>
[Fact]
public void Roundtrip_template_folder_preserves_hierarchy()
{
@@ -419,6 +437,8 @@ public sealed class EntitySerializerTests
Assert.Equal(rtRoot.Id, rtChild.ParentFolderId);
}
/// <summary>Verifies that an external system round trip preserves its retry configuration.</summary>
/// <returns>The result.</returns>
[Fact]
public void Roundtrip_external_system_preserves_retry_config()
{
@@ -441,7 +461,7 @@ public sealed class EntitySerializerTests
}
/// <summary>
/// arch-review 2026-08-19 P7-1 (row-27 shape): <c>TimeoutSeconds</c> is operative at
/// <c>TimeoutSeconds</c> is operative at
/// runtime (the per-system HTTP timeout) but was silently dropped by the export/import
/// DTO — same defect class as the earlier <c>MaxRetries</c>/<c>RetryDelay</c> holes this
/// test's sibling covers.
@@ -494,6 +514,8 @@ public sealed class EntitySerializerTests
Assert.Equal(0, sys.TimeoutSeconds);
}
/// <summary>Verifies that converting a DTO with a null secrets block yields an entity with default empty secrets.</summary>
/// <returns>The result.</returns>
[Fact]
public void FromDto_with_null_SecretsBlock_yields_entity_with_default_empty_secrets()
{
@@ -516,6 +538,8 @@ public sealed class EntitySerializerTests
Assert.Null(sys.AuthConfiguration);
}
/// <summary>Verifies that a list attribute round trip preserves its element data type.</summary>
/// <returns>The result.</returns>
[Fact]
public void Roundtrip_List_attribute_preserves_ElementDataType()
{
@@ -585,6 +609,8 @@ public sealed class EntitySerializerTests
ApiMethods: Array.Empty<ApiMethodDto>());
}
/// <summary>Verifies that import normalizes an old-form Int32 list value to native JSON.</summary>
/// <returns>The result.</returns>
[Fact]
public void Import_normalizes_old_form_Int32_list_value_to_native_json()
{
@@ -600,6 +626,8 @@ public sealed class EntitySerializerTests
Assert.Equal("[10,20]", attr.Value);
}
/// <summary>Verifies that import leaves a string list value quoted.</summary>
/// <returns>The result.</returns>
[Fact]
public void Import_leaves_string_list_value_quoted()
{
@@ -614,6 +642,8 @@ public sealed class EntitySerializerTests
Assert.Equal("[\"a\",\"b\"]", attr.Value);
}
/// <summary>Verifies that import leaves a malformed list value unchanged without throwing.</summary>
/// <returns>The result.</returns>
[Fact]
public void Import_leaves_malformed_list_value_unchanged_without_throwing()
{
@@ -628,6 +658,8 @@ public sealed class EntitySerializerTests
Assert.Equal("[\"a\"", attr.Value);
}
/// <summary>Verifies that import leaves a scalar attribute value unchanged.</summary>
/// <returns>The result.</returns>
[Fact]
public void Import_leaves_scalar_attribute_value_unchanged()
{
@@ -667,6 +699,8 @@ public sealed class EntitySerializerTests
Assert.Equal("42.0", attr.Value);
}
/// <summary>Verifies that a scalar attribute round trip keeps a null element data type as null.</summary>
/// <returns>The result.</returns>
[Fact]
public void Roundtrip_scalar_attribute_with_null_ElementDataType_remains_null()
{
@@ -699,7 +733,7 @@ public sealed class EntitySerializerTests
Assert.Null(rtAttr.ElementDataType);
}
// --- M8 (B2): site / data-connection / instance mapping ------------------
// --- Site / data-connection / instance mapping ------------------
/// <summary>
/// Builds a populated aggregate: one template (so the instance's TemplateName
@@ -768,6 +802,8 @@ public sealed class EntitySerializerTests
};
}
/// <summary>Verifies that converting a site, connection and instance to DTOs maps secrets and name links.</summary>
/// <returns>The result.</returns>
[Fact]
public void ToDto_maps_site_connection_instance_with_secrets_and_name_links()
{
@@ -831,6 +867,8 @@ public sealed class EntitySerializerTests
Assert.Equal("ns=2;s=Pump1.P", dtoBinding.DataSourceReferenceOverride);
}
/// <summary>Verifies that converting a connection to a DTO omits the secret key when the backup configuration is empty.</summary>
/// <returns>The result.</returns>
[Fact]
public void ToDto_omits_secret_key_when_backup_configuration_is_empty()
{
@@ -857,6 +895,8 @@ public sealed class EntitySerializerTests
Assert.False(dtoConn.Secrets.Values.ContainsKey("BackupConfiguration"));
}
/// <summary>Verifies that a site, connection and instance round trip restores configuration from the secrets and binding names.</summary>
/// <returns>The result.</returns>
[Fact]
public void Roundtrip_site_connection_instance_restores_config_from_secrets_and_binding_name()
{
@@ -911,6 +951,8 @@ public sealed class EntitySerializerTests
// --- S10: SMS recipient PhoneNumber + SmsConfiguration round-trip ---------
/// <summary>Verifies that converting an SMS recipient to a DTO carries its phone number.</summary>
/// <returns>The result.</returns>
[Fact]
public void ToDto_carries_sms_recipient_phone_number()
{
@@ -930,6 +972,8 @@ public sealed class EntitySerializerTests
Assert.Null(dtoRecipient.EmailAddress);
}
/// <summary>Verifies that an SMS recipient round trip preserves the phone number.</summary>
/// <returns>The result.</returns>
[Fact]
public void Roundtrip_sms_recipient_preserves_phone_number()
{
@@ -948,6 +992,8 @@ public sealed class EntitySerializerTests
Assert.Null(rtRecipient.EmailAddress);
}
/// <summary>Verifies that an email recipient round trip preserves the email address and leaves the phone number null.</summary>
/// <returns>The result.</returns>
[Fact]
public void Roundtrip_email_recipient_preserves_email_and_leaves_phone_null()
{
@@ -969,6 +1015,8 @@ public sealed class EntitySerializerTests
Assert.Null(rtRecipient.PhoneNumber);
}
/// <summary>Verifies that a recipient round trip preserves both the email address and the phone number.</summary>
/// <returns>The result.</returns>
[Fact]
public void Roundtrip_recipient_with_both_contacts_preserves_both()
{
@@ -989,6 +1037,8 @@ public sealed class EntitySerializerTests
Assert.Equal("+15559876543", rtRecipient.PhoneNumber);
}
/// <summary>Verifies that converting a recipient DTO without a phone number yields a null phone number.</summary>
/// <returns>The result.</returns>
[Fact]
public void FromDto_recipient_without_phone_number_yields_null_phone()
{
@@ -1017,6 +1067,8 @@ public sealed class EntitySerializerTests
Assert.Null(recipient.PhoneNumber);
}
/// <summary>Verifies that converting an SMS config to a DTO carves its auth token into the secrets block.</summary>
/// <returns>The result.</returns>
[Fact]
public void ToDto_carves_sms_auth_token_into_secrets_block()
{
@@ -1045,6 +1097,8 @@ public sealed class EntitySerializerTests
Assert.DoesNotContain("twilio-super-secret", dtoSms.FromNumber);
}
/// <summary>Verifies that an SMS config round trip restores the auth token from the secrets block.</summary>
/// <returns>The result.</returns>
[Fact]
public void Roundtrip_sms_config_restores_auth_token_from_secrets_block()
{
@@ -1075,6 +1129,8 @@ public sealed class EntitySerializerTests
Assert.Equal("twilio-super-secret", rtSms.AuthToken);
}
/// <summary>Verifies that converting an SMS config to a DTO omits the secret key when the auth token is null.</summary>
/// <returns>The result.</returns>
[Fact]
public void ToDto_omits_sms_secret_key_when_auth_token_is_null()
{
@@ -1095,6 +1151,8 @@ public sealed class EntitySerializerTests
// --- EWS: Transport + the pre-existing OAuth2 authority/scope drop ---------
/// <summary>Verifies that an SMTP config round trip preserves the transport and OAuth2 fields.</summary>
/// <returns>The result.</returns>
[Fact]
public void Roundtrip_smtp_config_preserves_transport_and_oauth2_fields()
{
@@ -1143,6 +1201,8 @@ public sealed class EntitySerializerTests
Assert.Equal(TimeSpan.FromSeconds(90), rtSmtp.RetryDelay);
}
/// <summary>Verifies that converting an SMTP config DTO without transport or OAuth2 fields yields nulls.</summary>
/// <returns>The result.</returns>
[Fact]
public void FromDto_smtp_config_without_transport_or_oauth2_fields_yields_nulls()
{
@@ -1182,6 +1242,8 @@ public sealed class EntitySerializerTests
Assert.Equal("smtp.example.com", smtp.Host);
}
/// <summary>Verifies that an SMTP config DTO omits null transport and OAuth2 fields from its JSON.</summary>
/// <returns>The result.</returns>
[Fact]
public void SmtpConfigDto_omits_null_transport_and_oauth2_fields_from_json()
{
@@ -10,11 +10,12 @@ public sealed class ManifestBuilderTests
private static BundleSummary EmptySummary => new(0, 0, 0, 0, 0, 0, 0, 0);
private static IReadOnlyList<ManifestContentEntry> NoContents => Array.Empty<ManifestContentEntry>();
/// <summary>Verifies that building a manifest populates the summary from the contents.</summary>
[Fact]
public void Build_populates_summary_from_contents()
{
var sut = new ManifestBuilder();
// M8 (B3): summary now carries trailing Sites/DataConnections/Instances counts.
// Summary now carries trailing Sites/DataConnections/Instances counts.
var summary = new BundleSummary(2, 1, 0, 0, 0, 0, 0, 0, Sites: 3, DataConnections: 4, Instances: 5);
var contents = new[]
{
@@ -26,7 +27,7 @@ public sealed class ManifestBuilderTests
var manifest = sut.Build("env", "user", "1.0.0", encryption: null, summary, contents, contentBytes: new byte[] { 1, 2, 3 });
Assert.Equal(summary, manifest.Summary);
// New M8 summary counts flow through the builder verbatim.
// New summary counts flow through the builder verbatim.
Assert.Equal(3, manifest.Summary.Sites);
Assert.Equal(4, manifest.Summary.DataConnections);
Assert.Equal(5, manifest.Summary.Instances);
@@ -35,11 +36,12 @@ public sealed class ManifestBuilderTests
Assert.Equal("user", manifest.ExportedBy);
Assert.Equal("1.0.0", manifest.ScadaBridgeVersion);
Assert.Equal(1, manifest.BundleFormatVersion);
// M8 (B3): schema minor bumped 1.0 → 1.1; format version stays 1.
// Schema minor bumped 1.0 → 1.1; format version stays 1.
Assert.Equal("1.1", manifest.SchemaVersion);
Assert.Null(manifest.Encryption);
}
/// <summary>Verifies that building a manifest computes a content hash with the sha256 prefix.</summary>
[Fact]
public void Build_computes_content_hash_with_sha256_prefix()
{
@@ -52,6 +54,7 @@ public sealed class ManifestBuilderTests
Assert.Equal("sha256:" + expectedHashHex, manifest.ContentHash);
}
/// <summary>Verifies that validation rejects an unsupported bundle format version.</summary>
[Fact]
public void Validate_rejects_unsupported_bundleFormatVersion()
{
@@ -74,6 +77,7 @@ public sealed class ManifestBuilderTests
Assert.Equal(ManifestValidationResult.UnsupportedFormatVersion, result);
}
/// <summary>Verifies that validation rejects a manifest whose content hash does not match.</summary>
[Fact]
public void Validate_rejects_when_contentHash_mismatch()
{
@@ -95,6 +99,7 @@ public sealed class ManifestBuilderTests
Assert.Equal(ManifestValidationResult.ContentHashMismatch, result);
}
/// <summary>Verifies that validation accepts a well-formed version 1 manifest.</summary>
[Fact]
public void Validate_accepts_well_formed_v1_manifest()
{
@@ -107,10 +112,11 @@ public sealed class ManifestBuilderTests
Assert.Equal(ManifestValidationResult.Ok, result);
}
/// <summary>Verifies that validation accepts an older schema version 1.0 manifest.</summary>
[Fact]
public void Validate_accepts_older_schemaVersion_1_0_manifest()
{
// An older "1.0" bundle (pre-M8) must still import: schema minor differences
// An older "1.0" bundle must still import: schema minor differences
// are additive and the validator gates only on BundleFormatVersion.
var bytes = Encoding.UTF8.GetBytes("legacy-bundle");
var hash = "sha256:" + Convert.ToHexString(SHA256.HashData(bytes)).ToLowerInvariant();
@@ -131,6 +137,7 @@ public sealed class ManifestBuilderTests
Assert.Equal(ManifestValidationResult.Ok, result);
}
/// <summary>Verifies that validation refuses bundle format version 2.</summary>
[Fact]
public void Validate_refuses_bundleFormatVersion_2()
{