Files
StellaOps Bot 6a299d231f
Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
Policy Lint & Smoke / policy-lint (push) Has been cancelled
Add unit tests for Router configuration and transport layers
- 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.
2025-12-05 08:01:47 +02:00

77 lines
2.2 KiB
C#

using System.Net;
using System.Net.Http.Json;
using System.Text;
using System.Text.Json;
using FluentAssertions;
using Xunit;
namespace Examples.Integration.Tests;
/// <summary>
/// Integration tests for the Billing microservice endpoints.
/// </summary>
public sealed class BillingEndpointTests : IClassFixture<GatewayFixture>
{
private readonly GatewayFixture _fixture;
public BillingEndpointTests(GatewayFixture fixture)
{
_fixture = fixture;
}
[Fact]
public async Task CreateInvoice_WithValidRequest_ReturnsCreatedInvoice()
{
// Arrange
var request = new
{
customerId = "CUST-001",
amount = 99.99m,
description = "Test invoice"
};
// Act
var response = await _fixture.GatewayClient.PostAsJsonAsync("/invoices", request);
// Assert
response.StatusCode.Should().Be(HttpStatusCode.OK);
var content = await response.Content.ReadAsStringAsync();
content.Should().Contain("invoiceId");
}
[Fact]
public async Task GetInvoice_WithValidId_ReturnsInvoice()
{
// Arrange
var invoiceId = "INV-12345";
// Act
var response = await _fixture.GatewayClient.GetAsync($"/invoices/{invoiceId}");
// Assert
response.StatusCode.Should().Be(HttpStatusCode.OK);
var content = await response.Content.ReadAsStringAsync();
content.Should().Contain(invoiceId);
}
[Fact]
public async Task UploadAttachment_WithStreamingData_ReturnsSuccess()
{
// Arrange
var invoiceId = "INV-12345";
var attachmentData = Encoding.UTF8.GetBytes("This is test attachment content");
using var content = new ByteArrayContent(attachmentData);
content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream");
// Act
var response = await _fixture.GatewayClient.PostAsync(
$"/invoices/{invoiceId}/attachments",
content);
// Assert
response.StatusCode.Should().Be(HttpStatusCode.OK);
var responseContent = await response.Content.ReadAsStringAsync();
responseContent.Should().Contain("attachmentId");
}
}