public void GivenInstanceId_WhenFetchingAsGuid_ThenReturnParsedValue()
        {
            Guid expected = Guid.NewGuid();
            IDurableActivityContext context = Substitute.For <IDurableActivityContext>();

            context.InstanceId.Returns(OperationId.ToString(expected));

            Assert.Equal(expected, context.GetInstanceGuid());
        }
        public Task <IReadOnlyList <ExtendedQueryTagStoreEntry> > GetQueryTagsAsync(
            [ActivityTrigger] IDurableActivityContext context,
            ILogger logger)
        {
            EnsureArg.IsNotNull(context, nameof(context));
            EnsureArg.IsNotNull(logger, nameof(logger));

            logger.LogInformation(
                "Fetching the extended query tags for operation ID '{OperationId}'.",
                context.InstanceId);

            return(_extendedQueryTagStore.GetExtendedQueryTagsAsync(
                       context.GetInstanceGuid(),
                       cancellationToken: CancellationToken.None));
        }
        public Task <IReadOnlyList <ExtendedQueryTagStoreEntry> > AssignReindexingOperationAsync(
            [ActivityTrigger] IDurableActivityContext context,
            ILogger logger)
        {
            EnsureArg.IsNotNull(context, nameof(context));
            EnsureArg.IsNotNull(logger, nameof(logger));

            IReadOnlyList <int> tagKeys = context.GetInput <IReadOnlyList <int> >();

            logger.LogInformation("Assigning {Count} query tags to operation ID '{OperationId}': {{{TagKeys}}}",
                                  tagKeys.Count,
                                  context.InstanceId,
                                  string.Join(", ", tagKeys));

            return(_extendedQueryTagStore.AssignReindexingOperationAsync(
                       tagKeys,
                       context.GetInstanceGuid(),
                       returnIfCompleted: false,
                       cancellationToken: CancellationToken.None));
        }