Add project files.

This commit is contained in:
2025-08-18 17:11:43 +03:30
parent 807dc263be
commit e5eb10d604
3943 changed files with 223719 additions and 0 deletions
@@ -0,0 +1,7 @@
namespace Elsa.Workflows.IntegrationTests.Scenarios.ActivityNotificationsMiddleware;
public class Spy
{
public bool ActivityExecutingWasCalled { get; set; }
public bool ActivityExecutedWasCalled { get; set; }
}
@@ -0,0 +1,26 @@
using Elsa.Mediator.Contracts;
using Elsa.Workflows.Notifications;
namespace Elsa.Workflows.IntegrationTests.Scenarios.ActivityNotificationsMiddleware;
public class TestHandler : INotificationHandler<ActivityExecuting>, INotificationHandler<ActivityExecuted>
{
private readonly Spy _spy;
public TestHandler(Spy spy)
{
_spy = spy;
}
public Task HandleAsync(ActivityExecuting notification, CancellationToken cancellationToken)
{
_spy.ActivityExecutingWasCalled = true;
return Task.CompletedTask;
}
public Task HandleAsync(ActivityExecuted notification, CancellationToken cancellationToken)
{
_spy.ActivityExecutedWasCalled = true;
return Task.CompletedTask;
}
}
@@ -0,0 +1,38 @@
using Elsa.Testing.Shared;
using Elsa.Workflows.Notifications;
using Microsoft.Extensions.DependencyInjection;
using Xunit.Abstractions;
namespace Elsa.Workflows.IntegrationTests.Scenarios.ActivityNotificationsMiddleware;
public class Tests
{
private readonly IWorkflowRunner _workflowRunner;
private readonly CapturingTextWriter _capturingTextWriter = new();
private readonly Spy _spy;
public Tests(ITestOutputHelper testOutputHelper)
{
var services = new TestApplicationBuilder(testOutputHelper)
.WithCapturingTextWriter(_capturingTextWriter)
.ConfigureServices(s =>
{
s.AddSingleton<Spy>();
s.AddNotificationHandler<TestHandler, ActivityExecuting>();
s.AddNotificationHandler<TestHandler, ActivityExecuted>();
})
.Build();
_workflowRunner = services.GetRequiredService<IWorkflowRunner>();
_spy = services.GetRequiredService<Spy>();
}
[Fact(DisplayName = "Running workflow with activity notifications middleware results in notifications being published")]
public async Task Test1()
{
await _workflowRunner.RunAsync<HelloWorldWorkflow>();
Assert.True(_spy.ActivityExecutingWasCalled);
Assert.True(_spy.ActivityExecutedWasCalled);
}
}
@@ -0,0 +1,11 @@
using Elsa.Workflows.Activities;
namespace Elsa.Workflows.IntegrationTests.Scenarios.ActivityNotificationsMiddleware;
class HelloWorldWorkflow : WorkflowBase
{
protected override void Build(IWorkflowBuilder workflow)
{
workflow.Root = new WriteLine("Hello World!");
}
}