Commit 98ac36c
committed
Fix test-hygiene issues in GeneratedFactoriesTests for #1461
Two tests were interacting with the process-global ReflectionCacheSet.Shared
in ways that are unsafe under xUnit's parallel test execution:
- FactoryDelegate_CompiledGeneratorCache_ClearedByReflectionCacheSetClear
called ReflectionCacheSet.Shared.Clear(), wiping the entire process-wide
reflection cache that all other parallel tests depend on. Replaced with a
fresh new ReflectionCacheSet() instance: directly adds an entry to the
GeneratedFactoryServiceRegistrationGenerators cache, asserts NotEmpty,
calls set.Clear(), asserts Empty. Proves the cache participates in clearing
without any global side effects.
- FactoryDelegate_CompiledGeneratorCached_SiblingScopes asserted .Count
stability on the shared cache, which is perturbed by parallel test classes
populating other entries. Replaced the count-equality assertion with an
identity check: captures the cached delegate reference (TryGetValue) after
scope1, then after scope2/scope3 asserts Assert.Same on the same key —
proving no recompilation occurred for that specific key regardless of what
other tests add to the global cache.
Also adds FactoryDelegate_CompiledGeneratorCache_ClearedByReflectionCacheSetPredicateClear,
a new test (also using a fresh set instance) that exercises the predicate-based
Clear(predicate) path, proving that the Type component of the composite key
drives assembly-unload selective eviction while unrelated keys are preserved.1 parent 020f778 commit 98ac36c
1 file changed
Lines changed: 41 additions & 16 deletions
Lines changed: 41 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
475 | 475 | | |
476 | 476 | | |
477 | 477 | | |
478 | | - | |
479 | | - | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
480 | 481 | | |
481 | | - | |
| 482 | + | |
| 483 | + | |
482 | 484 | | |
483 | 485 | | |
484 | 486 | | |
485 | 487 | | |
486 | 488 | | |
487 | 489 | | |
488 | 490 | | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
493 | 495 | | |
494 | 496 | | |
495 | 497 | | |
| |||
644 | 646 | | |
645 | 647 | | |
646 | 648 | | |
647 | | - | |
648 | | - | |
649 | | - | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
650 | 657 | | |
651 | | - | |
652 | | - | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
653 | 672 | | |
654 | | - | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
655 | 678 | | |
656 | | - | |
| 679 | + | |
657 | 680 | | |
658 | | - | |
| 681 | + | |
| 682 | + | |
659 | 683 | | |
660 | | - | |
| 684 | + | |
| 685 | + | |
661 | 686 | | |
662 | 687 | | |
0 commit comments