Initial import of the CBDDC codebase with docs and tests. Add a .NET-focused gitignore to keep generated artifacts out of source control.
Some checks failed
CI / verify (push) Has been cancelled
Some checks failed
CI / verify (push) Has been cancelled
This commit is contained in:
42
tests/ZB.MOM.WW.CBDDC.Hosting.Tests/HostedServicesTests.cs
Normal file
42
tests/ZB.MOM.WW.CBDDC.Hosting.Tests/HostedServicesTests.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// Verifies that the TCP sync server hosted service starts and stops the server lifecycle.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task TcpSyncServerHostedService_StartAndStop_CallsServerLifecycle()
|
||||
{
|
||||
var syncServer = Substitute.For<ISyncServer>();
|
||||
var logger = Substitute.For<ILogger<TcpSyncServerHostedService>>();
|
||||
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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the discovery hosted service starts and stops the discovery lifecycle.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task DiscoveryServiceHostedService_StartAndStop_CallsDiscoveryLifecycle()
|
||||
{
|
||||
var discoveryService = Substitute.For<IDiscoveryService>();
|
||||
var logger = Substitute.For<ILogger<DiscoveryServiceHostedService>>();
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user