Add project files.
This commit is contained in:
+58
@@ -0,0 +1,58 @@
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Testing.Shared;
|
||||
using Elsa.Workflows.UIHints;
|
||||
using Elsa.Workflows.UIHints.Dropdown;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Elsa.Workflows.IntegrationTests.Serialization.UIHintSerializiation;
|
||||
|
||||
public class Tests
|
||||
{
|
||||
private readonly CapturingTextWriter _capturingTextWriter = new();
|
||||
private readonly IServiceProvider _services;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MigrationTests"/> class.
|
||||
/// </summary>
|
||||
public Tests(ITestOutputHelper testOutputHelper)
|
||||
{
|
||||
_services = new TestApplicationBuilder(testOutputHelper)
|
||||
.WithCapturingTextWriter(_capturingTextWriter)
|
||||
.ConfigureElsa(elsa =>
|
||||
{
|
||||
elsa.AddActivity<TestActivity>();
|
||||
})
|
||||
.Build();
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "Enum input types get a dropdown UIHint by default")]
|
||||
public async Task Test1()
|
||||
{
|
||||
var activityDescriber = _services.GetRequiredService<IActivityDescriber>();
|
||||
|
||||
var description = await activityDescriber.DescribeActivityAsync(typeof(TestActivity));
|
||||
|
||||
var inputDescription = description.Inputs.First();
|
||||
Assert.Equal(InputUIHints.DropDown, inputDescription.UIHint);
|
||||
}
|
||||
|
||||
[Fact(DisplayName = "Enum input types get a dropdown UIHint by default")]
|
||||
public async Task Test2()
|
||||
{
|
||||
var activityDescriber = _services.GetRequiredService<IActivityDescriber>();
|
||||
|
||||
var description = await activityDescriber.DescribeActivityAsync(typeof(TestActivity));
|
||||
|
||||
var inputDescription = description.Inputs.First();
|
||||
Assert.True(inputDescription.UISpecifications.ContainsKey(InputUIHints.DropDown));
|
||||
Assert.True(inputDescription.UISpecifications[InputUIHints.DropDown] is DropDownProps);
|
||||
var dropDownProperties = (DropDownProps) inputDescription.UISpecifications[InputUIHints.DropDown];
|
||||
|
||||
Assert.Collection(dropDownProperties.SelectList.Items,
|
||||
item => { Assert.Equal("OptionsAreNice", item.Text); Assert.Equal("OptionsAreNice", item.Value); },
|
||||
item => { Assert.Equal("ToHave", item.Text); Assert.Equal("ToHave", item.Value); },
|
||||
item => { Assert.Equal("IfYouCanChooseThem", item.Text); Assert.Equal("IfYouCanChooseThem", item.Value); });
|
||||
}
|
||||
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.Json.Serialization;
|
||||
using Elsa.Workflows.Attributes;
|
||||
using Elsa.Workflows.Models;
|
||||
|
||||
namespace Elsa.Workflows.IntegrationTests.Serialization.UIHintSerializiation;
|
||||
|
||||
/// <summary>
|
||||
/// Write a line of text to the console.
|
||||
/// </summary>
|
||||
[Activity("Elsa", "Test", "Used in Testing - not a real activity")]
|
||||
public class TestActivity : CodeActivity
|
||||
{
|
||||
/// <summary>
|
||||
/// The text to write.
|
||||
/// </summary>
|
||||
[Description("The text to write.")]
|
||||
public Input<TestEnumType> Option { get; set; } = null!;
|
||||
|
||||
[JsonConstructor]
|
||||
private TestActivity(string? source = null, int? line = null) : base(source, line)
|
||||
{
|
||||
}
|
||||
/// <inheritdoc />
|
||||
public TestActivity(Input<TestEnumType> option, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : this(source, line) => Option = option;
|
||||
|
||||
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
namespace Elsa.Workflows.IntegrationTests.Serialization.UIHintSerializiation;
|
||||
|
||||
public enum TestEnumType
|
||||
{
|
||||
OptionsAreNice,
|
||||
ToHave,
|
||||
IfYouCanChooseThem
|
||||
}
|
||||
Reference in New Issue
Block a user