Skip to content

Make filtering regression assertions reject stale entries - #1186

Open
dwcullop wants to merge 2 commits into
mainfrom
u/dacullop/main/strict-filtering-assertions
Open

dwcullop wants to merge 2 commits into
mainfrom
u/dacullop/main/strict-filtering-assertions

Conversation

@dwcullop

@dwcullop dwcullop commented Sep 21, 2026

Copy link
Copy Markdown
Member

Summary

The static Filter regression tests for the cache asserted only on counts and on membership of the items that were expected to survive. That shape passes even when the operator leaves a stale entry behind: a result set containing an extra item that should have been filtered out satisfies "contains the expected items" just fine. The assertions were weak enough to hide exactly the class of bug they exist to catch.

This change corrects the assertions to be exact rather than permissive. The result collections are now compared against the full expected set with Assert.Equivalent(..., strict: true), so any leftover entry fails the test. The setup was also tightened so the comparison is meaningful: the threshold is derived from the generated data rather than from an average, which guarantees a known starting membership, and the mutations step through a partial exclusion and then a total exclusion so the strict comparison is exercised against both a non-empty and an empty expectation.

Evidence

The assertion correction is backed by controlled mutation: each strengthened test was run against a deliberately broken operator that leaves a stale entry in place. Under the original assertions those mutants pass; under the corrected assertions they fail, and they pass again once the mutation is reverted. That confirms the new assertions are doing real work and are not merely more verbose restatements of the old ones.

Scope

Tests only, limited to src/DynamicData.Tests/Cache/FilterFixture.Static.cs. No production code is touched by this PR.

Fixes #1184

EqualItemsHaveIndexedChanges_OnlyTheSpecifiedSlotChanges covers indexed list identity, which belongs to a separate issue rather than the strict filtering assertion correction. Remove the test along with the seed constant, test output constructor, and imports that existed solely to support it, restoring the list fixture to its previous state. The cache fixture retains only the strict Assert.Equivalent changes and their direct setup.
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.

[Bug]: Filter and RemoveKey regression assertions accept stale extra entries

1 participant