Skip to content

Add short collection and type checks for migrated tests - #5

Open
ivank-ys wants to merge 3 commits into
yevhen:mainfrom
ivank-ys:add-sequence-helpers
Open

ivank-ys wants to merge 3 commits into
yevhen:mainfrom
ivank-ys:add-sequence-helpers

Conversation

@ivank-ys

Copy link
Copy Markdown

Summary

Three checks are among the most common in test suites moved from FluentAssertions, and all are long in plain C#: an exact sequence (SequenceEqual(new[] { ... })), the same items in any order (Order().SequenceEqual(expected.Order())) and an exact runtime type (GetType() == typeof(T)). This PR adds IsSequence, HasSameItems and IsExactly<T> for them, documents the existing collection quantifiers, and fixes migration mappings that checked less than FluentAssertions did.

- Assert(ids.SequenceEqual(new[] { 1, 2, 3 }));
+ Assert(ids.IsSequence(1, 2, 3));

- Assert(ids.Order().SequenceEqual(expected.Order()));
+ Assert(ids.HasSameItems(expected));

- Assert(chart.GetType() == typeof(TextChart));
+ Assert(chart.IsExactly<TextChart>());
Expected sequence [1, 2, 3], but found [1, 2, 4]: item at index 2 is 4 instead of 3.
Expected the same items as [3, 2, 1], but found [1, 2, 4]: missing [3], extra [4].
Expected type TextChart, but found ImageChart.
  • MIGRATION.md: AllSatisfy and OnlyContain failed on an empty collection in FluentAssertions, while All passes, so they now map to Any() plus Each. WithMessage maps to Matches (full match with wildcards) instead of Contains.
  • Names are open: a Contains... pair would match ContainsInOrder, but that family allows extra items, while IsSequence and HasSameItems do not.

Merge Danger

Reversibility: reversible

Blast Radius: none. New methods and docs only; existing APIs and diagnostics do not change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant