Skip to content

Commit

Permalink
Fx tests for Update
Browse files Browse the repository at this point in the history
  • Loading branch information
abiisnn committed Oct 20, 2023
1 parent a99166b commit c08d021
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"resourceType": "SearchParameter",
"version": "4.0.1",
"name": "description",
"name": "reason",
"status": "draft",
"description": "The description of the research definition",
"code": "description",
"description": "The reason for the study",
"code": "reason",
"base": [
"ResearchDefinition"
"ImagingStudy"
],
"type": "string",
"expression": "ResearchDefinition.description"
"expression": "ImagingStudy.reason"
}
16 changes: 8 additions & 8 deletions test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/UpdateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,12 @@ public async Task GivenTheResource_WhenUpdatingANewDuplicatedSearchParameterReso
{
/* When the server starts, search-parameters.json files are loaded and the default search parameters
* are created. The search parameter with the code 'description' and base 'ResearchDefinition' already exists with
* the url http://hl7.org/fhir/SearchParameter/ResearchDefinition-description */
* the url http://hl7.org/fhir/SearchParameter/ImagingStudy-reason */

var id = Guid.NewGuid();
var resourceToCreate = Samples.GetJsonSample<SearchParameter>("SearchParameterDuplicatedUpdate");
resourceToCreate.Id = id.ToString();
resourceToCreate.Url = "http://hl7.org/fhir/SearchParameter/ResearchDefinition-description";
resourceToCreate.Url = "http://hl7.org/fhir/SearchParameter/ImagingStudy-reason";

using FhirClientException ex = await Assert.ThrowsAsync<FhirClientException>(() => _client.UpdateAsync(
$"SearchParameter/{id}",
Expand All @@ -284,7 +284,7 @@ public async Task GivenTheResource_WhenUpdatingANewDuplicatedSearchParameterReso
Assert.NotEmpty(operationOutcome.Issue);
Assert.Single(operationOutcome.Issue);

var expectedError = "A search parameter with the same code value 'description' already exists for base type 'ResearchDefinition'.";
var expectedError = "A search parameter with the same code value 'reason' already exists for base type 'ImagingStudy'.";
Assert.Contains(expectedError, operationOutcome.Issue[0].Diagnostics);
}

Expand All @@ -294,12 +294,12 @@ public async Task GivenTheResource_WhenUpdatingANewDuplicatedSearchParameterReso
{
/* When the server starts, search-parameters.json files are loaded and the default search parameters
* are created. The search parameter with the code 'description' and base 'ResearchDefinition' already exists with
* the url http://hl7.org/fhir/SearchParameter/ResearchDefinition-description */
* the url http://hl7.org/fhir/SearchParameter/ImagingStudy-reason */

var id = Guid.NewGuid();
var resourceToCreate = Samples.GetJsonSample<SearchParameter>("SearchParameterDuplicatedUpdate");
resourceToCreate.Id = id.ToString();
resourceToCreate.Url = "http://hl7.org/fhir/SearchParameter/description-ResearchDefinition-test-update-url";
resourceToCreate.Url = "http://hl7.org/fhir/SearchParameter/reason-ImagingStudy-test-update-url";

using FhirClientException ex = await Assert.ThrowsAsync<FhirClientException>(() => _client.UpdateAsync(
$"SearchParameter/{id}",
Expand All @@ -311,13 +311,13 @@ public async Task GivenTheResource_WhenUpdatingANewDuplicatedSearchParameterReso
Assert.NotEmpty(operationOutcome.Issue);
Assert.Equal(2, operationOutcome.Issue.Count);

var firstIssue = "A search parameter with Uri 'http://hl7.org/fhir/SearchParameter/description-ResearchDefinition-test-update-url' was not found.";
var secondIssue = "A search parameter with the same code value 'description' already exists for base type 'ResearchDefinition'.";
var firstIssue = "A search parameter with Uri 'http://hl7.org/fhir/SearchParameter/reason-ImagingStudy-test-update-url' was not found.";
var secondIssue = "A search parameter with the same code value 'reason' already exists for base type 'ImagingStudy'.";

Assert.Contains(firstIssue, operationOutcome.Issue[0].Diagnostics);
Assert.Contains(secondIssue, operationOutcome.Issue[1].Diagnostics);

/* If a search parameter with the url http://hl7.org/fhir/SearchParameter/description-ResearchDefinition-test-update-url already exists
/* If a search parameter with the url http://hl7.org/fhir/SearchParameter/reason-ImagingStudy-test-update-url already exists
* this test will fail because the first Issue will not be shown in the OperationOutcome.
*/
}
Expand Down

0 comments on commit c08d021

Please sign in to comment.