Introduce Assert.All(IEnumerable<T> collection, Predicate<T> match) and Assert.None(IEnumerable<T> collection, Predicate<T> match)
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 56/100
Direzione di ricerca
Read the existing MSTest Assert collection assertion APIs and their tests to find where predicate-based assertions belong. The issue gives examples for IEnumerable<T>, but does not specify overload details or expected failure message format. Done means Assert.All and Assert.None evaluate predicates and report useful details about the items that cause failure.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
It would also be nice to have a way to verify whether all or none of the items in an IEnumerable<T> (or IEnumerable, ...) match a given predicate.
The MSTest failure message could provide information on how many items did (not) match and even provide details on the first item (non) matching item. It could surely do this if there's only one item that did (not) match.
For example:
string[] fragments = [ "AB", "A", "BC" ];
Assert.All(fragments, f => f.Length < 3); // success
Assert.All(fragments, f => f.Length == 2); // fails as "A" does not match the predicate
Assert.None(fragments, f => f.Length > 2); // success
Assert.None(fragments, f => f.Length == 1); // fails as "A" matches the predicate
One can of course use plain LINQ, but you'll only get "true" or "false" failure messages that do not help you to pinpoint the item(s) that caused the condition to fail.
For example:
string[] fragments = [ "AB", "A", "BC" ];
Assert.IsTrue(fragments.All(f => f.Length < 3)); // success
Assert.IsTrue(fragments.All(f => f.Length == 2)); // fails as "A" does not match the predicate
Assert.IsTrue(!fragments.Any(f => f.Length > 2)); // success
Assert.IsTrue(!fragments.Any(f => f.Length == 1)); // fails as "A" matches the predicate
Perhaps such predicate support would also be useful for existing Assert methods, but that may not be necessary. I guess that - for example - Assert.IsNotEmpty(...) or Assert.IsEmpty(...) could just be modified to provide details on the (first) item that caused the assert to fail.
Sorry if such functionality already exist!
- Lingua principale
- C#
- Stelle
- 1.1k
- Fork
- 314
- Merge medio
- 11h 9m
- PR unite (30g)
- 340
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoft/testfx
-
type/breaking-change
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
I maintainer di solito rispondono entro 1 giorno
-
Remove obsolete MSTest 5 and Microsoft.Testing.Platform 3 compatibility APIs and configuration aliasesForse già presa @Evangelink l’ha presa oggi. Apertatype/breaking-change
microsoft/testfx#12312 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
area/assertion needs/triage
Difficoltà 5/5 Più di una settimana Idoneità per principianti 42/100
I maintainer di solito rispondono entro 1 giorno
-
type/automation type/test-gap
Difficoltà 3/5 Mezza giornata Idoneità per principianti 15/100
I maintainer di solito rispondono entro 1 giorno
-
The productive version of Microsoft.Testing.Extensions.HangDump must not reference to a preview version of Microsoft.Diagnostics.NETCore.ClientForse già presa @Evangelink l’ha presa 15 giorni fa. Apertaarea/dump external/other
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
microsoft/testfx#11981 · 6 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di microsoft/testfx
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
criticalmanufacturing/cli#909 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
RadicalCSG/com.chisel#312 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
eyalgolan/statecraft-israel#3093 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
DeveloperAcademy-POSTECH/2026-C6-M10-MUSA#677 ·
I maintainer di solito rispondono entro 1 giorno
-
REQ-13 : une demande En cours perd son responsable par un simple enregistrement, et reste En coursApertaa-corriger bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
christian-raj/S-Aloha#301 ·