* WIP #653 - Delete two tests These two couldn't easily be fixed, in both cases they were integration tests which involved passing through many classes. It wasn't immediately clear what needed to be done to fix them. As noted in the issue description, removing them was an acceptable fix. * WIP #653 - Fix a failing test I split this test into two. Per the discussion at: https://github.com/xunit/xunit/issues/350 XUnit seems quite opinonated about not having assertion messages. Thus, without changing assertion library (which deserves discussion before I just do it), the logical next best thing is to split into two single-assert tests, so it's clear which assertion failed on a test failure. Also, I moved the AutoMoqData attribute to the shared test lib, so that it can be used anywhere. That allowed me to eliminate the constructor for this test class, except for initialising the base class. * Provisionally resolve #653 - reinstate tests in CI This should complete the issue although we need to see a passing CI build with this code change before we can say it's done. * Provisionally resolves #653 - Add test script
This commit is contained in:
parent
3bf5237328
commit
f34409696d
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<string>(),
|
||||
Type = nameof(WriteLine),
|
||||
Properties = new List<ActivityDefinitionProperty>()
|
||||
{
|
||||
ActivityDefinitionProperty.Literal(nameof(WriteLine.Text), "Hello World!")
|
||||
}
|
||||
};
|
||||
|
||||
var readLine = new ActivityDefinition {ActivityId = Fixture.Create<string>(), Type = nameof(ReadLine)};
|
||||
var activities = new[] {writeLine, readLine};
|
||||
var connections = new[] {new ConnectionDefinition(writeLine.ActivityId, readLine.ActivityId, OutcomeNames.Done)};
|
||||
|
||||
return Fixture.Build<SaveWorkflowDefinitionRequest>()
|
||||
.With(x => x.Activities, activities)
|
||||
.With(x => x.Connections, connections)
|
||||
.Create();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,9 +7,11 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoFixture.AutoMoq" Version="4.15.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
|
||||
<PackageReference Include="Autofixture" Version="4.15.0" />
|
||||
<PackageReference Include="Autofixture.AutoMoq" Version="4.15.0" />
|
||||
<PackageReference Include="autofixture.xunit2" Version="4.15.0" />
|
||||
<PackageReference Include="Moq" Version="4.16.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
|
||||
<PackageReference Include="NodaTime.Testing" Version="3.0.3" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||
|
|
|
|||
|
|
@ -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<IBlobStorage>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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<string>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue