IntelliTect / IntelliTect/TestTools.Console

ConsoleAssert.GetMessageText has its own inline char-by-char diff that duplicates WildcardMatchAnalyzer.FindMismatchPosition

Offen Anfängerfreundlich
#130 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
C#
Sterne
1
Forks
0
Ø Merge
2 Min.
Gemergte PRs (30 T.)
5

Beschreibung

## Problem

\GetMessageText\ in \ConsoleAssert.cs\ contains an inline loop that finds the first character difference between two strings:

\\\csharp
// existing loop in GetMessageText
for (int i = 0; i < Math.Min(expected.Length, actual.Length); i++)
{
if (expected[i] != actual[i]) { ... }
}
\\\

PR #104 added \WildcardMatchAnalyzer.FindMismatchPosition\ which does exactly the same thing.

## Impact

This is a minor DRY issue in pre-existing code — no functional bug. The inline loop is used for the non-wildcard mismatch message while \FindMismatchPosition\ is used for the wildcard branch. Both compute the first differing character index.

## Suggestion

Extract a shared \FindFirstMismatchIndex(string expected, string actual)\ helper (or delegate the \GetMessageText\ call to \WildcardMatchAnalyzer.FindMismatchPosition\) so the logic lives in one place.

This was identified during the PR #104 review but left out because the inline loop is pre-existing code unrelated to the wildcard feature.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit dem Lesen von ConsoleAssert.cs und konzentriere dich auf GetMessageText und dessen Mismatch-Schleife ohne Wildcards. Vergleiche sie anschließend mit WildcardMatchAnalyzer.FindMismatchPosition. Bestätige, wie beide Pfade das erste unterschiedliche Zeichen melden, und führe die doppelte Logik zusammen, ohne die Meldungen zu ändern. Die Arbeit ist abgeschlossen, wenn das gemeinsame Verhalten durch die vorhandene Testsuite abgedeckt ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
csharp
Bereich
testing-qa
Issue-Typ
Refactoring
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
68/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.