Skip to content

Commit

Permalink
Moved api test to api solution
Browse files Browse the repository at this point in the history
  • Loading branch information
RasmusGraabaek committed Dec 20, 2024
1 parent b40f6ce commit 1ae31bd
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,8 @@
<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>

<ItemGroup>
<Folder Include="Integration\Processes\BRS_X01\NoInputExample\V1\" />
</ItemGroup>
</Project>
52 changes: 49 additions & 3 deletions source/ProcessManager.Tests/Fixtures/ProcessManagerAppFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,81 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using Energinet.DataHub.Core.FunctionApp.TestCommon.Azurite;
using Energinet.DataHub.Core.FunctionApp.TestCommon.Configuration;
using Energinet.DataHub.ProcessManager.Core.Tests.Fixtures;
using Energinet.DataHub.ProcessManager.Example.Orchestrations.Tests.Fixtures;
using Xunit.Abstractions;

namespace Energinet.DataHub.ProcessManager.Tests.Fixtures;

/// <summary>
/// Support testing Process Manager Orchestrations app using default fixture configuration.
/// </summary>
public class ProcessManagerAppFixture
: IAsyncLifetime
public class ProcessManagerAppFixture : IAsyncLifetime
{
private const string TaskHubName = "ApiOrchestrationsAppTest01";

public ProcessManagerAppFixture()
{
ProcessManagerAppManager = new ProcessManagerAppManager();
DatabaseManager = new ProcessManagerDatabaseManager("ApiOrchestrationsAppTests");
AzuriteManager = new AzuriteManager(useOAuth: true);

IntegrationTestConfiguration = new IntegrationTestConfiguration();

ExampleOrchestrationsAppManager = new ExampleOrchestrationsAppManager(
DatabaseManager,
IntegrationTestConfiguration,
AzuriteManager,
taskHubName: TaskHubName,
appPort: 8201,
manageDatabase: false,
manageAzurite: false);

ProcessManagerAppManager = new ProcessManagerAppManager(
DatabaseManager,
IntegrationTestConfiguration,
AzuriteManager,
taskHubName: TaskHubName,
appPort: 8202,
manageDatabase: false,
manageAzurite: false);
}

public IntegrationTestConfiguration IntegrationTestConfiguration { get; }

public ExampleOrchestrationsAppManager ExampleOrchestrationsAppManager { get; }

public ProcessManagerAppManager ProcessManagerAppManager { get; }

private ProcessManagerDatabaseManager DatabaseManager { get; }

private AzuriteManager AzuriteManager { get; }

public async Task InitializeAsync()
{
AzuriteManager.CleanupAzuriteStorage();
AzuriteManager.StartAzurite();

await DatabaseManager.CreateDatabaseAsync();

await ExampleOrchestrationsAppManager.StartAsync();
await ProcessManagerAppManager.StartAsync();
}

public async Task DisposeAsync()
{
await ExampleOrchestrationsAppManager.DisposeAsync();
await ProcessManagerAppManager.DisposeAsync();

await DatabaseManager.DeleteDatabaseAsync();

AzuriteManager.Dispose();
}

public void SetTestOutputHelper(ITestOutputHelper? testOutputHelper)
{
ExampleOrchestrationsAppManager.SetTestOutputHelper(testOutputHelper);
ProcessManagerAppManager.SetTestOutputHelper(testOutputHelper);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,29 @@
using Energinet.DataHub.ProcessManager.Abstractions.Api.Model;
using Energinet.DataHub.ProcessManager.Abstractions.Api.Model.OrchestrationInstance;
using Energinet.DataHub.ProcessManager.Example.Orchestrations.Abstractions.Processes.BRS_X01.InputExample.V1.Model;
using Energinet.DataHub.ProcessManager.Example.Orchestrations.Tests.Fixtures;
using Energinet.DataHub.ProcessManager.Tests.Fixtures;
using FluentAssertions;
using Xunit.Abstractions;

namespace Energinet.DataHub.ProcessManager.Example.Orchestrations.Tests.Integration.Processes.BRS_X01.InputExample.V1;
namespace Energinet.DataHub.ProcessManager.Tests.Integration.Processes.BRS_X01.InputExample.V1;

/// <summary>
/// Test case where we verify the ProcessManager.Example.Orchestrations and Process Manager Api
/// can be used to start an example orchestration (with input parameter) and
/// monitor its status during its lifetime.
/// </summary>
[Collection(nameof(ExampleOrchestrationsAppCollection))]
public class MonitorInputExampleUsingApiScenario : IAsyncLifetime
[Collection(nameof(ProcessManagerAppCollection))]
public class MonitorOrchestrationUsingApiScenario : IAsyncLifetime
{
public MonitorInputExampleUsingApiScenario(
ExampleOrchestrationsAppFixture fixture,
public MonitorOrchestrationUsingApiScenario(
ProcessManagerAppFixture fixture,
ITestOutputHelper testOutputHelper)
{
Fixture = fixture;
Fixture.SetTestOutputHelper(testOutputHelper);
}

private ExampleOrchestrationsAppFixture Fixture { get; }
private ProcessManagerAppFixture Fixture { get; }

public Task InitializeAsync()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,29 @@
using Energinet.DataHub.ProcessManager.Abstractions.Api.Model;
using Energinet.DataHub.ProcessManager.Abstractions.Api.Model.OrchestrationInstance;
using Energinet.DataHub.ProcessManager.Example.Orchestrations.Abstractions.Processes.BRS_X01.NoInputExample.V1.Model;
using Energinet.DataHub.ProcessManager.Example.Orchestrations.Tests.Fixtures;
using Energinet.DataHub.ProcessManager.Tests.Fixtures;
using FluentAssertions;
using Xunit.Abstractions;

namespace Energinet.DataHub.ProcessManager.Example.Orchestrations.Tests.Integration.Processes.BRS_X01.NoInputExample.V1;
namespace Energinet.DataHub.ProcessManager.Tests.Integration.Processes.BRS_X01.NoInputExample.V1;

/// <summary>
/// Test case where we verify the ProcessManager.Example.Orchestrations and Process Manager Api
/// can be used to start an example orchestration (with no-input parameter) and
/// monitor its status during its lifetime.
/// </summary>
[Collection(nameof(ExampleOrchestrationsAppCollection))]
public class MonitorNoInputExampleUsingApiScenario : IAsyncLifetime
[Collection(nameof(ProcessManagerAppCollection))]
public class MonitorOrchestrationUsingApiScenario : IAsyncLifetime
{
public MonitorNoInputExampleUsingApiScenario(
ExampleOrchestrationsAppFixture fixture,
public MonitorOrchestrationUsingApiScenario(
ProcessManagerAppFixture fixture,
ITestOutputHelper testOutputHelper)
{
Fixture = fixture;
Fixture.SetTestOutputHelper(testOutputHelper);
}

private ExampleOrchestrationsAppFixture Fixture { get; }
private ProcessManagerAppFixture Fixture { get; }

public Task InitializeAsync()
{
Expand Down
2 changes: 2 additions & 0 deletions source/ProcessManager.Tests/ProcessManager.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<ItemGroup>
<Compile Include="..\ProcessManager.Core.Tests\Fixtures\ProcessManagerDatabaseManager.cs" Link="Fixtures\ProcessManagerDatabaseManager.cs" />
<Compile Include="..\ProcessManager.Example.Orchestrations.Tests\Fixtures\ExampleOrchestrationsAppManager.cs" Link="Fixtures\ExampleOrchestrationsAppManager.cs"/>
</ItemGroup>

<ItemGroup>
Expand All @@ -24,6 +25,7 @@

<ItemGroup>
<ProjectReference Include="..\ProcessManager.DatabaseMigration\ProcessManager.DatabaseMigration.csproj" />
<ProjectReference Include="..\ProcessManager.Example.Orchestrations.Abstrations\ProcessManager.Example.Orchestrations.Abstrations.csproj" />
<ProjectReference Include="..\ProcessManager\ProcessManager.csproj" />
</ItemGroup>

Expand Down

0 comments on commit 1ae31bd

Please sign in to comment.