using Elsa.Workflows;
using Elsa.Workflows.Models;
using Elsa.Workflows.Options;
using JetBrains.Annotations;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.Testing.Shared;
///
/// Provides extension methods for .
///
[PublicAPI]
[Obsolete("Use WorkflowTestFixture instead.")]
public static class RunActivityExtensions
{
/// The service provider.
extension(IServiceProvider services)
{
///
/// Runs the specified activity.
///
/// The activity to run.
/// An optional cancellation token.
/// The result of running the activity.
[Obsolete("Use WorkflowTestFixture instead.")]
public async Task RunActivityAsync(IActivity activity, CancellationToken cancellationToken = default)
{
await services.PopulateRegistriesAsync();
var workflowRunner = services.GetRequiredService();
var result = await workflowRunner.RunAsync(activity, cancellationToken: cancellationToken);
return result;
}
///
/// Runs the specified activity.
///
/// The activity to run.
/// A set of options.
/// An optional cancellation token.
/// The result of running the activity.
[Obsolete("Use WorkflowTestFixture instead.")]
public async Task RunActivityAsync(IActivity activity, RunWorkflowOptions options, CancellationToken cancellationToken = default)
{
await services.PopulateRegistriesAsync();
var workflowRunner = services.GetRequiredService();
var result = await workflowRunner.RunAsync(activity, options, cancellationToken);
return result;
}
}
}