diff --git a/appveyor.yml b/appveyor.yml index ec72dc0db..cec1ae950 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -41,7 +41,8 @@ cd ..\..\..\..\ dotnet pack Elsa.sln --include-symbols /p:Version=$env:APPVEYOR_BUILD_VERSION - test: off + test_script: + - ps: dotnet test artifacts: - path: '**/*.nupkg' name: MyGet diff --git a/test/component/Elsa.ComponentTests/Clients/RestClient/WorkflowDefinitions/SaveTests.cs b/test/component/Elsa.ComponentTests/Clients/RestClient/WorkflowDefinitions/SaveTests.cs deleted file mode 100644 index 05ac3f6da..000000000 --- a/test/component/Elsa.ComponentTests/Clients/RestClient/WorkflowDefinitions/SaveTests.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using AutoFixture; -using Elsa.Activities.Console; -using Elsa.Client.Models; -using Elsa.ComponentTests.Helpers; -using Xunit; - -namespace Elsa.ComponentTests.Clients.RestClient.WorkflowDefinitions -{ - [Collection(ComponentTestsCollection.Name)] - public class SaveTests : ElsaClientTestBase - { - public SaveTests(ElsaHostApplicationFactory hostApplicationFactory) : base(hostApplicationFactory) - { - } - - [Fact(DisplayName = "Saving a new workflow definition returns HTTP 201.")] - public async Task Post01() - { - var request = CreateSaveWorkflowRequest(); - var workflowDefinition = await ElsaClient.WorkflowDefinitions.SaveAsync(request); - Assert.Equal(request.Name, workflowDefinition.Name); - } - - private SaveWorkflowDefinitionRequest CreateSaveWorkflowRequest() - { - var writeLine = new ActivityDefinition - { - ActivityId = Fixture.Create(), - Type = nameof(WriteLine), - Properties = new List() - { - ActivityDefinitionProperty.Literal(nameof(WriteLine.Text), "Hello World!") - } - }; - - var readLine = new ActivityDefinition {ActivityId = Fixture.Create(), Type = nameof(ReadLine)}; - var activities = new[] {writeLine, readLine}; - var connections = new[] {new ConnectionDefinition(writeLine.ActivityId, readLine.ActivityId, OutcomeNames.Done)}; - - return Fixture.Build() - .With(x => x.Activities, activities) - .With(x => x.Connections, connections) - .Create(); - } - } -} \ No newline at end of file diff --git a/test/integration/Elsa.Core.IntegrationTests/Elsa.Core.IntegrationTests.csproj b/test/integration/Elsa.Core.IntegrationTests/Elsa.Core.IntegrationTests.csproj index 0dc32fbde..c9a1d3c0a 100644 --- a/test/integration/Elsa.Core.IntegrationTests/Elsa.Core.IntegrationTests.csproj +++ b/test/integration/Elsa.Core.IntegrationTests/Elsa.Core.IntegrationTests.csproj @@ -7,9 +7,11 @@ - - + + + + diff --git a/test/integration/Elsa.Core.IntegrationTests/StorageProvider/StorageWorkflowProviderTests.cs b/test/integration/Elsa.Core.IntegrationTests/StorageProvider/StorageWorkflowProviderTests.cs deleted file mode 100644 index d2717f9d6..000000000 --- a/test/integration/Elsa.Core.IntegrationTests/StorageProvider/StorageWorkflowProviderTests.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Threading.Tasks; -using Elsa.Core.IntegrationTests.Helpers; -using Elsa.Models; -using Elsa.Testing.Shared.Unit; -using Microsoft.Extensions.DependencyInjection; -using Storage.Net.Blobs; -using Xunit; -using Xunit.Abstractions; - -namespace Elsa.Core.IntegrationTests.StorageProvider -{ - public class StorageWorkflowProviderTests : WorkflowsUnitTestBase - { - public StorageWorkflowProviderTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) - { - } - - [Fact(DisplayName = "Runs workflows provided by storage provider")] - public async Task Test01() - { - const string workflowFileName = "hello-world-workflow.json"; - const string workflowName = "SampleWorkflow"; - var json = await AssetHelper.ReadAssetAsync(workflowFileName); - var storage = ServiceProvider.GetRequiredService(); - await storage.WriteTextAsync(workflowFileName, json); - var workflowBlueprint = await WorkflowRegistry.GetWorkflowAsync(workflowName, VersionOptions.Published); - var workflowInstance = await WorkflowRunner.RunWorkflowAsync(workflowBlueprint!); - - Assert.Equal(WorkflowStatus.Finished, workflowInstance.WorkflowStatus); - } - } -} \ No newline at end of file diff --git a/test/integration/Elsa.Core.IntegrationTests/Workflows/FinishWorkflowTests.cs b/test/integration/Elsa.Core.IntegrationTests/Workflows/FinishWorkflowTests.cs index a13f981cd..e3c6e7245 100644 --- a/test/integration/Elsa.Core.IntegrationTests/Workflows/FinishWorkflowTests.cs +++ b/test/integration/Elsa.Core.IntegrationTests/Workflows/FinishWorkflowTests.cs @@ -1,5 +1,6 @@ using System.Threading.Tasks; using AutoFixture; +using AutoFixture.Xunit2; using Elsa.Models; using Elsa.Testing.Shared.Unit; using Xunit; @@ -9,22 +10,24 @@ namespace Elsa.Core.IntegrationTests.Workflows { public class FinishWorkflowTests : WorkflowsUnitTestBase { - private readonly Fixture _fixture; + public FinishWorkflowTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) {} - public FinishWorkflowTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) + [Theory(DisplayName = "Sets the workflow status of the workflow instance to WorkflowStatus.Finished after RunWorkflowAsync is used"), AutoMoqData] + public async Task RunWorkflowAsyncShouldSetWorkflowStatusToFinished(FinishWorkflow sut) { - _fixture = new Fixture(); - } - - [Fact(DisplayName = "Sets the workflow output to the specified value")] - public async Task Test01() - { - var output = _fixture.Create(); - var workflow = new FinishWorkflow(output); - var workflowInstance = await WorkflowRunner.RunWorkflowAsync(workflow); + var workflowInstance = await WorkflowRunner.RunWorkflowAsync(sut); Assert.Equal(WorkflowStatus.Finished, workflowInstance.WorkflowStatus); - Assert.Equal(output, workflowInstance.Output); + } + + [Theory(DisplayName = "Sets the output of the workflow instance to a FinishOutput which contains the expected output after RunWorkflowAsync is used"), AutoMoqData] + public async Task RunWorkflowAsyncShouldReturnExpectedOutput([Frozen] object expectedOutput, + FinishWorkflow sut) + { + var workflowInstance = await WorkflowRunner.RunWorkflowAsync(sut); + var actualOutput = (workflowInstance.Output as FinishOutput)?.Output; + + Assert.Same(expectedOutput, actualOutput); } } } \ No newline at end of file diff --git a/test/unit/Elsa.UnitTests/AutoMoqDataAttribute.cs b/test/shared/Elsa.Testing.Shared/AutoMoqDataAttribute.cs similarity index 100% rename from test/unit/Elsa.UnitTests/AutoMoqDataAttribute.cs rename to test/shared/Elsa.Testing.Shared/AutoMoqDataAttribute.cs