public void TestCalculateCompetitionPoints() { var diver = new Diver(3, "Johan", "Sweden", 23, "Man", 365); var dive1 = new Dive(1, 3.6f, 0, 1, diver.DiverId); var dive2 = new Dive(1, 6.2f, 0, 2, diver.DiverId); var dive3 = new Dive(1, 1.2f, 0, 3, diver.DiverId); var dive4 = new Dive(1, 3.0f, 0, 4, diver.DiverId); var dive5 = new Dive(1, 4.7f, 0, 5, diver.DiverId); diver.AddDive(dive1); diver.AddDive(dive2); diver.AddDive(dive3); diver.AddDive(dive4); diver.AddDive(dive5); Assert.AreEqual(5, diver.ListDive.Count); var score1 = new Score(5.5f); var score2 = new Score(2.5f); var score3 = new Score(8.0f); var score4 = new Score(5.0f); var score5 = new Score(2.5f); var allRefScores = new List<Score> { score1, score2, score3, score4, score5 }; diver.ListDive[0].TotalPoints.CalculateCompleteScore(allRefScores, diver.ListDive[0].Type.Difficulty); diver.ListDive[1].TotalPoints.CalculateCompleteScore(allRefScores, diver.ListDive[1].Type.Difficulty); diver.ListDive[2].TotalPoints.CalculateCompleteScore(allRefScores, diver.ListDive[2].Type.Difficulty); diver.ListDive[3].TotalPoints.CalculateCompleteScore(allRefScores, diver.ListDive[3].Type.Difficulty); diver.ListDive[4].TotalPoints.CalculateCompleteScore(allRefScores, diver.ListDive[4].Type.Difficulty); diver.SummarizeDivePoints(); //Assert.AreEqual(243.1, Math.Round(diver._competitionScore, 2)); }
public void TestAddDive() { var testDiver = new Diver(); testDiver.AddDive(new Dive(1, (float)3.5, 0, 1, testDiver.DiverId)); testDiver.AddDive(new Dive(2, (float)5.5, 0, 2, testDiver.DiverId)); Assert.AreEqual(testDiver.ListDive[0].Type.Difficulty, 3.5); Assert.AreEqual(testDiver.ListDive[1].Type.Difficulty, 5.5); }
public void TestCreateDiver() { var diver = new Diver(3, "Johan", "Sweden", 23, "Man", 365); var dive1 = new Dive(1, 3.6f, 0, 1, diver.DiverId); var dive2 = new Dive(1, 6.2f, 0, 2, diver.DiverId); var dive3 = new Dive(1, 1.2f, 0, 3, diver.DiverId); var dive4 = new Dive(1, 3.0f, 0, 4, diver.DiverId); var dive5 = new Dive(1, 4.7f, 0, 5, diver.DiverId); diver.AddDive(dive1); diver.AddDive(dive2); diver.AddDive(dive3); diver.AddDive(dive4); diver.AddDive(dive5); Assert.AreEqual(5, diver.ListDive.Count); }
public void TestFullCompetition() { var competitionObject = new Competition(1, "Örebro Mästerskapen", "20160217", "Örebro", "DM", 3); var diver = new Diver(4, "Klas", "Uganda", 59, "Man", 3); var diver2 = new Diver(5, "Susanna", "Sweden", 27, "Kvinna", 12); var diver3 = new Diver(2, "Klas-Göran", "Sweden", 22, "Man", 321); competitionObject.AddDiver(diver); competitionObject.AddDiver(diver2); competitionObject.AddDiver(diver3); Assert.AreEqual(3, competitionObject.ListDiver.Count); var dive1 = new Dive(1, 3.6f, 0, 1, diver.DiverId); var dive2 = new Dive(2, 6.2f, 0, 2, diver.DiverId); var dive3 = new Dive(3, 1.2f, 0, 3, diver.DiverId); diver.AddDive(dive1); diver.AddDive(dive2); diver.AddDive(dive3); var dive4 = new Dive(4, 2.6f, 0, 1, diver2.DiverId); var dive5 = new Dive(5, 3.7f, 0, 2, diver2.DiverId); var dive6 = new Dive(6, 9.2f, 0, 3, diver2.DiverId); diver2.AddDive(dive4); diver2.AddDive(dive5); diver2.AddDive(dive6); var dive7 = new Dive(7, 4.9f, 0, 1, diver3.DiverId); var dive8 = new Dive(8, 6.2f, 0, 2, diver3.DiverId); var dive9 = new Dive(9, 1.2f, 0, 3, diver3.DiverId); diver3.AddDive(dive7); diver3.AddDive(dive8); diver3.AddDive(dive9); if (competitionObject.CheckIfSameAmountOfDives()) { var allRefScores = new List<Score>(); var score1 = new Score(5.5f); var score2 = new Score(2.5f); var score3 = new Score(8.0f); var score4 = new Score(5.0f); var score5 = new Score(2.5f); allRefScores.Add(score1); allRefScores.Add(score2); allRefScores.Add(score3); allRefScores.Add(score4); allRefScores.Add(score5); for (var i = 0; i < competitionObject.Rounds; i++) { foreach (var contestant in competitionObject.ListDiver) { contestant.ListDive[i].TotalPoints.CalculateCompleteScore(allRefScores, contestant.ListDive[i].Type.Difficulty); } } foreach (var contestant in competitionObject.ListDiver) { contestant.SummarizeDivePoints(); } Assert.AreEqual("Susanna", competitionObject.GetWinner()); } }
private static void AddDives(Diver tempDiver, int rounds) { WriteLine("Enter details of dives for {0}:", tempDiver.Name); for (var i = 1; i <= rounds; i++) { var dive = new Dive(); WriteLine($"Dive number {i}:"); WriteLine("Dive code: "); dive.Type.Code = ReadLine(); try { if (!tempDiver.ListDive.Contains(dive)) tempDiver.AddDive(dive); else { i--; throw new ListObjectAlreadyExistsException("Dive already added!"); } } catch (ListObjectAlreadyExistsException e) { WriteLine(e.Message); } } TempCompetition.AddDiver(tempDiver); WriteLine("Diver {0} added!", tempDiver.Name); Thread.Sleep(2000); }