/// <summary> /// Update Test /// </summary> /// <param name="updatedTest">The Test to update</param> public void UpdateTest(Test updatedTest) { //check if the test to update is ok if (AllTests.All(test => test.Id != updatedTest.Id)) { throw new Exception("Test doesn't exist"); } if (AllTests.Any(test => test.Id == updatedTest.Id && (test.TesterId != updatedTest.TesterId || test.TraineeId != updatedTest.TraineeId || test.TestTime != updatedTest.TestTime))) { throw new Exception("Can't change this test details. please create new test"); } if (updatedTest.Criteria.Count <= Configuration.MinimumCriteria) { throw new Exception("Not enough criterion"); } if (updatedTest.ActualTestTime == DateTime.MinValue) { throw new Exception("Test date not updated"); } if ((updatedTest.ActualTestTime - updatedTest.TestTime).Days < 0) { throw new Exception("Actual date can't be before test date time"); } //update passed status updatedTest.UpdatePassedTest(); //update test _dalImp.UpdateTest(updatedTest); }
/// <summary> /// Remove a Test /// </summary> /// <param name="testToDelete">The Test to remove</param> public void RemoveTest(Test testToDelete) { if (AllTests.All(test => test.Id != testToDelete.Id)) { throw new Exception("Test doesn't exist"); } _dalImp.RemoveTest(testToDelete); }