Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
aeshub committed Apr 23, 2024
1 parent 9a89f7e commit 1c46749
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 21 deletions.
11 changes: 3 additions & 8 deletions backend/api.test/Controllers/MissionSchedulingControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Net.Http;
using System.Net.Http.Json;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Api.Controllers.Models;
using Api.Database.Context;
Expand Down Expand Up @@ -35,13 +36,10 @@ public class MissionSchedulingControllerTests(ITestOutputHelper outputHelper) :

public async Task InitializeAsync()
{
(var container, string connectionString, var connection) =
(_container, _connectionString, _connection) =
await TestSetupHelpers.ConfigurePostgreSqlContainer();
_container = container;
_connectionString = connectionString;
_connection = connection;

outputHelper.WriteLine($"Connection string is {connectionString}");
outputHelper.WriteLine($"Connection string is {_connectionString}");

_databaseUtilities = new DatabaseUtilities(Context);

Expand All @@ -57,13 +55,10 @@ public async Task InitializeAsync()

public async Task DisposeAsync()
{
//await Task.CompletedTask;
//await Context.DisposeAsync();
//await _connection.CloseAsync();
await _factory.DisposeAsync();
await _container.DisposeAsync();

//await Task.Delay(5000);
}

private FlotillaDbContext CreateContext()
Expand Down
8 changes: 2 additions & 6 deletions backend/api.test/EventHandlers/TestMissionEventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,9 @@ public class TestMissionEventHandler(ITestOutputHelper outputHelper) : IAsyncLif

public async Task InitializeAsync()
{
(var container, string connectionString, var connection) =
(_container, _connectionString, _connection) =
await TestSetupHelpers.ConfigurePostgreSqlContainer();
outputHelper.WriteLine($"Connection string is {connectionString}");

_container = container;
_connectionString = connectionString;
_connection = connection;
outputHelper.WriteLine($"Connection string is {_connectionString}");

_databaseUtilities = new DatabaseUtilities(Context);

Expand Down
10 changes: 10 additions & 0 deletions backend/api.test/TestWebApplicationFactory.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using System;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Api.Database.Context;
using Api.EventHandlers;
using Api.Mqtt;
using Api.Services;
using Api.Test.Mocks;
using Api.Test.Utilities;
Expand Down Expand Up @@ -87,6 +90,13 @@ protected override void ConfigureWebHost(IWebHostBuilder builder)
public override async ValueTask DisposeAsync()
{
Console.WriteLine("Test");
//var token = new CancellationToken(true);
//await this.Services.GetRequiredService<MissionEventHandler>().StopAsync(token);
//await this.Services.GetRequiredService<MqttEventHandler>().StopAsync(token);
//await this.Services.GetRequiredService<InspectionFindingEventHandler>().StopAsync(token);
//await this.Services.GetRequiredService<MqttService>().StopAsync(token);
//await this.Services.GetRequiredService<IsarConnectionEventHandler>().StopAsync(token);

await base.DisposeAsync();
}
}
Expand Down
8 changes: 1 addition & 7 deletions backend/api.test/Utilities/DbContextTestSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,12 @@ public class DatabaseFixture : IAsyncLifetime

public async Task InitializeAsync()
{
(var container, string connectionString, var connection) =
(Container, ConnectionString, Connection) =
await TestSetupHelpers.ConfigurePostgreSqlContainer();
Container = container;
ConnectionString = connectionString;
Connection = connection;

Respawner = await TestSetupHelpers.ConfigureDatabaseRespawner(Connection);

Factory = TestSetupHelpers.ConfigureWebApplicationFactory(ConnectionString);
Client = TestSetupHelpers.ConfigureHttpClient(Factory);
ServiceProvider = TestSetupHelpers.ConfigureServiceProvider(Factory);

SerializerOptions = TestSetupHelpers.ConfigureJsonSerializerOptions();
}

Expand Down

0 comments on commit 1c46749

Please sign in to comment.