public void Test_AlertTrigger_DataFromAboveToBelow_WithinHalf() { var thresholdRepository = new Mock <IThresholdRepository>(); thresholdRepository.Setup(m => m.GetAll()).Returns(new List <IThresholdData>()); ThermometerModel thermoModel = new ThermometerModel(); ThresholdModel model = new ThresholdModel(thermoModel, thresholdRepository.Object); Assert.IsTrue(model.TriggerThresholdAlert(0.0, -0.5)); // Now, alert has been shown once. So, set thermometer model accordingly to be triggered. thermoModel.Triggered = true; Assert.IsFalse(model.TriggerThresholdAlert(-0.5, 0.0)); // doing again will not trigger alert: Assert.IsFalse(model.TriggerThresholdAlert(0.0, 0.5)); }
public void Test_AlertTrigger_DataFromSameToSameOnTrigger() { var thresholdRepository = new Mock <IThresholdRepository>(); thresholdRepository.Setup(m => m.GetAll()).Returns(new List <IThresholdData>()); ThresholdModel model = new ThresholdModel(new ThermometerModel(), thresholdRepository.Object); Assert.IsFalse(model.TriggerThresholdAlert(0.0, 0.0)); }
public void Test_AlertTrigger_DataFromBelowToAboveTrigger() { var thresholdRepository = new Mock <IThresholdRepository>(); thresholdRepository.Setup(m => m.GetAll()).Returns(new List <IThresholdData>()); ThresholdModel model = new ThresholdModel(new ThermometerModel(), thresholdRepository.Object); Assert.IsTrue(model.TriggerThresholdAlert(-10.0, 10.0)); }
public void Test_AlertTrigger_SettingFromAbove_DataFromAboveToBelow() { var thresholdRepository = new Mock <IThresholdRepository>(); thresholdRepository.Setup(m => m.GetAll()).Returns(new List <IThresholdData>()); ThresholdModel model = new ThresholdModel(new ThermometerModel(), thresholdRepository.Object); IThresholdData setting = model.ThresholdSettings[0]; setting.Direction = ThresholdGoDirection.Above; Assert.IsTrue(model.TriggerThresholdAlert(1.0, -1.0)); }