public void TestUpdatePersistedMatch() { //Arrange int matchId = _MatchController.CreateMatch(_TestMatch); Match testMatchUpdate = new Match { Id = matchId, Held = true, Format = "TestFormatUpdated", Winner = _TestTeam1, EventId = _EventId }; testMatchUpdate.Maps.Add(_TestMap); testMatchUpdate.Teams.Add(_TestTeam1); testMatchUpdate.Teams.Add(_TestTeam2); //Act _MatchController.EditMatch(testMatchUpdate); var result = _MatchController.GetMatch(matchId); //LocalCleanUp _MatchController.DeleteMatch(testMatchUpdate); //Assert Assert.AreEqual(testMatchUpdate.Winner.Id, result.Winner.Id); }
public void TestCleanUp() { //Delete Bet TransactionOptions to = new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted }; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, to)) { using (SqlConnection connection = GetSqlConnection()) { connection.Open(); using (SqlCommand command = connection.CreateCommand()) { command.CommandText = "DELETE FROM TeamsOnBetsOnMatch WHERE TeamId=@id"; command.Parameters.AddWithValue("id", TestTeam1.Id); command.ExecuteNonQuery(); command.Parameters.Clear(); command.CommandText = "DELETE FROM BetsOnmatch WHERE BetId=@id"; command.Parameters.AddWithValue("id", TestBet.Id); command.ExecuteNonQuery(); command.Parameters.Clear(); command.CommandText = "DELETE FROM Bet WHERE Id=@id"; command.Parameters.AddWithValue("id", TestBet.Id); command.ExecuteNonQuery(); } connection.Close(); } scope.Complete(); } //Delete TestUser UserController.DeleteUser(TestUser); //Delete TestPlayers foreach (Player p in TestTeam1.Players) { PlayerController.DeletePlayer(p); } foreach (Player p in TestTeam2.Players) { PlayerController.DeletePlayer(p); } //Delete TestMatch MatchController.DeleteMatch(TestMatch); //Delete TestEvent EventController.DeleteEvent(TestEvent); //Delete TestTeam TeamController.DeleteTeam(TestTeam1); TeamController.DeleteTeam(TestTeam2); //Delete TestMap MatchController.DeleteMap(TestMap); }
/// <summary> /// Deletes persisted match /// </summary> /// <param name="match"></param> public void DeleteMatch(Match match) { matchController.DeleteMatch(match); }