Example #1
0
        static int Main(string[] args)
        {
            VitalAlert alertbysound = new VitalAlert(new SoundAlert().SendAlert);
            VitalAlert alertbysms   = new VitalAlert(new SMSAlert().SendAlert);

            Checker Vcheck = new Checker();

            int[] values = new int[3] {
                100, 95, 60
            };
            int[] values1 = new int[3] {
                40, 91, 92
            };
            ExpectTrue(Vcheck.vitalsAreOk(values, alertbysound));
            ExpectFalse(Vcheck.vitalsAreOk(values1, alertbysms));

            Checker Vcheck1 = new Checker();

            Vcheck1.VitalList.Add(new Vital("sugar", 70, 99));
            int[] values2 = new int[4] {
                40, 91, 92, 100
            };
            ExpectFalse(Vcheck1.vitalsAreOk(values2, alertbysms));

            int[] values3 = new int[4] {
                75, 95, 77, 80
            };
            ExpectTrue(Vcheck1.vitalsAreOk(values3, alertbysound));
            return(0);
        }
 public bool vitalsAreOk(int[] VitalValues,
                         VitalAlert typeOfAlert)
 {
     bool[] a = new bool[2] {
         true, true
     };
     for (int i = 0; i < VitalList.Count; i++)
     {
         a[0] = VitalList[i].isVitalOk(VitalValues[i], typeOfAlert);
         if (a[0] == false)
         {
             a[1] = false;
         }
     }
     return(a[1]);
 }
Example #3
0
 public bool isVitalOk(int vitalValue, VitalAlert alertType)
 {
     if (vitalValue < lowerLimit)
     {
         string message = "is LOW from the required range";
         alertType.Invoke(vitalName, message);
         return(false);
     }
     else if (vitalValue > upperLimit)
     {
         string message = "is HIGH from the required range";
         alertType.Invoke(vitalName, message);
         return(false);
     }
     else
     {
         Console.WriteLine("Vital: {0} is ok", vitalName);
         return(true);
     }
 }