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.
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
using System.Net;
|
||||
using System.Text.Json;
|
||||
using FluentAssertions;
|
||||
using Xunit;
|
||||
|
||||
namespace Examples.Integration.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Integration tests for the Inventory microservice endpoints.
|
||||
/// </summary>
|
||||
public sealed class InventoryEndpointTests : IClassFixture<GatewayFixture>
|
||||
{
|
||||
private readonly GatewayFixture _fixture;
|
||||
|
||||
public InventoryEndpointTests(GatewayFixture fixture)
|
||||
{
|
||||
_fixture = fixture;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ListItems_WithoutFilters_ReturnsAllItems()
|
||||
{
|
||||
// Act
|
||||
var response = await _fixture.GatewayClient.GetAsync("/items");
|
||||
|
||||
// Assert
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
content.Should().Contain("items");
|
||||
content.Should().Contain("totalCount");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ListItems_WithCategoryFilter_ReturnsFilteredItems()
|
||||
{
|
||||
// Act
|
||||
var response = await _fixture.GatewayClient.GetAsync("/items?category=widgets");
|
||||
|
||||
// Assert
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
content.Should().Contain("widgets");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ListItems_WithPagination_ReturnsPaginatedResponse()
|
||||
{
|
||||
// Act
|
||||
var response = await _fixture.GatewayClient.GetAsync("/items?page=1&pageSize=10");
|
||||
|
||||
// Assert
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
content.Should().Contain("\"page\":1");
|
||||
content.Should().Contain("\"pageSize\":10");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetItem_WithValidSku_ReturnsItem()
|
||||
{
|
||||
// Arrange
|
||||
var sku = "SKU-001";
|
||||
|
||||
// Act
|
||||
var response = await _fixture.GatewayClient.GetAsync($"/items/{sku}");
|
||||
|
||||
// Assert
|
||||
response.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
content.Should().Contain(sku);
|
||||
content.Should().Contain("name");
|
||||
content.Should().Contain("quantityOnHand");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user