Refactor code structure and optimize performance across multiple modules
This commit is contained in:
@@ -16,6 +16,8 @@ using StellaOps.Graph.Api.Contracts;
|
||||
using StellaOps.Graph.Api.Services;
|
||||
using Xunit;
|
||||
|
||||
|
||||
using StellaOps.TestKit;
|
||||
namespace StellaOps.Graph.Api.Tests;
|
||||
|
||||
/// <summary>
|
||||
@@ -61,7 +63,8 @@ public sealed class GraphApiContractTests : IDisposable
|
||||
|
||||
#region GRAPH-5100-006: Contract Tests
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Query_ReturnsNdjsonFormat()
|
||||
{
|
||||
// Arrange
|
||||
@@ -88,7 +91,8 @@ public sealed class GraphApiContractTests : IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Query_ReturnsNodeTypeInResponse()
|
||||
{
|
||||
// Arrange
|
||||
@@ -109,7 +113,8 @@ public sealed class GraphApiContractTests : IDisposable
|
||||
lines.Should().Contain(l => l.Contains("\"type\":\"node\""));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Query_WithEdges_ReturnsEdgeTypeInResponse()
|
||||
{
|
||||
// Arrange
|
||||
@@ -131,7 +136,8 @@ public sealed class GraphApiContractTests : IDisposable
|
||||
lines.Should().Contain(l => l.Contains("\"type\":\"edge\""));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Query_WithStats_ReturnsStatsTypeInResponse()
|
||||
{
|
||||
// Arrange
|
||||
@@ -153,7 +159,8 @@ public sealed class GraphApiContractTests : IDisposable
|
||||
lines.Should().Contain(l => l.Contains("\"type\":\"stats\""));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Query_ReturnsCursorInResponse()
|
||||
{
|
||||
// Arrange
|
||||
@@ -174,7 +181,8 @@ public sealed class GraphApiContractTests : IDisposable
|
||||
lines.Should().Contain(l => l.Contains("\"type\":\"cursor\""));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Query_EmptyResult_ReturnsEmptyCursor()
|
||||
{
|
||||
// Arrange
|
||||
@@ -195,7 +203,8 @@ public sealed class GraphApiContractTests : IDisposable
|
||||
lines.Should().Contain(l => l.Contains("\"type\":\"cursor\""));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Query_BudgetExceeded_ReturnsErrorResponse()
|
||||
{
|
||||
// Arrange
|
||||
@@ -222,7 +231,8 @@ public sealed class GraphApiContractTests : IDisposable
|
||||
|
||||
#region GRAPH-5100-007: Auth Tests
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void AuthScope_GraphRead_IsRequired()
|
||||
{
|
||||
// This is a validation test - actual scope enforcement is in middleware
|
||||
@@ -233,7 +243,8 @@ public sealed class GraphApiContractTests : IDisposable
|
||||
expectedScope.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void AuthScope_GraphWrite_IsRequired()
|
||||
{
|
||||
// This is a validation test - actual scope enforcement is in middleware
|
||||
@@ -243,7 +254,8 @@ public sealed class GraphApiContractTests : IDisposable
|
||||
expectedScope.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Query_ReturnsOnlyRequestedTenantData()
|
||||
{
|
||||
// Arrange - Request tenant1 data
|
||||
@@ -264,7 +276,8 @@ public sealed class GraphApiContractTests : IDisposable
|
||||
lines.Should().NotContain(l => l.Contains("tenant2"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Query_CrossTenant_ReturnsOnlyOwnData()
|
||||
{
|
||||
// Arrange - Request tenant2 data (which has only 1 artifact)
|
||||
@@ -286,7 +299,8 @@ public sealed class GraphApiContractTests : IDisposable
|
||||
nodesFound.Should().Be(1, "tenant2 has only 1 artifact");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Query_InvalidTenant_ReturnsEmptyResults()
|
||||
{
|
||||
// Arrange
|
||||
@@ -312,7 +326,8 @@ public sealed class GraphApiContractTests : IDisposable
|
||||
|
||||
#region GRAPH-5100-008: OTel Trace Assertions
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Query_EmitsActivityWithTenantId()
|
||||
{
|
||||
// Arrange
|
||||
@@ -344,7 +359,8 @@ public sealed class GraphApiContractTests : IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public async Task Query_MetricsIncludeTenantDimension()
|
||||
{
|
||||
// Arrange
|
||||
@@ -391,7 +407,8 @@ public sealed class GraphApiContractTests : IDisposable
|
||||
tags.Should().NotBeEmpty("Metrics should be recorded during query");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", TestCategories.Unit)]
|
||||
[Fact]
|
||||
public void GraphMetrics_HasExpectedInstruments()
|
||||
{
|
||||
// Arrange
|
||||
|
||||
Reference in New Issue
Block a user