elsa-core/test/integration/Elsa.IntegrationTests/Activities/If/IfTests.cs
jdevillard 9175322774
Add a more generic UIHandler to customize how inputAttributes can be handle by UI (#4688)
* add a more generic UIHandler to customize how inputAttributes can be handle by the ui

* Add IPropertyUIHandlerResolver and update PropertyUIHandlerResolver

Introduced a new interface, IPropertyUIHandlerResolver, to resolve UI options for a property. Refactored PropertyUIHandlerResolver to implement this interface and removed the unnecessary partial class structure. Also, cleaned up some unnecessary usings in various files for better code organization.

* Refactor variable name and description in InputDescriptor

The 'uISpecifications' variable in the InputDescriptor model is renamed to 'uiSpecifications' for better readability. Additionally, the associated comment was revised to explain that the dictionary is used by the UI.

* "Refactor codebase for improved organization and cleaner architecture"

The codebase has been significantly refactored, moving several classes to more appropriate namespaces for improved organization and cleaner architecture. This includes shifting UI hint handlers, activities, and memory-related components, amongst others. The changes should improve code readability and maintainability, but as this is a broad refactoring effort, thorough regression testing is advised.

* Add CheckList UIHint with associated handler and provider

This update introduces a new UIHint called CheckList to the Elsa.Workflows.Core. This includes the necessary handler and provider classes. The handler is registered in the WorkflowsFeature.cs, and the CheckList UIHint key has been added to the InputUIHints.cs. Various associated files have been created in both the Elsa.Api.Client and Elsa.Workflows.Core project to support this new UIHint.

---------

Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com>
Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2023-12-26 18:56:29 +01:00

45 lines
1.7 KiB
C#

using System;
using System.Linq;
using System.Threading.Tasks;
using Elsa.Testing.Shared;
using Elsa.Workflows.Contracts;
using Microsoft.Extensions.DependencyInjection;
using Xunit;
using Xunit.Abstractions;
namespace Elsa.IntegrationTests.Activities;
public class IfTests
{
private readonly IWorkflowRunner _workflowRunner;
private readonly CapturingTextWriter _capturingTextWriter = new();
private readonly IServiceProvider _services;
public IfTests(ITestOutputHelper testOutputHelper)
{
_services = new TestApplicationBuilder(testOutputHelper).WithCapturingTextWriter(_capturingTextWriter).Build();
_workflowRunner = _services.GetRequiredService<IWorkflowRunner>();
}
[Theory(DisplayName = "The correct branch executes when condition is true")]
[InlineData(true, "True!")]
[InlineData(false, "False!")]
public async Task Test1(bool conditionResult, string expectedLine)
{
await _services.PopulateRegistriesAsync();
await _workflowRunner.RunAsync(new IfThenWorkflow(() => conditionResult));
var lines = _capturingTextWriter.Lines.ToList();
Assert.Equal(new[] { expectedLine }, lines);
}
[Theory(DisplayName = "The If activity completes only after either one of its branches completed")]
[InlineData(true, new[] { "Start", "Executing", "True!", "End" })]
[InlineData(false, new[] { "Start", "Executing", "False!", "End" })]
public async Task Test2(bool conditionResult, string[] expectedLines)
{
await _services.PopulateRegistriesAsync();
await _workflowRunner.RunAsync(new ComplexIfWorkflow(() => conditionResult));
var lines = _capturingTextWriter.Lines.ToList();
Assert.Equal(expectedLines, lines);
}
}