private void HardwareManager_BooleanInputChanged(object sender, BooleanInputChangeEventArgs e) { this.logger.LogDebug($"Input received {e.Pin} = {e.State}"); lock (this.coverControl) { if (e.Pin == PinName.CoverButtonUp && e.State == true) { this.coverControl.OpenCover(true); } if (e.Pin == PinName.CoverButtonDown && e.State == true) { this.coverControl.CloseCover(true); } } }
public void ReadInput() { var driver = new Mock <IHardwareDriver>(); BooleanInputChangeEventArgs eventRaised = null; var manager = CreateHardwareManagerWithFullConfiguration(driver.Object); manager.OpenConfiguration(); manager.BooleanInputChanged += (s, e) => { eventRaised = e; }; driver.Raise(d => d.InputBooleanChanged += null, new HardwarePinChangeEventArgs(1, true)); manager.CloseConfiguration(); Assert.IsNotNull(eventRaised); Assert.AreEqual(PinName.Pump, eventRaised.Pin); Assert.IsTrue(eventRaised.State); }