From 4263934a4e2cca8f5dbb30856fefef1ee9758b75 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:52:27 +0000 Subject: [PATCH 1/6] Bump xunit.extensibility.core from 2.9.0 to 2.9.2 Bumps [xunit.extensibility.core](https://github.com/xunit/xunit) from 2.9.0 to 2.9.2. - [Commits](https://github.com/xunit/xunit/compare/v2-2.9.0...v2-2.9.2) --- updated-dependencies: - dependency-name: xunit.extensibility.core dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index f4e78d27e8..9df14e9828 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -117,7 +117,7 @@ - + From 3813af98f062918e76681e8d2186181a71fa7e1a Mon Sep 17 00:00:00 2001 From: Mikael Weaver Date: Tue, 18 Mar 2025 11:54:35 -0700 Subject: [PATCH 2/6] Update all xunit packages together --- Directory.Packages.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 9df14e9828..57af9ac714 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -119,8 +119,8 @@ - - + + From a6ea7b0827639d4569b4e5fbfc44c8ad2a8a08ba Mon Sep 17 00:00:00 2001 From: Mikael Weaver Date: Tue, 18 Mar 2025 11:55:21 -0700 Subject: [PATCH 3/6] Update xunit package versions to 2.9.3 --- Directory.Packages.props | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 57af9ac714..8eea783d38 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -117,10 +117,10 @@ - + - - + + From 4ea8a4c938d9fe413a9a3cd5c0d5418b132bf845 Mon Sep 17 00:00:00 2001 From: Mikael Weaver Date: Tue, 18 Mar 2025 12:40:12 -0700 Subject: [PATCH 4/6] update tests for new xunit version --- .../Create/CreateResourceValidatorTests.cs | 6 ++--- .../MemberMatchResourceValidatorTests.cs | 6 ++--- .../SearchParameterDefinitionManagerTests.cs | 2 +- .../Rest/ValidateTests.cs | 6 ++--- ...erFhirResourceChangeCaptureEnabledTests.cs | 12 ++++----- .../Persistence/SqlServerCreateStatsTests.cs | 25 ++++++++----------- 6 files changed, 26 insertions(+), 31 deletions(-) diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/Create/CreateResourceValidatorTests.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/Create/CreateResourceValidatorTests.cs index 2c61f5f638..52b19562ab 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/Create/CreateResourceValidatorTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/Create/CreateResourceValidatorTests.cs @@ -67,9 +67,9 @@ public void GivenAResourceWithInvalidId_WhenValidatingUpsert_ThenInvalidShouldBe var result = validator.Validate(createResourceRequest); Assert.False(result.IsValid); Assert.True(result.Errors.Count >= 3); - Assert.NotEmpty(result.Errors.Where(e => e.ErrorMessage.Contains("minimum cardinality 1 cannot be null"))); - Assert.NotEmpty(result.Errors.Where(e => e.ErrorMessage.Contains("XHTML content should be contained within a single
element"))); - Assert.NotEmpty(result.Errors.Where(e => e.ErrorMessage.Contains("Id must be any combination of upper or lower case ASCII letters"))); + Assert.Contains(result.Errors, e => e.ErrorMessage.Contains("minimum cardinality 1 cannot be null")); + Assert.Contains(result.Errors, e => e.ErrorMessage.Contains("XHTML content should be contained within a single
element")); + Assert.Contains(result.Errors, e => e.ErrorMessage.Contains("Id must be any combination of upper or lower case ASCII letters")); } [InlineData(true, null, true)] diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/MemberMatch/MemberMatchResourceValidatorTests.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/MemberMatch/MemberMatchResourceValidatorTests.cs index 10e552c9ae..332e60470e 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/MemberMatch/MemberMatchResourceValidatorTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Resources/MemberMatch/MemberMatchResourceValidatorTests.cs @@ -55,7 +55,7 @@ public void GivenAnInvalidResource_WhenValidatingMemberMatch_ThenInvalidShouldBe var result = validator.Validate(createMemberMatchRequest); Assert.False(result.IsValid); Assert.True(result.Errors.Count >= 1); - Assert.NotEmpty(result.Errors.Where(e => e.ErrorMessage.Contains("minimum cardinality 1 cannot be null"))); + Assert.Contains(result.Errors, e => e.ErrorMessage.Contains("minimum cardinality 1 cannot be null")); } #endif @@ -94,8 +94,8 @@ public void GivenAResourceWithInvalidId_WhenValidatingMemberMatch_ThenInvalidSho var result = validator.Validate(createResourceRequest); Assert.False(result.IsValid); Assert.True(result.Errors.Count >= 2); - Assert.NotEmpty(result.Errors.Where(e => e.ErrorMessage.Contains("XHTML content should be contained within a single
element"))); - Assert.NotEmpty(result.Errors.Where(e => e.ErrorMessage.Contains("Id must be any combination of upper or lower case ASCII letters"))); + Assert.Contains(result.Errors, e => e.ErrorMessage.Contains("XHTML content should be contained within a single
element")); + Assert.Contains(result.Errors, e => e.ErrorMessage.Contains("Id must be any combination of upper or lower case ASCII letters")); } [InlineData(true, null, true)] diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/SearchParameters/SearchParameterDefinitionManagerTests.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/SearchParameters/SearchParameterDefinitionManagerTests.cs index 5c8ffa985b..57c3598fc4 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/SearchParameters/SearchParameterDefinitionManagerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Search/SearchParameters/SearchParameterDefinitionManagerTests.cs @@ -517,7 +517,7 @@ public async Task GivenExistingSearchParameters_WhenStartingSearchParameterDefin Assert.True(patientParams.Where(p => p.Name == "preexisting2").First().IsSearchable); var questionnaireParams = searchParameterDefinitionManager.GetSearchParameters("QuestionnaireResponse"); - Assert.Single(questionnaireParams.Where(p => p.Name == "questionnaire2")); + Assert.Single(questionnaireParams, p => p.Name == "questionnaire2"); } private static void ValidateSearchParam(SearchParameterInfo expectedSearchParam, SearchParameterInfo actualSearchParam) diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/ValidateTests.cs b/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/ValidateTests.cs index 18a45df3a8..aba592057f 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/ValidateTests.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/ValidateTests.cs @@ -69,7 +69,7 @@ public async Task GivenAValidateRequest_WhenTheResourceIsNonConformToProfile_The { OperationOutcome outcome = await _client.ValidateAsync(path, Samples.GetJson(filename), profile); - Assert.NotEmpty(outcome.Issue.Where(x => x.Severity == OperationOutcome.IssueSeverity.Error)); + Assert.Contains(outcome.Issue, x => x.Severity == OperationOutcome.IssueSeverity.Error); Parameters parameters = new Parameters(); if (!string.IsNullOrEmpty(profile)) @@ -82,7 +82,7 @@ public async Task GivenAValidateRequest_WhenTheResourceIsNonConformToProfile_The outcome = await _client.ValidateAsync(path, parameters.ToJson()); - Assert.NotEmpty(outcome.Issue.Where(x => x.Severity == OperationOutcome.IssueSeverity.Error)); + Assert.Contains(outcome.Issue, x => x.Severity == OperationOutcome.IssueSeverity.Error); } [Theory] @@ -162,7 +162,7 @@ public async Task GivenAValidateByIdRequestWithStricterProfile_WhenRunningValida Patient createdResource = await _client.CreateAsync(Samples.GetDefaultPatient().ToPoco()); OperationOutcome outcome = await _client.ValidateByIdAsync(ResourceType.Patient, createdResource.Id, "http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient"); - Assert.NotEmpty(outcome.Issue.Where(x => x.Severity == OperationOutcome.IssueSeverity.Error)); + Assert.Contains(outcome.Issue, x => x.Severity == OperationOutcome.IssueSeverity.Error); } [Fact] diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/ChangeFeed/SqlServerFhirResourceChangeCaptureEnabledTests.cs b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/ChangeFeed/SqlServerFhirResourceChangeCaptureEnabledTests.cs index f6834853e3..108c6b2659 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/ChangeFeed/SqlServerFhirResourceChangeCaptureEnabledTests.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/ChangeFeed/SqlServerFhirResourceChangeCaptureEnabledTests.cs @@ -64,7 +64,7 @@ public async Task GivenADatabaseSupportsResourceChangeCapture_WhenInsertingAReso var resourceChanges = await resourceChangeDataStore.GetRecordsAsync(1, 200, CancellationToken.None); Assert.NotNull(resourceChanges); - Assert.Single(resourceChanges.Where(x => x.ResourceId == deserialized.Id)); + Assert.Single(resourceChanges, x => x.ResourceId == deserialized.Id); Assert.Equal(ResourceChangeTypeCreated, resourceChanges.First(x => x.ResourceId == deserialized.Id).ResourceChangeTypeId); } @@ -91,7 +91,7 @@ public async Task GivenADatabaseSupportsResourceChangeCapture_WhenUpdatingAResou var resourceChanges = await resourceChangeDataStore.GetRecordsAsync(1, 200, CancellationToken.None); Assert.NotNull(resourceChanges); - Assert.Single(resourceChanges.Where(x => x.ResourceVersion.ToString() == deserialized.VersionId && x.ResourceId == deserialized.Id)); + Assert.Single(resourceChanges, x => x.ResourceVersion.ToString() == deserialized.VersionId && x.ResourceId == deserialized.Id); var resourceChangeData = resourceChanges.FirstOrDefault(x => x.ResourceVersion.ToString() == deserialized.VersionId && x.ResourceId == deserialized.Id); @@ -121,8 +121,8 @@ public async Task GivenADatabaseSupportsResourceChangeCapture_WhenImportingNegat var resourceChanges = await resourceChangeDataStore.GetRecordsAsync(1, 200, CancellationToken.None); Assert.NotNull(resourceChanges); - Assert.Single(resourceChanges.Where(x => x.ResourceVersion.ToString() == "1" && x.ResourceId == id)); - Assert.Single(resourceChanges.Where(x => x.ResourceVersion.ToString() == "2" && x.ResourceId == id)); + Assert.Single(resourceChanges, x => x.ResourceVersion.ToString() == "1" && x.ResourceId == id); + Assert.Single(resourceChanges, x => x.ResourceVersion.ToString() == "2" && x.ResourceId == id); // negative versions are filtered out according to the existing logic because they are historical Assert.DoesNotContain(resourceChanges, x => x.ResourceVersion.ToString() == "-1" && x.ResourceId == id); @@ -378,7 +378,7 @@ public async Task GivenADatabaseSupportsResourceChangeCapture_WhenDeletingAResou var resourceChanges = await resourceChangeDataStore.GetRecordsAsync(1, 200, CancellationToken.None); Assert.NotNull(resourceChanges); - Assert.Single(resourceChanges.Where(x => x.ResourceVersion.ToString() == deletedResourceKey.ResourceKey.VersionId && x.ResourceId == deletedResourceKey.ResourceKey.Id)); + Assert.Single(resourceChanges, x => x.ResourceVersion.ToString() == deletedResourceKey.ResourceKey.VersionId && x.ResourceId == deletedResourceKey.ResourceKey.Id); var resourceChangeData = resourceChanges.FirstOrDefault(x => x.ResourceVersion.ToString() == deletedResourceKey.ResourceKey.VersionId && x.ResourceId == deletedResourceKey.ResourceKey.Id); @@ -402,7 +402,7 @@ public async Task GivenADatabase_WhenGettingResourceTypes_WhenInsertingAResource var resourceChanges = await resourceChangeDataStore.GetRecordsAsync(1, 200, CancellationToken.None); Assert.NotNull(resourceChanges); - Assert.Single(resourceChanges.Where(x => x.ResourceId == deserialized.Id)); + Assert.Single(resourceChanges, x => x.ResourceId == deserialized.Id); var resourceChangeData = resourceChanges.Where(x => x.ResourceId == deserialized.Id).FirstOrDefault(); diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerCreateStatsTests.cs b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerCreateStatsTests.cs index 1ac08cc677..f2a39218d4 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerCreateStatsTests.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerCreateStatsTests.cs @@ -60,11 +60,10 @@ public async Task GivenSearchForImagingStudyByIdentifier_StatsAreCreated() _output.WriteLine($"database {stat}"); } - Assert.Single(statsFromCache.Where( - _ => _.TableName == VLatest.TokenSearchParam.TableName + Assert.Single(statsFromCache, _ => _.TableName == VLatest.TokenSearchParam.TableName && _.ColumnName == "Code" && _.ResourceTypeId == sqlSearchService.Model.GetResourceTypeId(resourceType) - && _.SearchParamId == sqlSearchService.Model.GetSearchParamId(new Uri("http://hl7.org/fhir/SearchParameter/clinical-identifier")))); + && _.SearchParamId == sqlSearchService.Model.GetSearchParamId(new Uri("http://hl7.org/fhir/SearchParameter/clinical-identifier"))); } [Fact] @@ -75,28 +74,24 @@ public async Task GivenSearchForResearchStudyByFocusAndDateWithResearchSubject_S await _fixture.SearchService.SearchAsync(resourceType, query, CancellationToken.None); var statsFromCache = SqlServerSearchService.GetStatsFromCache(); var model = ((SqlServerSearchService)_fixture.SearchService).Model; - Assert.Single(statsFromCache.Where( - _ => _.TableName == VLatest.TokenSearchParam.TableName + Assert.Single(statsFromCache, _ => _.TableName == VLatest.TokenSearchParam.TableName && _.ColumnName == "Code" && _.ResourceTypeId == model.GetResourceTypeId(resourceType) - && _.SearchParamId == model.GetSearchParamId(new Uri("http://hl7.org/fhir/SearchParameter/ResearchStudy-focus")))); - Assert.Single(statsFromCache.Where( - _ => _.TableName == VLatest.DateTimeSearchParam.TableName + && _.SearchParamId == model.GetSearchParamId(new Uri("http://hl7.org/fhir/SearchParameter/ResearchStudy-focus"))); + Assert.Single(statsFromCache, _ => _.TableName == VLatest.DateTimeSearchParam.TableName && _.ColumnName == "StartDateTime" && _.ResourceTypeId == model.GetResourceTypeId(resourceType) - && _.SearchParamId == model.GetSearchParamId(new Uri("http://hl7.org/fhir/SearchParameter/ResearchStudy-date")))); - Assert.Single(statsFromCache.Where( - _ => _.TableName == VLatest.DateTimeSearchParam.TableName + && _.SearchParamId == model.GetSearchParamId(new Uri("http://hl7.org/fhir/SearchParameter/ResearchStudy-date"))); + Assert.Single(statsFromCache, _ => _.TableName == VLatest.DateTimeSearchParam.TableName && _.ColumnName == "EndDateTime" && _.ResourceTypeId == model.GetResourceTypeId(resourceType) - && _.SearchParamId == model.GetSearchParamId(new Uri("http://hl7.org/fhir/SearchParameter/ResearchStudy-date")))); + && _.SearchParamId == model.GetSearchParamId(new Uri("http://hl7.org/fhir/SearchParameter/ResearchStudy-date"))); if (ModelInfoProvider.Instance.Version == FhirSpecification.R4) { - Assert.Single(statsFromCache.Where( - _ => _.TableName == VLatest.TokenSearchParam.TableName + Assert.Single(statsFromCache, _ => _.TableName == VLatest.TokenSearchParam.TableName && _.ColumnName == "Code" && _.ResourceTypeId == model.GetResourceTypeId("ResearchSubject") - && _.SearchParamId == model.GetSearchParamId(new Uri("http://hl7.org/fhir/SearchParameter/ResearchSubject-status")))); + && _.SearchParamId == model.GetSearchParamId(new Uri("http://hl7.org/fhir/SearchParameter/ResearchSubject-status"))); } } } From b6203ad1a1b958a00a417169e4dc081517ee9fa9 Mon Sep 17 00:00:00 2001 From: Mikael Weaver Date: Tue, 18 Mar 2025 14:34:22 -0700 Subject: [PATCH 5/6] fix tests --- .../Persistence/SqlServerCreateStatsTests.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerCreateStatsTests.cs b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerCreateStatsTests.cs index 253ff0edc0..56e0b26f7e 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerCreateStatsTests.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerCreateStatsTests.cs @@ -83,9 +83,8 @@ public async Task GivenSearchForResearchStudyByFocusAndDateWithResearchSubject_S Assert.Single(statsFromCache, _ => _.TableName == VLatest.TokenSearchParam.TableName && _.ColumnName == "Code" && _.ResourceTypeId == model.GetResourceTypeId(resourceType) - && _.SearchParamId == model.GetSearchParamId(new Uri(researchStudyFocusUri)))); - Assert.Single(statsFromCache.Where( - _ => _.TableName == VLatest.DateTimeSearchParam.TableName + && _.SearchParamId == model.GetSearchParamId(new Uri(researchStudyFocusUri))); + Assert.Single(statsFromCache, _ => _.TableName == VLatest.DateTimeSearchParam.TableName && _.ColumnName == "StartDateTime" && _.ResourceTypeId == model.GetResourceTypeId(resourceType) && _.SearchParamId == model.GetSearchParamId(new Uri("http://hl7.org/fhir/SearchParameter/ResearchStudy-date"))); From f52eeda36a653cf0a4b5a4a8349bcf17c8fac278 Mon Sep 17 00:00:00 2001 From: Mikael Weaver Date: Tue, 18 Mar 2025 15:56:13 -0700 Subject: [PATCH 6/6] fix xunit test issues --- .../StartupTests.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.Health.Fhir.Shared.Web.UnitTests/StartupTests.cs b/src/Microsoft.Health.Fhir.Shared.Web.UnitTests/StartupTests.cs index acd0204b7c..3b67c0471f 100644 --- a/src/Microsoft.Health.Fhir.Shared.Web.UnitTests/StartupTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Web.UnitTests/StartupTests.cs @@ -104,8 +104,7 @@ public void GivenAppSettings_WhenTelemetryProviderIsApplicationInsignts_ThenAppl using var provider = services.BuildServiceProvider(); if (!string.IsNullOrWhiteSpace(instrumentationKey) || !string.IsNullOrWhiteSpace(connectionString)) { - Assert.NotEmpty(services.Where(descriptor => - descriptor.ImplementationType != null && descriptor.ImplementationType.FullName.Contains("ApplicationInsights", StringComparison.OrdinalIgnoreCase))); + Assert.Contains(services, descriptor => descriptor.ImplementationType != null && descriptor.ImplementationType.FullName.Contains("ApplicationInsights", StringComparison.OrdinalIgnoreCase)); Assert.DoesNotContain(services, descriptor => descriptor.ImplementationType != null && descriptor.ImplementationType.FullName.Contains("OpenTelemetry", StringComparison.OrdinalIgnoreCase)); @@ -153,8 +152,7 @@ public void GivenAppSettings_WhenTelemetryProviderIsOpenTelemetry_ThenOpenTeleme using var provider = services.BuildServiceProvider(); if (!string.IsNullOrWhiteSpace(connectionString)) { - Assert.NotEmpty(services.Where(descriptor => - descriptor.ImplementationType != null && descriptor.ImplementationType.FullName.Contains("OpenTelemetry", StringComparison.OrdinalIgnoreCase))); + Assert.Contains(services, descriptor => descriptor.ImplementationType != null && descriptor.ImplementationType.FullName.Contains("OpenTelemetry", StringComparison.OrdinalIgnoreCase)); } else {