@@ -419,20 +419,33 @@ public async Task GivenIncrementalLoad_MultipleInputsWithImplicitVersionsExplici
419
419
Assert . Equal ( "1" , history . Resource . Entry [ 0 ] . Resource . VersionId ) ;
420
420
}
421
421
422
+ [ Fact ]
423
+ public async Task GivenIncrementalLoad_LastUpdatedOnResourceCannotBeInTheFuture ( )
424
+ {
425
+ var id = Guid . NewGuid ( ) . ToString ( "N" ) ;
426
+ var ndJson = CreateTestPatient ( id , DateTimeOffset . UtcNow . AddSeconds ( 20 ) ) ; // set value higher than 10 seconds tolerance
427
+ var location = ( await ImportTestHelper . UploadFileAsync ( ndJson , _fixture . StorageAccount ) ) . location ;
428
+ var request = CreateImportRequest ( location , ImportMode . IncrementalLoad , false , true ) ;
429
+ var result = await ImportCheckAsync ( request , null , 1 ) ;
430
+ var errorLocation = result . Error . ToArray ( ) [ 0 ] . Url ;
431
+ var errorContent = await ImportTestHelper . DownloadFileAsync ( errorLocation , _fixture . StorageAccount ) ;
432
+ Assert . Contains ( "LastUpdated in the resource cannot be in the future." , errorContent ) ;
433
+ }
434
+
422
435
[ Fact ]
423
436
public async Task GivenIncrementalLoad_MultipleInputsWithImplicitVersionsExplicitLastUpdatedAfterImplicit ( )
424
437
{
425
438
var id = Guid . NewGuid ( ) . ToString ( "N" ) ;
426
439
var ndJson1 = CreateTestPatient ( id ) ;
427
- var ndJson2 = CreateTestPatient ( id , DateTimeOffset . UtcNow . AddDays ( 1 ) ) ;
440
+ var ndJson2 = CreateTestPatient ( id , DateTimeOffset . UtcNow . AddSeconds ( 8 ) , birhDate : "1990" ) ; // last updated within 10 seconds tolerance, different content
428
441
var location = ( await ImportTestHelper . UploadFileAsync ( ndJson1 + ndJson2 , _fixture . StorageAccount ) ) . location ;
429
442
var request = CreateImportRequest ( location , ImportMode . IncrementalLoad , false , true ) ;
430
443
await ImportCheckAsync ( request , null , 0 ) ;
431
-
432
444
var history = await _client . SearchAsync ( $ "Patient/{ id } /_history") ;
433
445
Assert . Equal ( 2 , history . Resource . Entry . Count ) ;
434
- Assert . Equal ( "1" , history . Resource . Entry [ 0 ] . Resource . VersionId ) ;
435
- Assert . Equal ( "-1" , history . Resource . Entry [ 1 ] . Resource . VersionId ) ;
446
+ //// same order
447
+ Assert . True ( int . Parse ( history . Resource . Entry [ 0 ] . Resource . VersionId ) > int . Parse ( history . Resource . Entry [ 1 ] . Resource . VersionId ) ) ;
448
+ Assert . True ( history . Resource . Entry [ 0 ] . Resource . Meta . LastUpdated > history . Resource . Entry [ 1 ] . Resource . Meta . LastUpdated ) ;
436
449
}
437
450
438
451
[ Fact ]
@@ -1725,7 +1738,7 @@ public async Task GivenImportRequestWithMultipleSameFile_ThenBadRequestShouldBeR
1725
1738
Assert . Equal ( HttpStatusCode . BadRequest , fhirException . StatusCode ) ;
1726
1739
}
1727
1740
1728
- private async Task < Uri > ImportCheckAsync ( ImportRequest request , TestFhirClient client = null , int ? errorCount = null )
1741
+ private async Task < ImportJobResult > ImportCheckAsync ( ImportRequest request , TestFhirClient client = null , int ? errorCount = null )
1729
1742
{
1730
1743
client = client ?? _client ;
1731
1744
Uri checkLocation = await ImportTestHelper . CreateImportTaskAsync ( client , request ) ;
@@ -1746,7 +1759,7 @@ private async Task<Uri> ImportCheckAsync(ImportRequest request, TestFhirClient c
1746
1759
1747
1760
Assert . NotEmpty ( result . Request ) ;
1748
1761
1749
- return checkLocation ;
1762
+ return result ;
1750
1763
}
1751
1764
1752
1765
private async Task < HttpResponseMessage > ImportWaitAsync ( Uri checkLocation , bool checkSuccessStatus = true )
0 commit comments