IntelliTect / IntelliTect/TestTools.Console

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

Aperta Adatta ai principianti
#130 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
C#
Stelle
1
Fork
0
Merge medio
2m
PR unite (30g)
5

Descrizione

## 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.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start by reading ConsoleAssert.cs, focusing on GetMessageText and its non-wildcard mismatch loop, then compare it with WildcardMatchAnalyzer.FindMismatchPosition. Confirm how both paths report the first differing character and consolidate the duplicated logic without changing the messages. The work is done when the shared behavior is covered by the existing test suite.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
csharp
Ambito
testing-qa
Tipo di issue
Refactoring
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
68/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.