private void TestTVInfoButtons(String command, String channel, Action <Mock <ITVInfoRemote> > setup, Action <Mock <ITVInfoRemote> > verify) { Dictionary <String, String> inputVals = new Dictionary <string, string> { { "Command", "remote" }, { "remoteButton", command }, { "channel", channel }, }; Mock <ITVInfoRemote> remote = SetupRemote <ITVInfoRemote>("Channel Remote"); setup(remote); SetupRemote <IVolumeController>("Volume Remote"); IOInterfaceReference ref2 = new IOInterfaceReference(); ref2.Properties.Single(r => r.Name.Equals("References")).Setter("Channel Remote"); ref2.Properties.Single(r => r.Name.Equals("Tag")).Setter("Channel"); IOInterfaceReference ref3 = new IOInterfaceReference(); ref3.Properties.Single(r => r.Name.Equals("References")).Setter("Volume Remote"); List <IOInterfaceReference> refs = new List <IOInterfaceReference> { ref2, ref3, }; CurrentConversation = new RemoteConversation(GetConfigurationManager(), refs); Assert.AreEqual("OK", RunSingleConversation <RemoteConversation>(inputVals)); verify(remote); }
public void PowerUpWithChannel() { Semaphore powerLock = new Semaphore(0, 1); Semaphore channelLock = new Semaphore(0, 1); Dictionary <String, String> inputVals = new Dictionary <string, string> { { "Command", "remote" }, { "remoteButton", "powerup" }, { "channel", "Channel" }, }; Mock <IPowerController> powerRemote = new Mock <IPowerController>(); Mock <ITVRemote> tvRemote = powerRemote.As <ITVRemote>(); powerRemote.Setup(s => s.IsValid).Returns(true); powerRemote.Setup(s => s.Name).Returns("Power Remote"); AddComponentToConfigurationManager(powerRemote.Object); powerRemote.Setup(s => s.TurnOn()).Callback(() => powerLock.Release()); tvRemote.Setup(s => s.TrySendChannel("Channel")).Returns(true).Callback(() => channelLock.Release()); SetupRemote <IDVRRemote>("Channel Remote"); SetupRemote <IVolumeController>("Volume Remote"); IOInterfaceReference ref1 = new IOInterfaceReference(); ref1.Properties.Single(r => r.Name.Equals("References")).Setter("Power Remote"); ref1.Properties.Single(r => r.Name.Equals("Tag")).Setter("Power"); IOInterfaceReference ref2 = new IOInterfaceReference(); ref2.Properties.Single(r => r.Name.Equals("References")).Setter("Channel Remote"); IOInterfaceReference ref3 = new IOInterfaceReference(); ref3.Properties.Single(r => r.Name.Equals("References")).Setter("Volume Remote"); List <IOInterfaceReference> refs = new List <IOInterfaceReference> { ref1, ref2, ref3, }; CurrentConversation = new RemoteConversation(GetConfigurationManager(), refs); Assert.AreEqual("OK", RunSingleConversation <RemoteConversation>(inputVals)); powerLock.WaitOne(); powerRemote.Verify(s => s.TurnOn(), Times.Exactly(1)); channelLock.WaitOne(); tvRemote.Verify(s => s.TrySendChannel("Channel"), Times.Exactly(1)); }