- 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.
54 lines
1.8 KiB
C#
54 lines
1.8 KiB
C#
using Microsoft.Extensions.DependencyInjection;
|
|
using StellaOps.Router.Common.Abstractions;
|
|
|
|
namespace StellaOps.Router.Transport.Udp;
|
|
|
|
/// <summary>
|
|
/// Extension methods for registering UDP transport services.
|
|
/// </summary>
|
|
public static class ServiceCollectionExtensions
|
|
{
|
|
/// <summary>
|
|
/// Adds UDP transport server services to the service collection.
|
|
/// </summary>
|
|
/// <param name="services">The service collection.</param>
|
|
/// <param name="configure">Optional configuration action.</param>
|
|
/// <returns>The service collection.</returns>
|
|
public static IServiceCollection AddUdpTransportServer(
|
|
this IServiceCollection services,
|
|
Action<UdpTransportOptions>? configure = null)
|
|
{
|
|
if (configure is not null)
|
|
{
|
|
services.Configure(configure);
|
|
}
|
|
|
|
services.AddSingleton<UdpTransportServer>();
|
|
services.AddSingleton<ITransportServer>(sp => sp.GetRequiredService<UdpTransportServer>());
|
|
|
|
return services;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Adds UDP transport client services to the service collection.
|
|
/// </summary>
|
|
/// <param name="services">The service collection.</param>
|
|
/// <param name="configure">Optional configuration action.</param>
|
|
/// <returns>The service collection.</returns>
|
|
public static IServiceCollection AddUdpTransportClient(
|
|
this IServiceCollection services,
|
|
Action<UdpTransportOptions>? configure = null)
|
|
{
|
|
if (configure is not null)
|
|
{
|
|
services.Configure(configure);
|
|
}
|
|
|
|
services.AddSingleton<UdpTransportClient>();
|
|
services.AddSingleton<ITransportClient>(sp => sp.GetRequiredService<UdpTransportClient>());
|
|
services.AddSingleton<IMicroserviceTransport>(sp => sp.GetRequiredService<UdpTransportClient>());
|
|
|
|
return services;
|
|
}
|
|
}
|