-
Notifications
You must be signed in to change notification settings - Fork 147
/
Alarm.cs
35 lines (27 loc) · 768 Bytes
/
Alarm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using Moq;
namespace TDDMicroExercises.TirePressureMonitoringSystem
{
public class Alarm
{
private const double LowPressureThreshold = 17;
private const double HighPressureThreshold = 21;
readonly ISensor _sensor = new Sensor();
bool _alarmOn = false;
public Alarm(ISensor sensor)
{
this._sensor = sensor;
}
public void Check()
{
double psiPressureValue = _sensor.PopNextPressurePsiValue();
if (psiPressureValue < LowPressureThreshold || HighPressureThreshold < psiPressureValue)
{
_alarmOn = true;
}
}
public bool AlarmOn
{
get { return _alarmOn; }
}
}
}