public void TestDeleteTeam() { // seeding DB using (var context = new ProTickDatabaseContext(dbOptions)) { DbContextSeeder.SeedFull(context); } // db is Test-Ready using (var context = new ProTickDatabaseContext(dbOptions)) { var dbm = new DatabaseQueryManager(context); var converter = new ResourceDTOConverter(dbm); var controller = new TeamController(context, converter, dbm); var dtos = DbContextSeeder.GetSeededTeamDTOs( 3 ) .ToList(); controller.DeleteTeam(dtos[2].TeamID); var actualCount = context.Team.ToList().Count; Assert.Equal(2, actualCount); Assert.True(context.Team.FirstOrDefault(x => x.TeamID == 3) == null); Assert.True(context.Team.FirstOrDefault(x => x.TeamID != 3) != null); controller.DeleteTeam(dtos[1].TeamID); actualCount = context.Team.ToList().Count; Assert.Equal(1, actualCount); Assert.True(context.Team.FirstOrDefault(x => x.TeamID == 2) == null); } }
//Deletes all Matches with the format "TestFormat" from db public void TestCleanUp() { _MatchController.DeleteMatch(_TestMatch); _EventController.DeleteEvent(_TestEvent); foreach (Player player in _TestTeam1.Players) { _PlayerController.DeletePlayer(player); } foreach (Player player in _TestTeam2.Players) { _PlayerController.DeletePlayer(player); } _TeamController.DeleteTeam(_TestTeam1); _TeamController.DeleteTeam(_TestTeam2); string connStr = ConfigurationManager.ConnectionStrings["JaaamDbString"].ToString(); using (SqlConnection connection = new SqlConnection(connStr)){ connection.Open(); using (SqlCommand command = connection.CreateCommand()) { command.CommandText = "DELETE FROM MAP where Name = @Name; DBCC CHECKIDENT(MAP, RESEED);"; command.Parameters.AddWithValue("Name", _TestMap.Name); command.ExecuteNonQuery(); } connection.Close(); } }
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); }
public void TestDeletePersistedTeamPass() { //Arrange int id = _TeamController.CreateTeam(_TestTeam); _TestTeam.Id = id; //Act foreach (Player p in _TestTeam.Players) { _PlayerController.DeletePlayer(p); } _TeamController.DeleteTeam(_TestTeam); _TestTeam.Id = id; Team result = _TeamController.GetTeam(id); //Assert Assert.IsNull(result); }
public void TestCleanUp() { _playerController.DeletePlayer(_testPlayer1); _playerController.DeletePlayer(_testPlayer2); _playerController.DeletePlayer(_testPlayer3); _playerController.DeletePlayer(_testPlayer4); _playerController.DeletePlayer(_testPlayer5); _teamController.DeleteTeam(_testTeam); }
public void DeleteTeam() { // Arrange // Act _target.DeleteTeam(1); // Assert A.CallTo(() => _teamService.GetTeamById(1)).MustHaveHappened(); A.CallTo(() => _teamService.DeleteTeam(A <Team> ._)).MustHaveHappened(); }
public async void TestForDeleteTeam() { var options = new DbContextOptionsBuilder <LeagueContext>() .UseInMemoryDatabase(databaseName: "p3TeamControllerDeleteTeam") .Options; using (var context = new LeagueContext(options)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); Repo r = new Repo(context, new NullLogger <Repo>()); Logic logic = new Logic(r, new NullLogger <Repo>()); TeamController teamController = new TeamController(logic); var team = new Team { TeamID = Guid.NewGuid(), CarpoolID = Guid.NewGuid(), LeagueID = Guid.NewGuid(), StatLineID = Guid.NewGuid(), Name = "Broncos", Wins = 21, Losses = 33 }; var deleteTeam = await teamController.DeleteTeam(team.TeamID); Assert.IsAssignableFrom <string>((deleteTeam as NotFoundObjectResult).Value); r.Teams.Add(team); await r.CommitSave(); var deleteTeam2 = await teamController.DeleteTeam(team.TeamID); Assert.IsAssignableFrom <bool>((deleteTeam2 as OkObjectResult).Value); } }
/// <summary> /// Deletes persisted team /// </summary> /// <param name="team"></param> public void DeleteTeam(Team team) { teamController.DeleteTeam(team); }