private void initiateTestMaterial() { symptomRegistry = SymptomRegistry.getRegistryInstance(); diseaseRegistry = DiseaseRegistry.getRegistryInstance(); testHealthyPatient = new Patient(testHealthyPatientName); testSymptoms = new ArrayList<Symptom>(); testSymptoms.add((Symptom) symptomRegistry.getElementByName("Hairloss")); testSymptoms.add((Symptom) symptomRegistry.getElementByName("Fever")); testSickPatient = new Patient(testSickPatientName, testSymptoms); Disease disease = (Disease) diseaseRegistry.getElementByName("Asthma"); testInfectedPatient = new Patient(testInfectedPatientName, disease); }
@Test public void testAddSymptom() { initiateTestMaterial(); assertTrue(testHealthyPatient.getHealth() == 100); Symptom symptom = (Symptom) symptomRegistry.getElementByName("Hairloss"); testHealthyPatient.addSymptom(symptom); assertTrue(testHealthyPatient.getHealth() == 50); }
@Test public void testInfect() { initiateTestMaterial(); assertTrue(testHealthyPatient.getHealth() == 100); Disease disease = (Disease) diseaseRegistry.getElementByName("Asthma"); testHealthyPatient.infect(disease); assertFalse(testHealthyPatient.getHealth() == 100); }
@Test public void testHeal() { initiateTestMaterial(); testHealthyPatient.heal(100); assertTrue(testHealthyPatient.getHealth() == 100); assertTrue(testSickPatient.getHealth() == 25); testSickPatient.heal(50); assertTrue(testSickPatient.getHealth() == 75); testSickPatient.heal(50); assertTrue(testSickPatient.getHealth() == 100); // test all symptoms are removed assertEquals(new ArrayList<Symptom>(), testSickPatient.getSymptoms()); testInfectedPatient.heal(0); assertFalse(testInfectedPatient.getHealth() == 100); // test all symptoms are still present testSymptoms = ((Disease) diseaseRegistry.getElementByName("Asthma")).getSymptoms(); assertEquals(testSymptoms, testInfectedPatient.getSymptoms()); }