diff --git a/test/WorkflowCore.IntegrationTests/Scenarios/StopScenario.cs b/test/WorkflowCore.IntegrationTests/Scenarios/StopScenario.cs index f58ddebea..e487a4053 100644 --- a/test/WorkflowCore.IntegrationTests/Scenarios/StopScenario.cs +++ b/test/WorkflowCore.IntegrationTests/Scenarios/StopScenario.cs @@ -1,12 +1,11 @@ -using WorkflowCore.Interface; -using WorkflowCore.Models; -using Xunit; +using System.Threading; +using System.Threading.Tasks; using FluentAssertions; -using WorkflowCore.Testing; +using WorkflowCore.Interface; +using WorkflowCore.Models; using WorkflowCore.Models.LifeCycleEvents; -using System.Threading.Tasks; -using System.Threading; -using Moq; +using WorkflowCore.Testing; +using Xunit; namespace WorkflowCore.IntegrationTests.Scenarios { @@ -18,33 +17,29 @@ public class StopWorkflow : IWorkflow public int Version => 1; public void Build(IWorkflowBuilder builder) { - builder.StartWith(context => ExecutionResult.Next()); + builder.StartWith(context => ExecutionResult.Next()); } } - public StopScenario() - { - Setup(); - } + public StopScenario() => Setup(); [Fact] public async Task Scenario() { var tcs = new TaskCompletionSource(); - Host.OnLifeCycleEvent += (evt) => OnLifeCycleEvent(evt, tcs); - var workflowId = StartWorkflow(null); + Host.OnLifeCycleEvent += async (evt) => + { + if (evt is WorkflowCompleted) + { + await Host.StopAsync(CancellationToken.None); + tcs.SetResult(default); + } + }; + var workflowId = StartWorkflow(default); await tcs.Task; - GetStatus(workflowId).Should().Be(WorkflowStatus.Complete); - } - private async void OnLifeCycleEvent(LifeCycleEvent evt, TaskCompletionSource tcs) - { - if (evt is WorkflowCompleted) - { - await Host.StopAsync(CancellationToken.None); - tcs.SetResult(new()); - } + GetStatus(workflowId).Should().Be(WorkflowStatus.Complete); } protected override void Dispose(bool disposing) { }