static void Main(string[] args) { VitalsCollection v_collection = new VitalsCollection(3); Vitals one_vital = new Vitals(); one_vital.setName("Test1"); one_vital.setValue(30); one_vital.setLower(25); one_vital.setUpper(50); v_collection.Initialize(); v_collection.UpdateVitals(); VitalsMonitor v_monitor = new VitalsMonitor(); AlertInSMS alertSMS = new AlertInSMS(); AlertInIntercom alertIntercom = new AlertInIntercom(); //Testing VitalsAreNormal() Checker.ExpectTrue(v_monitor.VitalsAreNormal(alertSMS, v_collection)); v_collection.UpdateVitals(); Checker.ExpectFalse(v_monitor.VitalsAreNormal(alertIntercom, v_collection)); v_collection.UpdateVitals(); Checker.ExpectFalse(v_monitor.VitalsAreNormal(alertIntercom, v_collection)); //Testing VitalIsNormal() Checker.ExpectTrue(v_monitor.VitalIsNormal(one_vital)); one_vital.setValue(20); Checker.ExpectFalse(v_monitor.VitalIsNormal(one_vital)); one_vital.setValue(56); Checker.ExpectFalse(v_monitor.VitalIsNormal(one_vital)); Console.WriteLine("All ok"); }
internal bool VitalsAreNormal(IAlert alertNow, VitalsCollection v_collection) { int loopCounter = 0; bool status = true; for (loopCounter = 0; loopCounter < v_collection.allVitals.Length; loopCounter++) { bool new_status = VitalIsNormal(v_collection.allVitals[loopCounter]); status = status && new_status; } alertRequired(status, alertNow, message); this.message = ""; return(status); }