@@ -621,24 +621,37 @@ public async System.Threading.Tasks.Task TestSnapshotDuplicateSuppressedMappings
621621 // Regression test: two diff entries with identical identity+map both suppressed would add
622622 // the same snapshot index to itemsToRemove twice, causing ArgumentOutOfRangeException
623623 // with List<int> but is safe with HashSet<int>.
624- var baseProfile = CreateProfileWithDuplicateSuppressedMappings ( testCase ) ;
625624 var resolver = new CachedResolver ( ZipSource . CreateValidationSource ( ) ) ;
625+ var inheritedMapping = await FindInheritedAccountMappingAsync ( resolver ) ;
626+ var baseProfile = CreateProfileWithDuplicateSuppressedMappings ( testCase , inheritedMapping . Identity , inheritedMapping . Map ) ;
626627
627628 var generator = new SnapshotGenerator ( resolver , testCase . CreateSnapshotGeneratorSettings ( ) ) ;
628629 await generator . UpdateAsync ( baseProfile ) ;
629630 Assert . IsNotNull ( baseProfile . Snapshot , "Should have snapshot" ) ;
630631
631632 var rootElement = baseProfile . Snapshot . Element . FirstOrDefault ( e => e . Path == "Account" ) ;
632633 Assert . IsNotNull ( rootElement , "Should have Account root element" ) ;
633- var mappings = rootElement . Mapping ? . Where ( m => m . Identity == "rim" && m . Map == "Entity. Role, or Act" ) ;
634+ var mappings = rootElement . Mapping ? . Where ( m => m . Identity == inheritedMapping . Identity && m . Map == inheritedMapping . Map ) ;
634635
635636 if ( testCase . IsSuppressed )
636637 mappings . Should ( ) . HaveCount ( 0 , "Mapping should not appear in snapshot when suppressed" ) ;
637638 else
638639 mappings . Should ( ) . HaveCount ( 1 , "Mapping should appear once in snapshot when not suppressed and duplicate is removed" ) ;
639640 }
640641
641- private StructureDefinition CreateProfileWithDuplicateSuppressedMappings ( TestCase testCase )
642+ private async System . Threading . Tasks . Task < ( string Identity , string Map ) > FindInheritedAccountMappingAsync ( CachedResolver resolver )
643+ {
644+ var account = await resolver . FindStructureDefinitionAsync ( "http://hl7.org/fhir/StructureDefinition/Account" ) ;
645+ var rootElement = account ? . Snapshot ? . Element ? . FirstOrDefault ( e => e . Path == "Account" ) ;
646+ var inheritedMapping = rootElement ? . Mapping ? . FirstOrDefault ( m => m . Identity == "rim" ) ;
647+
648+ Assert . IsNotNull ( inheritedMapping , "Base Account snapshot should contain a rim mapping" ) ;
649+ Assert . IsFalse ( string . IsNullOrEmpty ( inheritedMapping . Map ) , "Base Account rim mapping should have a map" ) ;
650+
651+ return ( inheritedMapping . Identity , inheritedMapping . Map ) ;
652+ }
653+
654+ private StructureDefinition CreateProfileWithDuplicateSuppressedMappings ( TestCase testCase , string identity , string map )
642655 {
643656 return new StructureDefinition
644657 {
@@ -662,15 +675,15 @@ private StructureDefinition CreateProfileWithDuplicateSuppressedMappings(TestCas
662675 [
663676 new ElementDefinition . MappingComponent
664677 {
665- Identity = "rim" ,
666- Map = "Entity. Role, or Act" ,
678+ Identity = identity ,
679+ Map = map ,
667680 Extension = testCase . CreateExtension ( )
668681 } ,
669682 // Duplicate: same identity+map, also suppressed — would add same snap index twice
670683 new ElementDefinition . MappingComponent
671684 {
672- Identity = "rim" ,
673- Map = "Entity. Role, or Act" ,
685+ Identity = identity ,
686+ Map = map ,
674687 Extension = testCase . CreateExtension ( )
675688 }
676689 ]
0 commit comments