-
Notifications
You must be signed in to change notification settings - Fork 568
Add tests to improve R4.Core tests coverage #5260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| { | ||
| // Arrange | ||
| const string operationName = "export"; | ||
| var cancellationTokenSource = new CancellationTokenSource(); |
Check warning
Code scanning / CodeQL
Missing Dispose call on local IDisposable Warning
...oft.Health.Fhir.R4.Core.UnitTests/Features/Operations/MemberMatch/MemberMatchServiceTests.cs
Fixed
Show fixed
Hide fixed
| foreach (var type in new[] { "ValueSet", "CodeSystem", "StructureDefinition" }) | ||
| { | ||
| if (type != resourceType) | ||
| { | ||
| _searchService.SearchAsync( | ||
| type, | ||
| Arg.Any<List<Tuple<string, string>>>(), | ||
| Arg.Any<CancellationToken>()) | ||
| .Returns(new SearchResult(new List<SearchResultEntry>(), null, null, new List<Tuple<string, string>>())); | ||
| } | ||
| } |
Check notice
Code scanning / CodeQL
Missed opportunity to use Where Note
implicitly filters its target sequence
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 days ago
To address the issue, the foreach loop in SetupSearchServiceWithResults should iterate only over elements where type != resourceType, utilizing LINQ's .Where(...) method for clarity and intent. The if (type != resourceType) guard inside the loop becomes superfluous and should be removed. There is no change to existing functionality—just a refactor to express filtering more idiomatically. Only the loop over the array on line 322–332 in SetupSearchServiceWithResults needs to be updated. Since System.Linq is already imported (line 8), no imports are required.
-
Copy modified line R322 -
Copy modified lines R324-R328
| @@ -319,16 +319,13 @@ | ||
| .Returns(searchResult); | ||
|
|
||
| // Setup for other resource types to return empty | ||
| foreach (var type in new[] { "ValueSet", "CodeSystem", "StructureDefinition" }) | ||
| foreach (var type in new[] { "ValueSet", "CodeSystem", "StructureDefinition" }.Where(type => type != resourceType)) | ||
| { | ||
| if (type != resourceType) | ||
| { | ||
| _searchService.SearchAsync( | ||
| type, | ||
| Arg.Any<List<Tuple<string, string>>>(), | ||
| Arg.Any<CancellationToken>()) | ||
| .Returns(new SearchResult(new List<SearchResultEntry>(), null, null, new List<Tuple<string, string>>())); | ||
| } | ||
| _searchService.SearchAsync( | ||
| type, | ||
| Arg.Any<List<Tuple<string, string>>>(), | ||
| Arg.Any<CancellationToken>()) | ||
| .Returns(new SearchResult(new List<SearchResultEntry>(), null, null, new List<Tuple<string, string>>())); | ||
| } | ||
| } | ||
|
|
Description
Add tests to improve R4.Core tests coverage
Related issues
Addresses 174931
Testing
Describe how this change was tested.
FHIR Team Checklist
Semver Change (docs)
Patch|Skip|Feature|Breaking (reason)