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));
        }
        private void LoadOpcSensor(XmlNode aNode)
        {
            var sensorInfo = new OpcSensorInfoImpl {
                Id = opcSensorInfos.Count,
                DataBlocksTags = new string[controlBlock.DataBlocksCount]
            };
            var items = aNode.ChildNodes;
            for (var i = 0; i < items.Count; ++i) {
                var item = items[i];
                switch (item.Name) {
                    case SENSOR_NAME:
                        sensorInfo.Name = item.InnerText;
                        break;
                    case SENSOR_ENABLE:
                        sensorInfo.EnableTag = item.InnerText;
                        break;
                    case SENSOR_CURRENT_VALUE:
                        sensorInfo.CurrentValueTag = item.InnerText;
                        break;
                    case DATA_BLOCKS:
                        var dataBlocks = item.ChildNodes;
                        for (var j = 0; j < controlBlock.DataBlocksCount; ++j) {
                            if (dataBlocks[j].Name.Equals(DATA_BLOCK)) {
                                sensorInfo.DataBlocksTags[j] = dataBlocks[j].InnerText;
                            }
                        }
                        break;
                }
            }

            if (opcSensorInfos.Any(s => s.Name.Equals(sensorInfo.Name))) {
                throw new ArgumentException("Датчик с таким именем уже существует: " + sensorInfo.Name);
            }

            opcSensorInfos.Add(sensorInfo);
        }