public IEnumerator TestEvaluateLevel_InputIsNeg1_OutputNOTKNOWN() { yield return(null); Assert.AreNotEqual(AbilityLevel.NOT_KNOWN, AbilityManagement.EvaluateLevel(0)); Assert.AreEqual(AbilityLevel.NOT_KNOWN, AbilityManagement.EvaluateLevel(-1)); }
public IEnumerator WHEN_GetSubScoreSeqFunctionCalled_THEN_SubScoreSeqReturned() { // Add example SubScoreStorage objects to subScoreSeq AbilityManagement.subScoreSeq.Add(inhibition_ctf); // Call tested function List <SubscoreStorage> gottenSubScoreSeq = AbilityManagement.GetSubScoreSeq(); yield return(null); Assert.AreEqual(AbilityManagement.subScoreSeq, gottenSubScoreSeq); }
public IEnumerator TestEvaluateLevelFunction_InputIsOver90_OutputEXCELLENT() { yield return(null); // Test the input has to be strict greater than 90, to get EXCELLENT Assert.AreEqual(AbilityLevel.EXCELLENT, AbilityManagement.EvaluateLevel(100)); Assert.AreEqual(AbilityLevel.EXCELLENT, AbilityManagement.EvaluateLevel(95)); // Edge case tests for 90: pick 89, 90, 91 as input Assert.AreEqual(AbilityLevel.EXCELLENT, AbilityManagement.EvaluateLevel(91)); Assert.AreNotEqual(AbilityLevel.EXCELLENT, AbilityManagement.EvaluateLevel(90)); Assert.AreNotEqual(AbilityLevel.EXCELLENT, AbilityManagement.EvaluateLevel(89)); }
// Start is called before the first frame update void Start() { // Get the name of the current active scene currentSceneName = SceneManager.GetActiveScene().name; // Call the function to calculate the overall cognitive or motor level overallScoreSeq = AbilityManagement.GetOverallScoreSeq(); // Link TextMeshProUGUI field to UI Component scoreValue = GameObject.Find("ScoreValue").GetComponent <TMPro.TextMeshProUGUI>(); levelValue = GameObject.Find("LevelValue").GetComponent <TMPro.TextMeshProUGUI>(); // Fill in score and level in UI UpdateScoreAndLevelText(); }
public IEnumerator TestEvaluateLevel_InputIsBetween0And25_OutputVERYPOOR() { yield return(null); // Test the input has to be greater than or equal to 0 and less than or equal to 25, to get VERY POOR // Edge case tests for 25: pick 26, 25, 24 as input Assert.AreNotEqual(AbilityLevel.VERY_POOR, AbilityManagement.EvaluateLevel(26)); Assert.AreEqual(AbilityLevel.VERY_POOR, AbilityManagement.EvaluateLevel(25)); Assert.AreEqual(AbilityLevel.VERY_POOR, AbilityManagement.EvaluateLevel(24)); Assert.AreEqual(AbilityLevel.VERY_POOR, AbilityManagement.EvaluateLevel(12)); // Edge case tests for 0: 1, 0, -1 as input Assert.AreEqual(AbilityLevel.VERY_POOR, AbilityManagement.EvaluateLevel(1)); Assert.AreEqual(AbilityLevel.VERY_POOR, AbilityManagement.EvaluateLevel(0)); Assert.AreNotEqual(AbilityLevel.VERY_POOR, AbilityManagement.EvaluateLevel(-1)); }
public IEnumerator TestEvaluateLevel_InputIsBetween25And50_OutputPOOR() { yield return(null); // Test the input has to be strict greater than 25 and less than or equal to 50, to get POOR // Edge case tests for 50: pick 51, 50, 49 as input Assert.AreNotEqual(AbilityLevel.POOR, AbilityManagement.EvaluateLevel(51)); Assert.AreEqual(AbilityLevel.POOR, AbilityManagement.EvaluateLevel(50)); Assert.AreEqual(AbilityLevel.POOR, AbilityManagement.EvaluateLevel(49)); Assert.AreEqual(AbilityLevel.POOR, AbilityManagement.EvaluateLevel(42)); // Edge case tests for 25: pick 26, 25, 24 as input Assert.AreEqual(AbilityLevel.POOR, AbilityManagement.EvaluateLevel(26)); Assert.AreNotEqual(AbilityLevel.POOR, AbilityManagement.EvaluateLevel(25)); Assert.AreNotEqual(AbilityLevel.POOR, AbilityManagement.EvaluateLevel(24)); }
public IEnumerator TestEvaluateLevel_InputIsBetween50And75_OutputOK() { yield return(null); // Test the input has to be strict greater than 50 and less than or equal to 75, to get OK // Edge case tests for 75: pick 76, 75, 74 as input Assert.AreNotEqual(AbilityLevel.OK, AbilityManagement.EvaluateLevel(76)); Assert.AreEqual(AbilityLevel.OK, AbilityManagement.EvaluateLevel(75)); Assert.AreEqual(AbilityLevel.OK, AbilityManagement.EvaluateLevel(74)); Assert.AreEqual(AbilityLevel.OK, AbilityManagement.EvaluateLevel(55)); // Edge case tests for 50: pick 51, 50, 49 as input Assert.AreEqual(AbilityLevel.OK, AbilityManagement.EvaluateLevel(51)); Assert.AreNotEqual(AbilityLevel.OK, AbilityManagement.EvaluateLevel(50)); Assert.AreNotEqual(AbilityLevel.OK, AbilityManagement.EvaluateLevel(49)); }
public IEnumerator TestEvaluateLevel_InputIsBetween75And90_OutputGOOD() { yield return(null); // Test the input has to be strict greater than 75 and less than or equal to 90, to get GOOD // Edge case tests for 90: pick 89, 90, 91 as input Assert.AreNotEqual(AbilityLevel.GOOD, AbilityManagement.EvaluateLevel(91)); Assert.AreEqual(AbilityLevel.GOOD, AbilityManagement.EvaluateLevel(90)); Assert.AreEqual(AbilityLevel.GOOD, AbilityManagement.EvaluateLevel(89)); Assert.AreEqual(AbilityLevel.GOOD, AbilityManagement.EvaluateLevel(80)); // Edge case tests for 75: pick 76, 75, 74 as input Assert.AreEqual(AbilityLevel.GOOD, AbilityManagement.EvaluateLevel(76)); Assert.AreNotEqual(AbilityLevel.GOOD, AbilityManagement.EvaluateLevel(75)); Assert.AreNotEqual(AbilityLevel.GOOD, AbilityManagement.EvaluateLevel(74)); }
public IEnumerator WHEN_CalculateOverallScoreForOneAbilityFunctionCalled_THEN_AnOverallScoreDerived() { // Add example SubScoreStorage objects to subScoreSeq AbilityManagement.subScoreSeq.Add(inhibition_ctf); AbilityManagement.subScoreSeq.Add(inhibition_balloons); AbilityManagement.subScoreSeq.Add(pointing_balloons); int expectedOverallScore_Inhition = (int)Math.Ceiling((double)(89 * 2 + 65 * 1) / (2 + 1)); int expectedOverallScore_Pointing = (int)Math.Ceiling((double)(71 * 2) / (2)); int actualOverallScore_Inhition = AbilityManagement.CalculateOverallScoreForOneAbility(AbilityName.INHIBITION); int actualOverallScore_Pointing = AbilityManagement.CalculateOverallScoreForOneAbility(AbilityName.POINTING); yield return(null); Assert.IsTrue(Mathf.Abs(expectedOverallScore_Inhition - actualOverallScore_Inhition) <= tolerance); Assert.IsTrue(Mathf.Abs(expectedOverallScore_Pointing - actualOverallScore_Pointing) <= tolerance); }
/// <summary> /// The Update function /// calls the functions to get the calculated scores to be displayed on /// the screen. /// </summary> private void Update() { // If the Ability.Measure() function is called in BatterySessionManagement // and the Text is not filled yet if (!isFilled && BatterySessionManagement.IfMeasureCalled()) { // Call the function to calculate and update subscore values subScoreSeq = AbilityManagement.GetSubScoreSeq(); // Call the function to calculate the overall cognitive or motor level overallScoreSeq = AbilityManagement.GetOverallScoreSeq(); // Update the text shown on the screen to show the cognitive and motor levels GetScoreAndLevel(); // Toggle the boolean to indicate that the text values for the levels have been filled isFilled = true; } }
public IEnumerator WHEN_GetOverallScoreSeqFunctionCalled_THEN_OverallScoreSeqReturned() { // Create example OverallScoreStorage object: OverallScoreStorage overall_inhibition = new OverallScoreStorage { AbilityName = AbilityName.INHIBITION, Score = 100, Level = AbilityLevel.EXCELLENT }; AbilityManagement.overallScoreSeq.Add(overall_inhibition); // Call tested function List <OverallScoreStorage> gottenOverallScoreSeq = AbilityManagement.GetOverallScoreSeq(); yield return(null); Assert.AreEqual(AbilityManagement.overallScoreSeq, gottenOverallScoreSeq); }
public IEnumerator WHEN_CalculateOverallScoreSeqFunctionCalled_THEN_OverallScoreSeqUpdated() { // Add example SubScoreStorage objects to subScoreSeq AbilityManagement.subScoreSeq.Add(inhibition_ctf); AbilityManagement.subScoreSeq.Add(inhibition_balloons); AbilityManagement.subScoreSeq.Add(pointing_balloons); // Call tested function AbilityManagement.CalculateOverallScoreSeq(); // Expected overall score and level int expectedOverallScore_Inhition = (int)Math.Ceiling((double)(89 * 2 + 65 * 1) / (2 + 1)); int expectedOverallScore_Pointing = (int)Math.Ceiling((double)(71 * 2) / (2)); AbilityLevel expectedOverallLevel_Inhition = AbilityManagement.EvaluateLevel(expectedOverallScore_Inhition); AbilityLevel expectedOverallLevel_Pointing = AbilityManagement.EvaluateLevel(expectedOverallScore_Pointing); List <OverallScoreStorage> actualOverallScoreSeq = AbilityManagement.overallScoreSeq; yield return(null); // Test the actualOverallScoreSeq is as expected foreach (OverallScoreStorage overallScore in actualOverallScoreSeq) { if (overallScore.AbilityName == AbilityName.INHIBITION) { Assert.AreEqual(expectedOverallScore_Inhition, overallScore.Score); Assert.AreEqual(expectedOverallLevel_Inhition, overallScore.Level); } else if (overallScore.AbilityName == AbilityName.POINTING) { Assert.AreEqual(expectedOverallScore_Pointing, overallScore.Score); Assert.AreEqual(expectedOverallLevel_Pointing, overallScore.Level); } else { Assert.AreEqual(-1, overallScore.Score); Assert.AreEqual(AbilityLevel.NOT_KNOWN, overallScore.Level); } } }
// Helper Function /// <summary> /// Iterate through overallScoreSeq and fill the expected score variables /// with the correct score and level values. /// </summary> private void GetScoreAndLevel() { // Get the expected score values overallScoreSeq = AbilityManagement.GetOverallScoreSeq(); foreach (OverallScoreStorage overallScore in overallScoreSeq) { if (overallScore.AbilityName == AbilityName.POINTING) { expectedPointingScore = overallScore.Score.ToString(); expectedPointingLevel = overallScore.Level.ToString(); } if (overallScore.AbilityName == AbilityName.INHIBITION) { expectedInhibitionScore = overallScore.Score.ToString(); expectedInhibitionLevel = overallScore.Level.ToString(); } if (overallScore.AbilityName == AbilityName.SELECTIVE_VISUAL) { expectedSelectiveVisualScore = overallScore.Score.ToString(); expectedSelectiveVisualLevel = overallScore.Level.ToString(); } if (overallScore.AbilityName == AbilityName.VISUOSPATIAL_SKETCHPAD) { expectedVisuospatialSketchpadScore = overallScore.Score.ToString(); expectedVisuospatialSketchpadLevel = overallScore.Level.ToString(); } if (overallScore.AbilityName == AbilityName.TIME_TO_CONTACT) { expectedTimeToContactScore = overallScore.Score.ToString(); expectedTimeToContactLevel = overallScore.Level.ToString(); } if (overallScore.AbilityName == AbilityName.OBJECT_RECOGNITION) { expectedObjectRecognitionScore = overallScore.Score.ToString(); expectedObjectRecognitionLevel = overallScore.Level.ToString(); } } }
public IEnumerator WHEN_MeasureFunctionCalled_THEN_ScoreSeqUpdated() { // Make all games labelled as played AbilityManagement.notYetCatchTheBall = false; AbilityManagement.notYetJudgeTheBall = false; AbilityManagement.notYetSaveOneBall = false; AbilityManagement.notYetPlayBalloons = false; AbilityManagement.notYetPlayCTF = false; AbilityManagement.notYetPlayImageHit = false; AbilityManagement.notYetPlaySquares = false; // Call tested function AbilityManagement.Measure(); yield return(null); // subScoreSeq contains 0 to 13 records Assert.IsTrue(0 <= AbilityManagement.subScoreSeq.Count && AbilityManagement.subScoreSeq.Count <= 13); // overallScoreSeq contains all 6 ability records Assert.AreEqual(6, AbilityManagement.overallScoreSeq.Count); }
public IEnumerator WHEN_EvaluateLevelFunctionCalled_THEN_LevelDerived() { Assert.AreEqual(typeof(AbilityLevel), AbilityManagement.EvaluateLevel(10).GetType()); yield return(null); }