57 lines
1.9 KiB
C#
57 lines
1.9 KiB
C#
using Microsoft.Extensions.DependencyInjection;
|
|
using ZB.MOM.WW.CBDDC.Core.Network;
|
|
using ZB.MOM.WW.CBDDC.Core.Storage;
|
|
|
|
namespace ZB.MOM.WW.CBDDC.Network.Tests;
|
|
|
|
public class MultiDatasetRegistrationTests
|
|
{
|
|
/// <summary>
|
|
/// Verifies CBDDC network registration replaces the default orchestrator with multi-dataset wiring.
|
|
/// </summary>
|
|
[Fact]
|
|
public void AddCBDDCMultiDataset_ShouldRegisterCoordinatorAndReplaceSyncOrchestrator()
|
|
{
|
|
var services = new ServiceCollection();
|
|
|
|
services.AddCBDDCNetwork<TestPeerNodeConfigurationProvider>(useHostedService: false);
|
|
services.AddCBDDCMultiDataset(options =>
|
|
{
|
|
options.EnableMultiDatasetSync = true;
|
|
options.EnableDatasetPrimary = true;
|
|
options.EnableDatasetLogs = true;
|
|
options.EnableDatasetTimeseries = true;
|
|
});
|
|
|
|
services.Any(descriptor => descriptor.ServiceType == typeof(IMultiDatasetSyncOrchestrator)).ShouldBeTrue();
|
|
|
|
var syncDescriptor = services.Last(descriptor => descriptor.ServiceType == typeof(ISyncOrchestrator));
|
|
syncDescriptor.ImplementationFactory.ShouldNotBeNull();
|
|
}
|
|
|
|
private sealed class TestPeerNodeConfigurationProvider : IPeerNodeConfigurationProvider
|
|
{
|
|
/// <summary>
|
|
/// Raised when the peer configuration changes.
|
|
/// </summary>
|
|
public event PeerNodeConfigurationChangedEventHandler? ConfigurationChanged
|
|
{
|
|
add { }
|
|
remove { }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the current peer configuration.
|
|
/// </summary>
|
|
public Task<PeerNodeConfiguration> GetConfiguration()
|
|
{
|
|
return Task.FromResult(new PeerNodeConfiguration
|
|
{
|
|
NodeId = "node-test",
|
|
TcpPort = 9000,
|
|
AuthToken = "auth"
|
|
});
|
|
}
|
|
}
|
|
}
|