/// <summary> /// Checks if a Document satisfies the list of conditions for this index /// </summary> public bool MatchesSearchConditions(Document doc, Type entityType) { return(GetPredicate(entityType)(doc)); }
public bool ExecuteFilter <T>(T obj) { return(GetPredicate <T>()(obj)); }
public async Task GivenNewOrchestrationWithWork_WhenReindexingInstances_ThenDivideAndReindexBatches() { const int batchSize = 5; _options.BatchSize = batchSize; _options.MaxParallelBatches = 3; IReadOnlyList <WatermarkRange> expectedBatches = CreateBatches(50); var expectedInput = new ReindexInput { QueryTagKeys = new List <int> { 1, 2, 3, 4, 5 } }; var expectedTags = new List <ExtendedQueryTagStoreEntry> { new ExtendedQueryTagStoreEntry(1, "01010101", "AS", null, QueryTagLevel.Instance, ExtendedQueryTagStatus.Adding, QueryStatus.Enabled, 0), new ExtendedQueryTagStoreEntry(2, "02020202", "IS", "foo", QueryTagLevel.Series, ExtendedQueryTagStatus.Adding, QueryStatus.Enabled, 0), new ExtendedQueryTagStoreEntry(4, "04040404", "SH", null, QueryTagLevel.Study, ExtendedQueryTagStatus.Adding, QueryStatus.Enabled, 0) }; // Arrange the input IDurableOrchestrationContext context = CreateContext(); context .GetInput <ReindexInput>() .Returns(expectedInput); context .CallActivityWithRetryAsync <IReadOnlyList <ExtendedQueryTagStoreEntry> >( nameof(ReindexDurableFunction.AssignReindexingOperationAsync), _options.ActivityRetryOptions, expectedInput.QueryTagKeys) .Returns(expectedTags); context .CallActivityWithRetryAsync <IReadOnlyList <WatermarkRange> >( nameof(ReindexDurableFunction.GetInstanceBatchesV2Async), _options.ActivityRetryOptions, Arg.Is(GetPredicate(null))) .Returns(expectedBatches); context .CallActivityWithRetryAsync( nameof(ReindexDurableFunction.ReindexBatchV2Async), _options.ActivityRetryOptions, Arg.Any <ReindexBatchArguments>()) .Returns(Task.CompletedTask); // Invoke the orchestration await _reindexDurableFunction.ReindexInstancesAsync(context, NullLogger.Instance); // Assert behavior context .Received(1) .GetInput <ReindexInput>(); await context .Received(1) .CallActivityWithRetryAsync <IReadOnlyList <ExtendedQueryTagStoreEntry> >( nameof(ReindexDurableFunction.AssignReindexingOperationAsync), _options.ActivityRetryOptions, expectedInput.QueryTagKeys); await context .DidNotReceive() .CallActivityWithRetryAsync <IReadOnlyList <ExtendedQueryTagStoreEntry> >( nameof(ReindexDurableFunction.GetQueryTagsAsync), _options.ActivityRetryOptions, Arg.Any <object>()); await context .Received(1) .CallActivityWithRetryAsync <IReadOnlyList <WatermarkRange> >( nameof(ReindexDurableFunction.GetInstanceBatchesV2Async), _options.ActivityRetryOptions, Arg.Is(GetPredicate(null))); foreach (WatermarkRange batch in expectedBatches) { await context .Received(1) .CallActivityWithRetryAsync( nameof(ReindexDurableFunction.ReindexBatchV2Async), _options.ActivityRetryOptions, Arg.Is(GetPredicate(expectedTags, batch))); } await context .DidNotReceive() .CallActivityWithRetryAsync <IReadOnlyList <int> >( nameof(ReindexDurableFunction.CompleteReindexingAsync), _options.ActivityRetryOptions, Arg.Any <object>()); context .Received(1) .ContinueAsNew( Arg.Is <ReindexInput>(x => GetPredicate(expectedTags, expectedBatches, 50)(x)), false); }