- Implemented tests for RouterConfig, RoutingOptions, StaticInstanceConfig, and RouterConfigOptions to ensure default values are set correctly. - Added tests for RouterConfigProvider to validate configurations and ensure defaults are returned when no file is specified. - Created tests for ConfigValidationResult to check success and error scenarios. - Developed tests for ServiceCollectionExtensions to verify service registration for RouterConfig. - Introduced UdpTransportTests to validate serialization, connection, request-response, and error handling in UDP transport. - Added scripts for signing authority gaps and hashing DevPortal SDK snippets.
80 lines
2.5 KiB
C#
80 lines
2.5 KiB
C#
using System.Net;
|
|
using FluentAssertions;
|
|
using Xunit;
|
|
|
|
namespace Examples.Integration.Tests;
|
|
|
|
/// <summary>
|
|
/// Tests that verify multiple microservices can register and receive
|
|
/// correctly routed requests through the gateway.
|
|
/// </summary>
|
|
public sealed class MultiServiceRoutingTests : IClassFixture<GatewayFixture>
|
|
{
|
|
private readonly GatewayFixture _fixture;
|
|
|
|
public MultiServiceRoutingTests(GatewayFixture fixture)
|
|
{
|
|
_fixture = fixture;
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Gateway_RoutesBillingRequests_ToBillingService()
|
|
{
|
|
// Act
|
|
var response = await _fixture.GatewayClient.GetAsync("/invoices/INV-001");
|
|
|
|
// Assert
|
|
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
|
var content = await response.Content.ReadAsStringAsync();
|
|
content.Should().Contain("INV-001");
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Gateway_RoutesInventoryRequests_ToInventoryService()
|
|
{
|
|
// Act
|
|
var response = await _fixture.GatewayClient.GetAsync("/items/SKU-001");
|
|
|
|
// Assert
|
|
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
|
var content = await response.Content.ReadAsStringAsync();
|
|
content.Should().Contain("SKU-001");
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Gateway_HandlesSequentialRequestsToDifferentServices()
|
|
{
|
|
// Act - Send requests to both services
|
|
var billingResponse = await _fixture.GatewayClient.GetAsync("/invoices/INV-001");
|
|
var inventoryResponse = await _fixture.GatewayClient.GetAsync("/items/SKU-001");
|
|
|
|
// Assert - Both should succeed
|
|
billingResponse.StatusCode.Should().Be(HttpStatusCode.OK);
|
|
inventoryResponse.StatusCode.Should().Be(HttpStatusCode.OK);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Gateway_HandlesConcurrentRequestsToDifferentServices()
|
|
{
|
|
// Act - Send requests to both services concurrently
|
|
var billingTask = _fixture.GatewayClient.GetAsync("/invoices/INV-001");
|
|
var inventoryTask = _fixture.GatewayClient.GetAsync("/items/SKU-001");
|
|
|
|
await Task.WhenAll(billingTask, inventoryTask);
|
|
|
|
// Assert - Both should succeed
|
|
billingTask.Result.StatusCode.Should().Be(HttpStatusCode.OK);
|
|
inventoryTask.Result.StatusCode.Should().Be(HttpStatusCode.OK);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Gateway_ReturnsNotFound_ForUnknownRoute()
|
|
{
|
|
// Act
|
|
var response = await _fixture.GatewayClient.GetAsync("/unknown/route");
|
|
|
|
// Assert
|
|
response.StatusCode.Should().Be(HttpStatusCode.NotFound);
|
|
}
|
|
}
|