private void HandleEvent(BloodSugarEvent current) { _ledController.Alert(current.Direction); var color = ConvertToRGBColor(current); _ledController.SetColor(color); }
public void ShouldGetRangeRight(decimal input, BloodSugarState expected) { // arrange var evt = new BloodSugarEvent { BloodSugarLevel = input }; // act var result = SugarStateFinder.Get(evt); // assert result.Should().Be(expected); }
public static BloodSugarState Get(BloodSugarEvent current) { if (current.BloodSugarLevel <= VeryLow) { return(BloodSugarState.VeryLow); } if (current.BloodSugarLevel <= Low) { return(BloodSugarState.Low); } // above low, below high. yay if (current.BloodSugarLevel < High) { return(BloodSugarState.InRange); } if (current.BloodSugarLevel <= VeryHigh) { return(BloodSugarState.High); } return(BloodSugarState.VeryHigh); }
public void Init() { try { _bloodSugarProvider.Init(); _ledController.Init(); } #pragma warning disable CS0168 // Variable is declared but never used #pragma warning disable IDE0059 // Value assigned to symbol is never used catch (Exception ex) { Debugger.Break(); throw; // if we can't start we shouldn't. This is pretty much the only place we want to inform the user } #pragma warning restore IDE0059 // Value assigned to symbol is never used #pragma warning restore CS0168 // Variable is declared but never used // set an initial result _lastEvent = new BloodSugarEvent { Timestamp = DateTime.Now.AddYears(-1) }; }
private Color ConvertToRGBColor(BloodSugarEvent current) { var state = SugarStateFinder.Get(current); return(LedScoutColors.StateColors[state]); }