Ejemplo n.º 1
0
        public void ZWaveSwitchNameSet()
        {
            ZWaveSwitch        zWaveSwitch = new ZWaveSwitch();
            PersistentProperty prop        = zWaveSwitch.Properties.SingleOrDefault(s => s.Name.Equals("Name"));

            Assert.IsNotNull(prop);

            prop.Setter("Test Name");

            Assert.AreEqual("Test Name", zWaveSwitch.Name);
        }
Ejemplo n.º 2
0
        public void ZWaveNodeProperties()
        {
            Mock <IZWaveController> controller = new Mock <IZWaveController>(MockBehavior.Strict);

            controller.Setup(s => s.IsInitialized).Returns(false);
            ZWaveNode.SetController(controller.Object);
            Mock <IInternalConfigurationManager> configManager = new Mock <IInternalConfigurationManager>();
            MockZWaveNode node = new MockZWaveNode();

            Assert.AreEqual(1, node.Properties.Count());
            PersistentProperty prop = node.Properties.Single();

            Assert.AreEqual("NodeId", prop.Name);
            prop.Setter("100");
            Assert.AreEqual(100, node.NodeId);
            Assert.AreEqual("100", prop.Getter());
        }
Ejemplo n.º 3
0
        private IParseable ParseComponent(XmlNode componentNode, ParseableElementType typeToLookFor)
        {
            Lazy <IParseable, IParseableMetadata> parseable;

            try
            {
                parseable = _compositionContainer.GetExport <IParseable, IParseableMetadata>(componentNode.Name);
            }
            catch (ImportCardinalityMismatchException)
            {
                throw new InvalidOperationException(String.Format("Could not find any components with the name {0}.", componentNode.Name));
            }
            if (parseable.Metadata.Type != typeToLookFor)
            {
                switch (parseable.Metadata.Type)
                {
                case ParseableElementType.App:
                    throw new InvalidOperationException(String.Format("There was an error while processing a declaration for the app {0}. Ensure that {0} is declared at the top level of the Apps tag in the configuration file.", componentNode.Name));

                case ParseableElementType.IOInterface:
                    throw new InvalidOperationException(String.Format("There was an error while processing a declaration for the IO interface {0}. Ensure that {0} is declared at the top level of the IO Interfaces tag in the configuration file.", componentNode.Name));

                case ParseableElementType.Support:
                    throw new InvalidOperationException(String.Format("There was an error while processing a declaration for the support component {0}. Ensure that {0} is declared underneath an app or an IO interface.", componentNode.Name));

                default:
                    throw new NotImplementedException(String.Format("The component type {0} is not supported!", typeToLookFor.ToString()));
                }
            }
            IParseable component = parseable.Value;

            foreach (XmlAttribute attr in componentNode.Attributes)
            {
                PersistentProperty prop = component.Properties.Single(p => p.Name.Equals(attr.Name));
                prop.Setter(attr.Value);
            }
            foreach (IParseable childComponent in ParseChildrenComponents(componentNode, ParseableElementType.Support))
            {
                component.AddChild(childComponent);
            }
            return(component);
        }