Refactor code structure and optimize performance across multiple modules
This commit is contained in:
@@ -19,7 +19,8 @@ public sealed class PolicySimulationEndpointTests : IClassFixture<WebApplication
|
||||
_factory = factory;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task CreateListGetSimulation()
|
||||
{
|
||||
using var client = _factory.CreateClient();
|
||||
@@ -56,7 +57,8 @@ public sealed class PolicySimulationEndpointTests : IClassFixture<WebApplication
|
||||
Assert.Equal(runId, simulation.GetProperty("simulation").GetProperty("runId").GetString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task MetricsEndpointWithoutProviderReturns501()
|
||||
{
|
||||
using var client = _factory.CreateClient();
|
||||
@@ -67,7 +69,8 @@ public sealed class PolicySimulationEndpointTests : IClassFixture<WebApplication
|
||||
Assert.Equal(HttpStatusCode.NotImplemented, response.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task MetricsEndpointReturnsSummary()
|
||||
{
|
||||
var stub = new StubPolicySimulationMetricsProvider
|
||||
@@ -111,7 +114,8 @@ public sealed class PolicySimulationEndpointTests : IClassFixture<WebApplication
|
||||
Assert.Equal(2.0, payload.GetProperty("policy_simulation_latency").GetProperty("mean_seconds").GetDouble());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task CreateSimulationRequiresScopeHeader()
|
||||
{
|
||||
using var client = _factory.CreateClient();
|
||||
@@ -126,7 +130,8 @@ public sealed class PolicySimulationEndpointTests : IClassFixture<WebApplication
|
||||
Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task CreateSimulationRequiresPolicySimulateScope()
|
||||
{
|
||||
using var client = _factory.CreateClient();
|
||||
@@ -142,7 +147,8 @@ public sealed class PolicySimulationEndpointTests : IClassFixture<WebApplication
|
||||
Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task CancelSimulationMarksStatus()
|
||||
{
|
||||
using var client = _factory.CreateClient();
|
||||
@@ -167,7 +173,8 @@ public sealed class PolicySimulationEndpointTests : IClassFixture<WebApplication
|
||||
Assert.True(cancelled.GetProperty("simulation").GetProperty("cancellationRequested").GetBoolean());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task RetrySimulationCreatesNewRun()
|
||||
{
|
||||
using var client = _factory.CreateClient();
|
||||
@@ -197,7 +204,8 @@ public sealed class PolicySimulationEndpointTests : IClassFixture<WebApplication
|
||||
Assert.Equal(runId, retryOf.GetString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task StreamSimulationEmitsCoreEvents()
|
||||
{
|
||||
using var client = _factory.CreateClient();
|
||||
@@ -227,6 +235,7 @@ public sealed class PolicySimulationEndpointTests : IClassFixture<WebApplication
|
||||
var seenHeartbeat = false;
|
||||
|
||||
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(2));
|
||||
using StellaOps.TestKit;
|
||||
while (!cts.Token.IsCancellationRequested && !(seenRetry && seenInitial && seenQueueLag && seenHeartbeat))
|
||||
{
|
||||
var readTask = reader.ReadLineAsync();
|
||||
|
||||
Reference in New Issue
Block a user