public void Five_Results_No_Ties_Correct_Order() { var results = CreateResultSet(5, 3); var score1_1 = new Score { CourseNumber = 1, CourseScore = 1 }; results[0].Scores.Add(score1_1); var score1_2 = new Score { CourseNumber = 2, CourseScore = 1 }; results[0].Scores.Add(score1_2); var score1_3 = new Score { CourseNumber = 3, CourseScore = 1 }; results[0].Scores.Add(score1_3); var score2_1 = new Score { CourseNumber = 1, CourseScore = 3 }; results[1].Scores.Add(score2_1); var score2_2 = new Score { CourseNumber = 2, CourseScore = 3 }; results[1].Scores.Add(score2_2); var score2_3 = new Score { CourseNumber = 3, CourseScore = 3 }; results[1].Scores.Add(score2_3); var score3_1 = new Score { CourseNumber = 1, CourseScore = 2 }; results[2].Scores.Add(score3_1); var score3_2 = new Score { CourseNumber = 2, CourseScore = 2 }; results[2].Scores.Add(score3_2); var score3_3 = new Score { CourseNumber = 3, CourseScore = 2 }; results[2].Scores.Add(score3_3); var score4_1 = new Score { CourseNumber = 1, CourseScore = -2 }; results[3].Scores.Add(score4_1); var score4_2 = new Score { CourseNumber = 2, CourseScore = -2 }; results[3].Scores.Add(score4_2); var score4_3 = new Score { CourseNumber = 3, CourseScore = -2 }; results[3].Scores.Add(score4_3); var score5_1 = new Score { CourseNumber = 1, CourseScore = 10 }; results[4].Scores.Add(score5_1); var score5_2 = new Score { CourseNumber = 2, CourseScore = 10 }; results[4].Scores.Add(score5_2); var score5_3 = new Score { CourseNumber = 3, CourseScore = 10 }; results[4].Scores.Add(score5_3); var idList = _resultService.BreakTies(results.OrderBy(r => r.TotalScore).ToList()); Assert.IsTrue(idList.Count == 5); Assert.IsTrue(idList[0].Scores.Count == 3); Assert.IsTrue(idList[0].ResultId == 13); Assert.IsTrue(idList[1].ResultId == 10); Assert.IsTrue(idList[2].ResultId == 12); Assert.IsTrue(idList[3].ResultId == 11); Assert.IsTrue(idList[4].ResultId == 14); }
public void SaveNewScores(ScoreViewModel model, FormCollection form) { //var comp = _eventRepository.GetEventById(model.EventId); var result = new Result { EventId = model.EventId, DriverId = model.DriverId, ClassId = model.ClassId, DateCreated = DateTime.Now, DateModified = DateTime.Now }; for (int i = 0; i < model.NumberOfCourses; i ++ ) { int? courseScore = null; if(!string.IsNullOrEmpty(form["Course_" + (i + 1) + "_Score"])) { courseScore = int.Parse(form["Course_" + (i + 1) + "_Score"]); } var score = new Score { CourseNumber = i + 1, CourseScore = courseScore }; if(result.Scores == null) { result.Scores = new EntityCollection<Score>(); } result.Scores.Add(score); } _resultRepository.SaveNewScores(result); _resultService.AwardPlaceAndPoints(result.EventId, result.ClassId); }
public void WPaC_Case_ThreeWay_Two_Unbreakable() { var results = CreateResultSet(6, 2); var score1_1 = new Score { CourseNumber = 1, CourseScore = 28 }; results[0].Scores.Add(score1_1); var score1_2 = new Score { CourseNumber = 2, CourseScore = 28 }; results[0].Scores.Add(score1_2); var score2_1 = new Score { CourseNumber = 1, CourseScore = 36 }; results[1].Scores.Add(score2_1); var score2_2 = new Score { CourseNumber = 2, CourseScore = 30 }; results[1].Scores.Add(score2_2); var score3_1 = new Score { CourseNumber = 1, CourseScore = 38 }; results[2].Scores.Add(score3_1); var score3_2 = new Score { CourseNumber = 2, CourseScore = 28 }; results[2].Scores.Add(score3_2); var score4_1 = new Score { CourseNumber = 1, CourseScore = 38 }; results[3].Scores.Add(score4_1); var score4_2 = new Score { CourseNumber = 2, CourseScore = 28 }; results[3].Scores.Add(score4_2); var score5_1 = new Score { CourseNumber = 1, CourseScore = 38 }; results[4].Scores.Add(score5_1); var score5_2 = new Score { CourseNumber = 2, CourseScore = 30 }; results[4].Scores.Add(score5_2); var score6_1 = new Score { CourseNumber = 1, CourseScore = 32 }; results[5].Scores.Add(score6_1); var score6_2 = new Score { CourseNumber = 2, CourseScore = 38 }; results[5].Scores.Add(score6_2); var idList = _resultService.BreakTies(results.OrderBy(r => r.TotalScore).ToList()); Assert.IsTrue(idList.Count == 6); Assert.IsTrue(idList[0].Scores.Count == 2); Assert.IsTrue(idList[0].ResultId == 10); Assert.IsTrue(idList[1].ResultId == 12); Assert.IsTrue(idList[2].ResultId == 13); Assert.IsTrue(idList[3].ResultId == 11); Assert.IsTrue(idList[4].ResultId == 14); Assert.IsTrue(idList[5].ResultId == 15); }
public void Two_Results_One_Tie_Course3_Breaks_Doesnt_Change_Order() { var results = CreateResultSet(2, 3); var score1_1 = new Score { CourseNumber = 1, CourseScore = 2 }; results[0].Scores.Add(score1_1); var score1_2 = new Score { CourseNumber = 2, CourseScore = 3 }; results[0].Scores.Add(score1_2); var score1_3 = new Score { CourseNumber = 3, CourseScore = 1 }; results[0].Scores.Add(score1_3); var score2_1 = new Score { CourseNumber = 1, CourseScore = 2 }; results[1].Scores.Add(score2_1); var score2_2 = new Score { CourseNumber = 2, CourseScore = 2 }; results[1].Scores.Add(score2_2); var score2_3 = new Score { CourseNumber = 3, CourseScore = 2 }; results[1].Scores.Add(score2_3); var idList = _resultService.BreakTies(results); Assert.IsTrue(idList.Count == 2); Assert.IsTrue(idList[0].Scores.Count == 3); Assert.IsTrue(idList[0].ResultId == 10); Assert.IsTrue(idList[1].ResultId == 11); }
public void One_Result_No_Ties() { var results = CreateResultSet(1, 3); var score1_1 = new Score { CourseNumber = 1, CourseScore = 1 }; results[0].Scores.Add(score1_1); var score1_2 = new Score { CourseNumber = 2, CourseScore = 1 }; results[0].Scores.Add(score1_2); var score1_3 = new Score { CourseNumber = 3, CourseScore = 1 }; results[0].Scores.Add(score1_3); var idList = _resultService.BreakTies(results); Assert.IsTrue(idList.Count == 1); Assert.IsTrue(idList[0].Scores.Count == 3); Assert.IsTrue(idList[0].ResultId == 10); }
public void Five_Results_Two_Ties_One_Unbreakable() { var results = CreateResultSet(5, 3); var score1_1 = new Score { CourseNumber = 1, CourseScore = 10 }; // 0 3 results[0].Scores.Add(score1_1); var score1_2 = new Score { CourseNumber = 2, CourseScore = -10 }; results[0].Scores.Add(score1_2); var score1_3 = new Score { CourseNumber = 3, CourseScore = 0 }; results[0].Scores.Add(score1_3); var score2_1 = new Score { CourseNumber = 1, CourseScore = -10 }; // -20 2 results[1].Scores.Add(score2_1); var score2_2 = new Score { CourseNumber = 2, CourseScore = -18 }; results[1].Scores.Add(score2_2); var score2_3 = new Score { CourseNumber = 3, CourseScore = 8 }; results[1].Scores.Add(score2_3); var score3_1 = new Score { CourseNumber = 1, CourseScore = 10 }; // 0 4 results[2].Scores.Add(score3_1); var score3_2 = new Score { CourseNumber = 2, CourseScore = -10 }; results[2].Scores.Add(score3_2); var score3_3 = new Score { CourseNumber = 3, CourseScore = 0 }; results[2].Scores.Add(score3_3); var score4_1 = new Score { CourseNumber = 1, CourseScore = 28 }; // 20 5 results[3].Scores.Add(score4_1); var score4_2 = new Score { CourseNumber = 2, CourseScore = -10 }; results[3].Scores.Add(score4_2); var score4_3 = new Score { CourseNumber = 3, CourseScore = 0 }; results[3].Scores.Add(score4_3); var score5_1 = new Score { CourseNumber = 1, CourseScore = 10 }; // -20 1 results[4].Scores.Add(score5_1); var score5_2 = new Score { CourseNumber = 2, CourseScore = -20 }; results[4].Scores.Add(score5_2); var score5_3 = new Score { CourseNumber = 3, CourseScore = -10 }; // WINNER results[4].Scores.Add(score5_3); var idList = _resultService.BreakTies(results.OrderBy(r => r.TotalScore).ToList()); Assert.IsTrue(idList.Count == 5); Assert.IsTrue(idList[0].Scores.Count == 3); Assert.IsTrue(idList[0].ResultId == 14); Assert.IsTrue(idList[1].ResultId == 11); Assert.IsTrue(idList[2].ResultId == 10); Assert.IsTrue(idList[3].ResultId == 12); Assert.IsTrue(idList[4].ResultId == 13); }
/// <summary> /// Deprecated Method for adding a new object to the Scores EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToScores(Score score) { base.AddObject("Scores", score); }
/// <summary> /// Create a new Score object. /// </summary> /// <param name="scoreId">Initial value of the ScoreId property.</param> /// <param name="resultId">Initial value of the ResultId property.</param> /// <param name="courseNumber">Initial value of the CourseNumber property.</param> public static Score CreateScore(global::System.Int32 scoreId, global::System.Int32 resultId, global::System.Int32 courseNumber) { Score score = new Score(); score.ScoreId = scoreId; score.ResultId = resultId; score.CourseNumber = courseNumber; return score; }