public void GivenOrchestrationStatus_WhenGettingOperationRuntimeStatus_ThenConvertStatus(
     OrchestrationRuntimeStatus actual, OperationRuntimeStatus expected)
 {
     Assert.Equal(expected, new DurableOrchestrationStatus {
         RuntimeStatus = actual
     }.GetOperationRuntimeStatus());
 }
        /// <inheritdoc/>
        public async Task <OperationStatus> GetStatusAsync(Guid operationId, CancellationToken cancellationToken = default)
        {
            cancellationToken.ThrowIfCancellationRequested();

            // TODO: Pass token when supported
            DurableOrchestrationStatus status = await _durableClient.GetStatusAsync(OperationId.ToString(operationId), showInput : true);

            if (status == null)
            {
                return(null);
            }

            _logger.LogInformation(
                "Successfully found the status of orchestration instance '{InstanceId}' with name '{Name}'.",
                status.InstanceId,
                status.Name);

            OperationType type = status.GetOperationType();

            if (type == OperationType.Unknown)
            {
                _logger.LogWarning("Orchestration instance with '{Name}' did not resolve to a public operation type.", status.Name);
                return(null);
            }

            OperationRuntimeStatus runtimeStatus = status.GetOperationRuntimeStatus();
            OperationProgress      progress      = GetOperationProgress(type, status);

            return(new OperationStatus
            {
                CreatedTime = status.CreatedTime,
                LastUpdatedTime = status.LastUpdatedTime,
                OperationId = operationId,
                PercentComplete = runtimeStatus == OperationRuntimeStatus.Completed ? 100 : progress.PercentComplete,
                Resources = await GetResourceUrlsAsync(type, progress.ResourceIds, cancellationToken),
                Status = runtimeStatus,
                Type = type,
            });
        }