@@ -23,7 +23,7 @@ public sealed class IndexTests : ElasticRepositoryTestBase
2323{
2424 public IndexTests ( ITestOutputHelper output ) : base ( output )
2525 {
26- Log . SetLogLevel < EmployeeRepository > ( LogLevel . Warning ) ;
26+ Log . SetLogLevel < EmployeeRepository > ( LogLevel . Trace ) ;
2727 }
2828
2929 public override async Task InitializeAsync ( )
@@ -1370,4 +1370,46 @@ public async Task PatchAllAsync_WhenScriptPatchAndMonthlyIndexMissing_CreatesInd
13701370 var exists = await _client . Indices . ExistsAsync ( index . Name ) ;
13711371 Assert . False ( exists . Exists ) ;
13721372 }
1373+
1374+ [ Fact ]
1375+ public async Task PatchAllAsync_ByQuery_CreatesAllRelevantDailyIndices ( )
1376+ {
1377+ // Arrange
1378+ var index = new EmployeeIndex ( _configuration ) ;
1379+ await index . DeleteAsync ( ) ;
1380+ await using var _ = new AsyncDisposableAction ( ( ) => index . DeleteAsync ( ) ) ;
1381+ var repository = new EmployeeRepository ( index ) ;
1382+
1383+ string id1 = ObjectId . GenerateNewId ( ) . ToString ( ) ;
1384+ string id2 = ObjectId . GenerateNewId ( DateTime . UtcNow . SubtractDays ( 1 ) ) . ToString ( ) ;
1385+
1386+ // Act
1387+ await repository . PatchAllAsync ( q => q . Id ( id1 , id2 ) , new ActionPatch < Employee > ( e => e . Name = "Patched" ) ) ;
1388+
1389+ // Assert
1390+ var response = await _client . Indices . ExistsAsync ( index . GetIndex ( id1 ) ) ;
1391+ Assert . True ( response . Exists ) ;
1392+ }
1393+
1394+ [ Fact ]
1395+ public async Task PatchAllAsync_ByQueryAcrossMultipleDays_CreatesAllRelevantDailyIndices ( )
1396+ {
1397+ // Arrange
1398+ var index = new DailyEmployeeIndex ( _configuration , 1 ) ;
1399+ await index . DeleteAsync ( ) ;
1400+ await using var _ = new AsyncDisposableAction ( ( ) => index . DeleteAsync ( ) ) ;
1401+ var repository = new EmployeeRepository ( index ) ;
1402+
1403+ string id1 = ObjectId . GenerateNewId ( ) . ToString ( ) ;
1404+ string id2 = ObjectId . GenerateNewId ( DateTime . UtcNow . SubtractDays ( 1 ) ) . ToString ( ) ;
1405+
1406+ // Act
1407+ await repository . PatchAllAsync ( q => q . Id ( id1 , id2 ) , new ActionPatch < Employee > ( e => e . Name = "Patched" ) ) ;
1408+
1409+ // Assert
1410+ var existsDay1 = await _client . Indices . ExistsAsync ( index . GetIndex ( id1 ) ) ;
1411+ Assert . True ( existsDay1 . Exists ) ;
1412+ var existsDay2 = await _client . Indices . ExistsAsync ( index . GetIndex ( id2 ) ) ;
1413+ Assert . True ( existsDay2 . Exists ) ;
1414+ }
13731415}
0 commit comments