using Microsoft.Extensions.Logging; using ZB.MOM.WW.CBDDC.Hosting.HostedServices; using ZB.MOM.WW.CBDDC.Network; namespace ZB.MOM.WW.CBDDC.Hosting.Tests; public class HostedServicesTests { /// /// Verifies that the TCP sync server hosted service starts and stops the server lifecycle. /// [Fact] public async Task TcpSyncServerHostedService_StartAndStop_CallsServerLifecycle() { var syncServer = Substitute.For(); var logger = Substitute.For>(); var hostedService = new TcpSyncServerHostedService(syncServer, logger); await hostedService.StartAsync(CancellationToken.None); await hostedService.StopAsync(CancellationToken.None); await syncServer.Received(1).Start(); await syncServer.Received(1).Stop(); } /// /// Verifies that the discovery hosted service starts and stops the discovery lifecycle. /// [Fact] public async Task DiscoveryServiceHostedService_StartAndStop_CallsDiscoveryLifecycle() { var discoveryService = Substitute.For(); var logger = Substitute.For>(); var hostedService = new DiscoveryServiceHostedService(discoveryService, logger); await hostedService.StartAsync(CancellationToken.None); await hostedService.StopAsync(CancellationToken.None); await discoveryService.Received(1).Start(); await discoveryService.Received(1).Stop(); } }