public void CreatindSensorTest() { var configuration = new XmlDataProviderConfigurationImpl(); var listener = new ConfigurationListener(); configuration.SubscribeConfigurationListener(listener); var sensor = new OpcSensorInfoImpl { Id = 1, Name = "TestName" }; configuration.CreateOpcSensorInfo(sensor); Assert.AreEqual(configuration.GetOpcSensorInfoCount(), 1); Assert.AreSame(sensor, configuration.ReadOpcSensorInfoByName(sensor.Name)); Assert.AreSame(sensor, listener.CreatedSensor); configuration.UnsubscribeConfigurationListener(listener); var sensor2 = new OpcSensorInfoImpl { Id = 1, Name = "sensor2" }; Assert.Throws<ArgumentException>(() => configuration.CreateOpcSensorInfo(sensor2)); sensor2.Id = 2; configuration.CreateOpcSensorInfo(sensor2); Assert.AreNotSame(listener.CreatedSensor, configuration.ReadOpcSensorInfoById(2)); }
void Configurable.ProvideConfiguration(ConfigurationListener listener) { listener.OnEnableConfigure(name, this, gameObject.activeSelf); }