From b32c3b45bb76063dfa678a39f04cee5c3da4d9fa Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Fri, 16 Dec 2022 22:07:24 +0100 Subject: [PATCH] Remove outdated tests --- .../Elsa.IntegrationTests.csproj | 10 +-- .../Scenarios/PersistentVariables/Tests.cs | 86 ------------------- .../PersistentVariables/Workflows.cs | 49 ----------- 3 files changed, 5 insertions(+), 140 deletions(-) delete mode 100644 test/Elsa.IntegrationTests/Scenarios/PersistentVariables/Tests.cs delete mode 100644 test/Elsa.IntegrationTests/Scenarios/PersistentVariables/Workflows.cs diff --git a/test/Elsa.IntegrationTests/Elsa.IntegrationTests.csproj b/test/Elsa.IntegrationTests/Elsa.IntegrationTests.csproj index 6087c089c..d27083351 100644 --- a/test/Elsa.IntegrationTests/Elsa.IntegrationTests.csproj +++ b/test/Elsa.IntegrationTests/Elsa.IntegrationTests.csproj @@ -7,9 +7,9 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -21,8 +21,8 @@ - - + + diff --git a/test/Elsa.IntegrationTests/Scenarios/PersistentVariables/Tests.cs b/test/Elsa.IntegrationTests/Scenarios/PersistentVariables/Tests.cs deleted file mode 100644 index 3974b213f..000000000 --- a/test/Elsa.IntegrationTests/Scenarios/PersistentVariables/Tests.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Elsa.Extensions; -using Elsa.Testing.Shared; -using Elsa.Workflows.Core.Implementations; -using Elsa.Workflows.Core.Middleware.Workflows; -using Elsa.Workflows.Core.Models; -using Elsa.Workflows.Core.Services; -using Elsa.Workflows.Core.State; -using Elsa.Workflows.Runtime.Extensions; -using Microsoft.Extensions.DependencyInjection; -using Xunit; -using Xunit.Abstractions; - -namespace Elsa.IntegrationTests.Scenarios.PersistentVariables; - -public class WorkflowInstancePersistenceTests -{ - private readonly IWorkflowRunner _workflowRunner; - private readonly CapturingTextWriter _capturingTextWriter = new(); - private readonly IWorkflowBuilderFactory _workflowBuilderFactory; - - public WorkflowInstancePersistenceTests(ITestOutputHelper testOutputHelper) - { - var services = new TestApplicationBuilder(testOutputHelper).WithCapturingTextWriter(_capturingTextWriter).Build(); - _workflowBuilderFactory = services.GetRequiredService(); - _workflowRunner = services.GetRequiredService(); - - services.ConfigureDefaultWorkflowExecutionPipeline(pipeline => pipeline - .UsePersistentVariables() - .UseDefaultActivityScheduler()); - } - - [Fact(DisplayName = "Persistent variables are persisted after workflow gets blocked")] - public async Task Test1() - { - // Run the workflow. - var result = await _workflowRunner.RunAsync(); - - // Assert the variable was persisted. - var persistentVariables = result.WorkflowState.PersistentVariables; - var currentLanguageVariable = persistentVariables.FirstOrDefault(); - - Assert.NotNull(currentLanguageVariable); - } - - [Fact(DisplayName = "Persistent variables are applied before workflow gets resumed")] - public async Task Test2() - { - // Build the workflow. - var languages = new[] { "C#", "JavaScript", "Haskell" }; - var workflow = await _workflowBuilderFactory.CreateBuilder().BuildWorkflowAsync(new BlockingWorkflow(languages)); - var currentIndex = 0; - - var bookmark = default(Bookmark?); - var workflowState = default(WorkflowState?); - var variable = workflow.Variables.First(); - - // Continuously resume the workflow until no more bookmarks are returned. - while (true) - { - // Run/resume the workflow. - var result = workflowState == null - ? await _workflowRunner.RunAsync(workflow) - : await _workflowRunner.RunAsync(workflow, workflowState, new RunWorkflowOptions(BookmarkId: bookmark!.Id)); - - bookmark = result.WorkflowState.Bookmarks.FirstOrDefault(); - - if (bookmark == null) - break; - - workflowState = result.WorkflowState; - - // Assert that the expected variable is persisted. - var persistentVariablesDictionary = (IDictionary)workflowState.Properties[WorkflowStateStorageDriver.VariablesDictionaryStateKey]; - var stateId = $"{workflowState.Id}:{variable.Name}"; - var persistedValue = persistentVariablesDictionary[stateId]; - var expectedValue = languages[currentIndex]; - - Assert.Equal(expectedValue, persistedValue); - - currentIndex ++; - } - } -} \ No newline at end of file diff --git a/test/Elsa.IntegrationTests/Scenarios/PersistentVariables/Workflows.cs b/test/Elsa.IntegrationTests/Scenarios/PersistentVariables/Workflows.cs deleted file mode 100644 index 763d736b2..000000000 --- a/test/Elsa.IntegrationTests/Scenarios/PersistentVariables/Workflows.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Elsa.Workflows.Core; -using Elsa.Workflows.Core.Activities; -using Elsa.Workflows.Core.Models; -using Elsa.Workflows.Core.Services; - -namespace Elsa.IntegrationTests.Scenarios.PersistentVariables; - -public class BlockingWorkflow : WorkflowBase -{ - // ReSharper disable once UnusedMember.Global - public BlockingWorkflow() : this(new[] { "C#", "JavaScript", "Haskell" }) - { - } - - public BlockingWorkflow(string[] languages) - { - Languages = languages; - } - - public string[] Languages { get; } - - protected override void Build(IWorkflowBuilder workflow) - { - var currentLanguage = workflow.WithVariable().WithWorkflowDrive(); - - workflow.WithRoot(new Sequence - { - Activities = - { - new WriteLine("Start"), - new ForEach(Languages) - { - CurrentValue = new Output(currentLanguage), - Body = new Sequence - { - Activities = - { - new WriteLine("Waiting for event..."), - new Event("Resume") { Id = "Resume" }, - new WriteLine(context => currentLanguage.Get(context)) - } - } - }, - - new WriteLine("Done") - } - }); - } -} \ No newline at end of file