Frontend gaps fill work. Testing fixes work. Auditing in progress.

This commit is contained in:
StellaOps Bot
2025-12-30 01:22:58 +02:00
parent 1dc4bcbf10
commit 7a5210e2aa
928 changed files with 183942 additions and 3941 deletions

View File

@@ -1,6 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<OutputType>Exe</OutputType>
<UseAppHost>true</UseAppHost>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
@@ -8,7 +10,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.TimeProvider.Testing" />
<PackageReference Include="xunit" >
<PackageReference Include="xunit.v3.assert">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit.v3.core">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
@@ -18,3 +23,6 @@
<ProjectReference Include="../StellaOps.Infrastructure.Postgres.Testing/StellaOps.Infrastructure.Postgres.Testing.csproj" />
</ItemGroup>
</Project>

View File

@@ -1,6 +1,5 @@
using System.Reflection;
using Xunit;
using Xunit.Sdk;
namespace StellaOps.Infrastructure.Postgres.Testing;
@@ -24,9 +23,8 @@ namespace StellaOps.Infrastructure.Postgres.Testing;
/// </code>
/// </remarks>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public sealed class MigrationTestAttribute : BeforeAfterTestAttribute
public sealed class MigrationTestAttribute : Attribute
{
/// <summary>
/// Gets or sets whether to truncate tables before the test runs.
/// Default is true.
@@ -43,42 +41,6 @@ public sealed class MigrationTestAttribute : BeforeAfterTestAttribute
/// Gets or sets specific table names to truncate. If null or empty, all tables are truncated.
/// </summary>
public string[]? Tables { get; set; }
/// <summary>
/// Called before the test method runs.
/// </summary>
public override void Before(MethodInfo methodUnderTest)
{
if (!TruncateBefore)
{
return;
}
// Try to find the fixture from the test class
var testClass = methodUnderTest.DeclaringType;
if (testClass is null) return;
// Look for a field or property of type PostgresIntegrationFixture
var fixtureField = testClass
.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)
.FirstOrDefault(f => typeof(PostgresIntegrationFixture).IsAssignableFrom(f.FieldType));
var fixtureProperty = testClass
.GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)
.FirstOrDefault(p => typeof(PostgresIntegrationFixture).IsAssignableFrom(p.PropertyType));
// Note: We can't access the instance here in xUnit's BeforeAfterTestAttribute
// This is a limitation - the actual truncation needs to be done via a different mechanism
// See MigrationTestFixture for a better approach
}
/// <summary>
/// Called after the test method runs.
/// </summary>
public override void After(MethodInfo methodUnderTest)
{
// Cleanup is optional and typically not needed
}
}
/// <summary>
@@ -117,7 +79,7 @@ public abstract class MigrationTestBase<TFixture> : IAsyncLifetime
/// Called before each test. Override to customize initialization.
/// By default, truncates all tables for test isolation.
/// </summary>
public virtual async Task InitializeAsync()
public virtual async ValueTask InitializeAsync()
{
await _fixture.TruncateAllTablesAsync().ConfigureAwait(false);
}
@@ -125,9 +87,9 @@ public abstract class MigrationTestBase<TFixture> : IAsyncLifetime
/// <summary>
/// Called after each test. Override to customize cleanup.
/// </summary>
public virtual Task DisposeAsync()
public virtual ValueTask DisposeAsync()
{
return Task.CompletedTask;
return ValueTask.CompletedTask;
}
/// <summary>
@@ -151,3 +113,7 @@ public static class MigrationTestCollection
/// </summary>
public const string Name = "MigrationTests";
}

View File

@@ -67,7 +67,7 @@ public abstract class PostgresIntegrationFixture : IAsyncLifetime
/// <summary>
/// Initializes the PostgreSQL container and runs migrations.
/// </summary>
public virtual async Task InitializeAsync()
public virtual async ValueTask InitializeAsync()
{
try
{
@@ -114,7 +114,7 @@ public abstract class PostgresIntegrationFixture : IAsyncLifetime
/// <summary>
/// Cleans up the PostgreSQL container and fixture.
/// </summary>
public virtual async Task DisposeAsync()
public virtual async ValueTask DisposeAsync()
{
if (_fixture != null)
{
@@ -155,3 +155,5 @@ public sealed class PostgresIntegrationFixtureWithoutMigrations : PostgresIntegr
protected override Assembly? GetMigrationAssembly() => null;
protected override string GetModuleName() => "Test";
}

View File

@@ -3,6 +3,8 @@
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<OutputType>Exe</OutputType>
<UseAppHost>true</UseAppHost>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>preview</LangVersion>
@@ -15,7 +17,8 @@
<ItemGroup>
<PackageReference Include="Testcontainers.PostgreSql" />
<PackageReference Include="xunit" PrivateAssets="all" />
<PackageReference Include="xunit.v3.assert" PrivateAssets="all" />
<PackageReference Include="xunit.v3.core" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
@@ -23,3 +26,6 @@
</ItemGroup>
</Project>

View File

@@ -18,7 +18,7 @@ public abstract class NetworkIsolatedTestBase : IAsyncLifetime
_monitor = new NetworkMonitor(OnNetworkAttempt);
}
public virtual async Task InitializeAsync()
public virtual async ValueTask InitializeAsync()
{
// Install network interception
await _monitor.StartMonitoringAsync();
@@ -30,7 +30,7 @@ public abstract class NetworkIsolatedTestBase : IAsyncLifetime
_monitor.BlockDns();
}
public virtual async Task DisposeAsync()
public virtual async ValueTask DisposeAsync()
{
await _monitor.StopMonitoringAsync();
@@ -146,3 +146,7 @@ public sealed class NetworkIsolationViolationException : Exception
{
public NetworkIsolationViolationException(string message) : base(message) { }
}

View File

@@ -2,13 +2,19 @@
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<OutputType>Exe</OutputType>
<UseAppHost>true</UseAppHost>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>preview</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="xunit" PrivateAssets="all" />
<PackageReference Include="xunit.v3.assert" PrivateAssets="all" />
<PackageReference Include="xunit.v3.core" PrivateAssets="all" />
</ItemGroup>
</Project>

View File

@@ -2,6 +2,8 @@
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<OutputType>Exe</OutputType>
<UseAppHost>true</UseAppHost>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>preview</LangVersion>
@@ -11,8 +13,9 @@
<ItemGroup>
<PackageReference Include="FsCheck" />
<PackageReference Include="FsCheck.Xunit" PrivateAssets="all" />
<PackageReference Include="xunit" PrivateAssets="all" />
<PackageReference Include="FsCheck.Xunit.v3" PrivateAssets="all" />
<PackageReference Include="xunit.v3.assert" PrivateAssets="all" />
<PackageReference Include="xunit.v3.core" PrivateAssets="all" />
<PackageReference Include="xunit.runner.visualstudio" PrivateAssets="all">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
@@ -26,3 +29,9 @@
</ItemGroup>
</Project>