public void Compete_With_Valid_Competitors_In_Competition_Score_Changed() { //Arrange var olympics = new Olympics(); //Act olympics.AddCompetition(1, "SoftUniada", 500); olympics.AddCompetitor(5, "Ani"); olympics.Compete(5, 1); olympics.AddCompetitor(1, "Ivan"); olympics.Compete(1, 1); olympics.AddCompetitor(2, "Stamat"); olympics.Compete(2, 1); int expectedCompetitorsScore = 1500; long actualCompetitorsScore = 0; foreach (Competitor competitor in olympics.GetCompetition(1).Competitors) { actualCompetitorsScore += competitor.TotalScore; } //Assert Assert.AreEqual(expectedCompetitorsScore, actualCompetitorsScore); }
public void Disqualify_Should_Decrease_Competitors_Count_In_Competition() { //Arrange var olympics = new Olympics(); //Act olympics.AddCompetition(1, "SoftUniada", 500); olympics.AddCompetitor(5, "Ani"); olympics.Compete(5, 1); olympics.AddCompetitor(1, "Ivan"); olympics.Compete(1, 1); olympics.AddCompetitor(2, "Stamat"); olympics.Compete(2, 1); olympics.Disqualify(1, 5); int expectedCompetitorsCount = 2; int actualCompetitorsCount = olympics.GetCompetition(1).Competitors.Count; //Assert Assert.AreEqual(expectedCompetitorsCount, actualCompetitorsCount); }
public void Compete_With_Valid_Competitors_In_Competition() { //Arrange var olympics = new Olympics(); //Act olympics.AddCompetition(1, "SoftUniada", 500); olympics.AddCompetitor(5, "Ani"); olympics.Compete(5, 1); olympics.AddCompetitor(1, "Ivan"); olympics.Compete(1, 1); olympics.AddCompetitor(2, "Stamat"); olympics.Compete(2, 1); int expectedCompetitorsCount = 3; int actualCompetitorsCount = olympics.GetCompetition(1).Competitors.Count; //Assert Assert.AreEqual(expectedCompetitorsCount, actualCompetitorsCount); }
public void GetCompetition_With_Invalid_Id_Should_Throw_Exception() { //Arrange var olympics = new Olympics(); int id = 1; string name = "SoftUniada"; int score = 500; //Act olympics.AddCompetition(id, name, score); //Assert Assert.Throws <ArgumentException>(() => olympics.GetCompetition(int.MinValue)); }
public void GetCompetition_Should_Return_Correct_Competition() { //Arrange var olympics = new Olympics(); int id = 1; string name = "SoftUniada"; int score = 500; //Act olympics.AddCompetition(id, name, score); Competition competition = olympics.GetCompetition(id); bool isCorrectCompetition = competition.Id == id && competition.Name == name && competition.Score == score; //Assert Assert.IsTrue(isCorrectCompetition); }