private static void TestGoodStudentDetentionScenario(RuleCalculationModeType calculationType) { calculateRequest = kernel.Get <ICalculateDetentionRequest>(); calculateRequest.RequestingFaculty = facultyService.Get().InternalList.First(); calculateRequest.RuleCalculationMode = kernel.Get <IRuleCalculationMode>(); calculateRequest.RuleCalculationMode.CalculationType = calculationType; calculateRequest.Student = studentService.Get().InternalList.Where(x => x.RollNumber == "002").First(); // Has 1 offence (1.5 hours detention) registered calculateRequest.DetentionStartTime = DateTime.Now; var response = detentionCalculatorService.CalculateDetention(calculateRequest); if (response == null || response.DetentionPeriodInHours != 0.9 * 1.5) { throw new Exception("TestGoodStudentDetentionScenario failed"); } else { Console.WriteLine("TestGoodStudentDetentionScenario Success."); } }
private static void TestNoDetentionScenario(RuleCalculationModeType calculationType) { calculateRequest = kernel.Get <ICalculateDetentionRequest>(); calculateRequest.RequestingFaculty = facultyService.Get().InternalList.First(); calculateRequest.RuleCalculationMode = kernel.Get <IRuleCalculationMode>(); calculateRequest.RuleCalculationMode.CalculationType = calculationType; calculateRequest.Student = studentService.Get().InternalList.Where(x => x.RollNumber == "001").First(); // Has no offence registered calculateRequest.DetentionStartTime = DateTime.Now; var response = detentionCalculatorService.CalculateDetention(calculateRequest); if (response != null) { throw new Exception("TestNoDetentionScenario failed. Student should not get detention since has no offence registered against him/her."); } else { Console.WriteLine("TestNoDetentionScenario Success."); } }