public void ZWaveControllerTryStartPairingAlreadyPairing() { 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); RaiseNotificationNoNodes(ZWNotification.Type.DriverReady, valueId); _zWaveManager.Setup(s => s.BeginControllerCommand(2, ZWControllerCommand.AddDevice, false, 0)).Returns(true); Mock <IZWavePairingMonitor> monitor = new Mock <IZWavePairingMonitor>(MockBehavior.Strict); monitor.Setup(m => m.PairingStarted()); MockZWaveNode node = new MockZWaveNode(); Assert.IsTrue(controller.TryStartPairing(node, monitor.Object)); MockZWaveNode node2 = new MockZWaveNode(); Assert.IsFalse(controller.TryStartPairing(node2, monitor.Object)); Assert.IsFalse(controller.IsInitialized); _configManager.Verify(s => s.FindAllComponentsOfTypeEvenInvalid <ZWaveNode>(), Times.Exactly(1)); _zWaveManager.Verify(s => s.BeginControllerCommand(2, ZWControllerCommand.AddDevice, false, 0), Times.Exactly(1)); monitor.Verify(m => m.PairingStarted(), Times.Exactly(1)); }
public void ZWaveControllerNodeAddedPairing() { ZWaveController controller = SetupInitializedController(); _configManager.Raise(s => s.InitializationComplete += null, EventArgs.Empty); VerifyInitializedController(controller); MockZWaveNode pairingNode = new MockZWaveNode(); Assert.AreEqual(0, pairingNode.NodeId); _zWaveManager.Setup(s => s.BeginControllerCommand(0, ZWControllerCommand.AddDevice, false, 0)).Returns(true); Mock <IZWavePairingMonitor> monitor = new Mock <IZWavePairingMonitor>(MockBehavior.Strict); monitor.Setup(m => m.PairingStarted()); Assert.IsTrue(controller.TryStartPairing(pairingNode, monitor.Object)); _configManager.Setup(s => s.FindAllComponentsOfTypeEvenInvalid <ZWaveNode>()).Returns(new List <ZWaveNode>()); _zWaveManager.Raise(s => s.OnNotification += null, new NotificationEventArgs(_zWaveManager.Object, (byte)5, ZWNotification.Type.NodeAdded, null, 2)); Assert.IsTrue(pairingNode.IsConnected); Assert.AreEqual(5, pairingNode.NodeId); _configManager.Verify(s => s.FindAllComponentsOfTypeEvenInvalid <ZWaveNode>(), Times.Exactly(1)); monitor.Verify(m => m.PairingStarted(), Times.Exactly(1)); }