Ejemplo n.º 1
0
        public void ZWaveNodesAddValueIdDuplicate()
        {
            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(0, node.MockValueIds.Count());

            uint homeId = 0;
            byte nodeId = 1;

            ZWValueID.ValueGenre genre = ZWValueID.ValueGenre.Basic;
            byte commandClass          = 2;
            byte instance   = 3;
            byte valueIndex = 4;

            ZWValueID.ValueType type = ZWValueID.ValueType.Bool;
            byte      pollIntensity  = 5;
            ZWValueID id             = new ZWValueID(homeId, nodeId, genre, commandClass, instance, valueIndex, type, pollIntensity);

            node.AddValueId(id);
            node.AddValueId(id);

            Assert.AreEqual(1, node.MockValueIds.Count());
            Assert.AreSame(id, node.MockValueIds.Single());
        }
Ejemplo n.º 2
0
        public void ZWaveNodeSetValueByte()
        {
            uint homeId = 0;
            byte nodeId = 1;

            ZWValueID.ValueGenre genre = ZWValueID.ValueGenre.Basic;
            byte commandClass          = 2;
            byte instance   = 3;
            byte valueIndex = 4;

            ZWValueID.ValueType type = ZWValueID.ValueType.Byte;
            byte      pollIntensity  = 5;
            ZWValueID id             = new ZWValueID(homeId, nodeId, genre, commandClass, instance, valueIndex, type, pollIntensity);

            Mock <IZWaveController> controller = new Mock <IZWaveController>(MockBehavior.Strict);

            controller.Setup(s => s.SetValue(id, 0x25));
            ZWaveNode.SetController(controller.Object);
            Mock <IInternalConfigurationManager> configManager = new Mock <IInternalConfigurationManager>();
            MockZWaveNode node = new MockZWaveNode();

            node.AddValueId(id);

            node.MockSetValue(valueIndex, commandClass, 0x25);

            controller.Verify(s => s.SetValue(id, 0x25), Times.Exactly(1));
        }
Ejemplo n.º 3
0
        public void ZWaveControllerValueRemoved()
        {
            ZWaveController controller = SetupInitializedController();

            _configManager.Raise(s => s.InitializationComplete += null, EventArgs.Empty);

            VerifyInitializedController(controller);

            ZWValueID     valueId = new ZWValueID(0, 1, ZWValueID.ValueGenre.Basic, 2, 3, 4, ZWValueID.ValueType.Bool, 5);
            MockZWaveNode node    = new MockZWaveNode();

            node.NodeId = 1;
            node.AddValueId(valueId);
            RaiseNotification(ZWNotification.Type.ValueRemoved, valueId, node);

            Assert.IsFalse(controller.IsInitialized);
            Assert.AreEqual(0, node.MockValueIds.Count());
            _configManager.Verify(s => s.FindAllComponentsOfTypeEvenInvalid <ZWaveNode>(), Times.Exactly(1));
        }