public void ValidateDisableOnNUll() { UaPubSubApplication uaPubSubApplication = UaPubSubApplication.Create(publisherConfigurationFile); UaPubSubConfigurator configurator = uaPubSubApplication.UaPubSubConfigurator; Assert.Throws <ArgumentException>(() => configurator.Disable(null), "The Disable method does not throw exception when called with null parameter."); }
/// <summary> /// Initializes a new instance of the <see cref="UaPubSubApplication"/> class. /// </summary> /// <param name="dataStore"> The current implementation of <see cref="IUaPubSubDataStore"/> used by this instance of pub sub application</param> /// <param name="applicationId"> The application id for instance.</param> private UaPubSubApplication(IUaPubSubDataStore dataStore = null, string applicationId = null) { m_uaPubSubConnections = new List <IUaPubSubConnection>(); if (dataStore != null) { m_dataStore = dataStore; } else { m_dataStore = new UaPubSubDataStore(); } if (!String.IsNullOrEmpty(applicationId)) { ApplicationId = applicationId; } else { ApplicationId = $"opcua:{System.Net.Dns.GetHostName()}:{new Random().Next().ToString("D10")}"; } m_dataCollector = new DataCollector(m_dataStore); m_uaPubSubConfigurator = new UaPubSubConfigurator(); m_uaPubSubConfigurator.ConnectionAdded += UaPubSubConfigurator_ConnectionAdded; m_uaPubSubConfigurator.ConnectionRemoved += UaPubSubConfigurator_ConnectionRemoved; m_uaPubSubConfigurator.PublishedDataSetAdded += UaPubSubConfigurator_PublishedDataSetAdded; m_uaPubSubConfigurator.PublishedDataSetRemoved += UaPubSubConfigurator_PublishedDataSetRemoved; Utils.Trace("An instance of UaPubSubApplication was created."); }
public void ValidateDisableOnNonExisting() { UaPubSubApplication uaPubSubApplication = UaPubSubApplication.Create(publisherConfigurationFile); UaPubSubConfigurator configurator = uaPubSubApplication.UaPubSubConfigurator; PubSubConfigurationDataType nonExisting = new PubSubConfigurationDataType(); Assert.Throws <ArgumentException>(() => configurator.Disable(nonExisting), "The Disable method does not throw exception when called with non existing parameter."); }
public void ValidateOperational_2ToDisabled_0_Reader() { UaPubSubApplication uaPubSubApplication = UaPubSubApplication.Create(SubscriberConfigurationFileName); UaPubSubConfigurator configurator = uaPubSubApplication.UaPubSubConfigurator; // The hierarchy PubSub -> PubSubConnection -> PubSubReaderGroup -> DataSetReader brought to [Disabled, Disabled, Disabled, Disabled] PubSubConfigurationDataType pubSub = uaPubSubApplication.UaPubSubConfigurator.PubSubConfiguration; PubSubConnectionDataType subscriberConnection = uaPubSubApplication.UaPubSubConfigurator.PubSubConfiguration.Connections[0]; ReaderGroupDataType readerGroup = subscriberConnection.ReaderGroups[0]; DataSetReaderDataType datasetReader = readerGroup.DataSetReaders[0]; configurator.Disable(pubSub); configurator.Disable(subscriberConnection); configurator.Disable(readerGroup); configurator.Disable(datasetReader); PubSubState psState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(pubSub); PubSubState conState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(subscriberConnection); PubSubState rgState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(readerGroup); PubSubState dsrState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(datasetReader); Assert.That(psState == PubSubState.Disabled, Is.True); Assert.That(conState == PubSubState.Disabled, Is.True); Assert.That(rgState == PubSubState.Disabled, Is.True); Assert.That(dsrState == PubSubState.Disabled, Is.True); // The hierarchy PubSub -> PubSubConnection -> PubSubReaderGroup -> DataSetReader brought to [Operational, Operational, Operational, Operational] configurator.Enable(pubSub); configurator.Enable(subscriberConnection); configurator.Enable(readerGroup); configurator.Enable(datasetReader); psState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(pubSub); conState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(subscriberConnection); rgState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(readerGroup); dsrState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(datasetReader); Assert.That(psState == PubSubState.Operational, Is.True); Assert.That(conState == PubSubState.Operational, Is.True); Assert.That(rgState == PubSubState.Operational, Is.True); Assert.That(dsrState == PubSubState.Operational, Is.True); // The hierarchy PubSub -> PubSubConnection -> PubSubReaderGroup -> DataSetReader brought to [Disabled, Disabled, Disabled, Disabled] configurator.Disable(pubSub); configurator.Disable(subscriberConnection); configurator.Disable(readerGroup); configurator.Disable(datasetReader); psState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(pubSub); conState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(subscriberConnection); rgState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(readerGroup); dsrState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(datasetReader); Assert.That(psState == PubSubState.Disabled, Is.True); Assert.That(conState == PubSubState.Disabled, Is.True); Assert.That(rgState == PubSubState.Disabled, Is.True); Assert.That(dsrState == PubSubState.Disabled, Is.True); }
public void ValidateDisableOnDisabled() { UaPubSubApplication uaPubSubApplication = UaPubSubApplication.Create(publisherConfigurationFile); UaPubSubConfigurator configurator = uaPubSubApplication.UaPubSubConfigurator; PubSubConfigurationDataType pubSub = uaPubSubApplication.UaPubSubConfigurator.PubSubConfiguration; configurator.Disable(pubSub); Assert.AreEqual((StatusCode)StatusCodes.BadInvalidState, configurator.Disable(pubSub)); }
public void ValidateOperational_2ToDisabled_0_Publisher() { UaPubSubApplication uaPubSubApplication = UaPubSubApplication.Create(publisherConfigurationFile); UaPubSubConfigurator configurator = uaPubSubApplication.UaPubSubConfigurator; // The hierarchy PubSub -> PubSubConnection -> PubSubWriterGroup -> DataSetWriter brought to [Disabled, Disabled, Disabled, Disabled] PubSubConfigurationDataType pubSub = uaPubSubApplication.UaPubSubConfigurator.PubSubConfiguration; PubSubConnectionDataType publisherConnection = uaPubSubApplication.UaPubSubConfigurator.PubSubConfiguration.Connections.First(); WriterGroupDataType writerGroup = publisherConnection.WriterGroups[0]; DataSetWriterDataType datasetWriter = writerGroup.DataSetWriters[0]; configurator.Disable(pubSub); configurator.Disable(publisherConnection); configurator.Disable(writerGroup); configurator.Disable(datasetWriter); PubSubState psState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(pubSub); PubSubState conState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(publisherConnection); PubSubState wgState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(writerGroup); PubSubState dswState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(datasetWriter); Assert.That(psState == PubSubState.Disabled, Is.True); Assert.That(conState == PubSubState.Disabled, Is.True); Assert.That(wgState == PubSubState.Disabled, Is.True); Assert.That(dswState == PubSubState.Disabled, Is.True); // The hierarchy PubSub -> PubSubConnection -> PubSubWriterGroup -> DataSetWriter brought to [Operational, Operational, Operational, Operational] configurator.Enable(pubSub); configurator.Enable(publisherConnection); configurator.Enable(writerGroup); configurator.Enable(datasetWriter); psState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(pubSub); conState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(publisherConnection); wgState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(writerGroup); dswState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(datasetWriter); Assert.That(psState == PubSubState.Operational, Is.True); Assert.That(conState == PubSubState.Operational, Is.True); Assert.That(wgState == PubSubState.Operational, Is.True); Assert.That(dswState == PubSubState.Operational, Is.True); // The hierarchy PubSub -> PubSubConnection -> PubSubWriterGroup -> DataSetWriter brought to [Disabled, Disabled, Disabled, Disabled] configurator.Disable(pubSub); configurator.Disable(publisherConnection); configurator.Disable(writerGroup); configurator.Disable(datasetWriter); psState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(pubSub); conState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(publisherConnection); wgState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(writerGroup); dswState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(datasetWriter); Assert.That(psState == PubSubState.Disabled, Is.True); Assert.That(conState == PubSubState.Disabled, Is.True); Assert.That(wgState == PubSubState.Disabled, Is.True); Assert.That(dswState == PubSubState.Disabled, Is.True); }
/// <summary> /// Initializes a new instance of the <see cref="UaPubSubApplication"/> class. /// </summary> /// <param name="dataStore"> The current implementation of <see cref="IUaPubSubDataStore"/> used by this instance of pub sub application</param> private UaPubSubApplication(IUaPubSubDataStore dataStore = null) { m_uaPubSubConnections = new List <IUaPubSubConnection>(); if (dataStore != null) { m_dataStore = dataStore; } else { m_dataStore = new UaPubSubDataStore(); } m_dataCollector = new DataCollector(m_dataStore); m_uaPubSubConfigurator = new UaPubSubConfigurator(); m_uaPubSubConfigurator.ConnectionAdded += UaPubSubConfigurator_ConnectionAdded; m_uaPubSubConfigurator.ConnectionRemoved += UaPubSubConfigurator_ConnectionRemoved; m_uaPubSubConfigurator.PublishedDataSetAdded += UaPubSubConfigurator_PublishedDataSetAdded; m_uaPubSubConfigurator.PublishedDataSetRemoved += UaPubSubConfigurator_PublishedDataSetRemoved; }
public void ValidateDisabled_0ToPause_1_Publisher() { UaPubSubApplication uaPubSubApplication = UaPubSubApplication.Create(PublisherConfigurationFileName); UaPubSubConfigurator configurator = uaPubSubApplication.UaPubSubConfigurator; // The hierarchy PubSub -> PubSubConnection -> PubSubWriterGroup -> DataSetWriter brought to [Disabled, Disabled, Disabled, Disabled] PubSubConfigurationDataType pubSub = uaPubSubApplication.UaPubSubConfigurator.PubSubConfiguration; PubSubConnectionDataType publisherConnection = uaPubSubApplication.UaPubSubConfigurator.PubSubConfiguration.Connections[0]; WriterGroupDataType writerGroup = publisherConnection.WriterGroups[0]; DataSetWriterDataType datasetWriter = writerGroup.DataSetWriters[0]; configurator.Disable(pubSub); configurator.Disable(publisherConnection); configurator.Disable(writerGroup); configurator.Disable(datasetWriter); PubSubState psState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(pubSub); PubSubState conState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(publisherConnection); PubSubState wgState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(writerGroup); PubSubState dswState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(datasetWriter); Assert.That(psState == PubSubState.Disabled, Is.True); Assert.That(conState == PubSubState.Disabled, Is.True); Assert.That(wgState == PubSubState.Disabled, Is.True); Assert.That(dswState == PubSubState.Disabled, Is.True); // Bring connection to Enabled configurator.Enable(publisherConnection); psState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(pubSub); conState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(publisherConnection); wgState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(writerGroup); dswState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(datasetWriter); Assert.That(psState == PubSubState.Disabled, Is.True); Assert.That(conState == PubSubState.Paused, Is.True); Assert.That(wgState == PubSubState.Disabled, Is.True); Assert.That(dswState == PubSubState.Disabled, Is.True); // Bring writerGroup to Enabled configurator.Enable(writerGroup); psState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(pubSub); conState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(publisherConnection); wgState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(writerGroup); dswState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(datasetWriter); Assert.That(psState == PubSubState.Disabled, Is.True); Assert.That(conState == PubSubState.Paused, Is.True); Assert.That(wgState == PubSubState.Paused, Is.True); Assert.That(dswState == PubSubState.Disabled, Is.True); // Bring datasetWriter to Enabled configurator.Enable(datasetWriter); psState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(pubSub); conState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(publisherConnection); wgState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(writerGroup); dswState = uaPubSubApplication.UaPubSubConfigurator.FindStateForObject(datasetWriter); Assert.That(psState == PubSubState.Disabled, Is.True); Assert.That(conState == PubSubState.Paused, Is.True); Assert.That(wgState == PubSubState.Paused, Is.True); Assert.That(dswState == PubSubState.Paused, Is.True); }