public void GivenATournamentNamedWithUsersAddedToIt(string tournamentName, string commaSeparatedUserNames) { List <string> userNames = StringUtility.ToStringList(commaSeparatedUserNames, ","); using (UserRepository userRepository = CreateuserRepository()) { foreach (string userName in userNames) { userRepository.CreateUser(userName); } userRepository.Save(); using (TournamentRepository tournamentRepository = CreateTournamentRepository()) { Tournament tournament = tournamentRepository.CreateTournament(tournamentName); foreach (string userName in userNames) { User user = userRepository.GetUserByName(userName); tournamentRepository.AddBetterToTournament(tournament, user); } tournamentRepository.Save(); } } }
public void CannotCreateTournamentWithNameAlreadyInUseNoMatterLetterCasing() { using (TournamentRepository tournamentRepository = CreateTournamentRepository()) { Tournament secondTournament = tournamentRepository.CreateTournament(tournamentName.ToUpper()); secondTournament.Should().BeNull(); } }
public TournamentRepositoryTestBase() { testDatabaseName = Guid.NewGuid().ToString(); using (TournamentRepository tournamentRepository = CreateTournamentRepository()) { tournamentRepository.CreateTournament(tournamentName); tournamentRepository.Save(); } }
private void btn_createTournament_Click(object sender, EventArgs e) { if (lbox_team1Selection.SelectedItem != null && lbox_team2Selection.SelectedItem != null && lbox_team3Selection.SelectedItem != null && lbox_team4Selection.SelectedItem != null && lbox_team1Selection.SelectedItem.ToString() != lbox_team2Selection.SelectedItem.ToString() && lbox_team1Selection.SelectedItem.ToString() != lbox_team3Selection.SelectedItem.ToString() && lbox_team1Selection.SelectedItem.ToString() != lbox_team4Selection.SelectedItem.ToString() && lbox_team2Selection.SelectedItem.ToString() != lbox_team3Selection.SelectedItem.ToString() && lbox_team2Selection.SelectedItem.ToString() != lbox_team4Selection.SelectedItem.ToString() && lbox_team3Selection.SelectedItem.ToString() != lbox_team4Selection.SelectedItem.ToString()) { Tournament tournament = tournamentRepository.CreateTournament(DateTime.Now, DateTime.Now.AddDays(1), lbox_team1Selection.SelectedItem.ToString() + " tournament"); TournamentMatches tournamentMatchers = new TournamentMatches(tournament, lbox_team1Selection.SelectedItem.ToString(), lbox_team2Selection.SelectedItem.ToString(), lbox_team3Selection.SelectedItem.ToString(), lbox_team4Selection.SelectedItem.ToString()); tournamentMatchers.ShowDialog(); } else { MessageBox.Show("Choose 4 different teams!"); } }
public void CanGetCertainRangeOfCreatedTournaments() { List <string> tournamentNames = new List <string>() { tournamentName }; for (int index = 1; index < 30; ++index) { tournamentNames.Add("Tourney " + index.ToString()); } using (TournamentRepository tournamentRepository = CreateTournamentRepository()) { foreach (string tournamentName in tournamentNames) { tournamentRepository.CreateTournament(tournamentName); // Wait a bit between creation just to make sure the created date has some space between each tournament Thread.Sleep(100); } tournamentRepository.Save(); int startIndex = 15; int grabCount = 6; List <Tournament> tournaments = tournamentRepository.GetTournaments(startIndex, grabCount).ToList(); tournaments.Should().HaveCount(grabCount); for (int index = 0; index < tournaments.Count; ++index) { string expectedName = "Tourney " + (startIndex + index).ToString(); tournaments[index].Name.Should().Be(expectedName); } } }
public void CanGetListOfSeveralTournaments() { List <string> tournamentNames = new List <string>() { tournamentName, "WCS 2019", "BHA Cup", "DH Masters" }; using (TournamentRepository tournamentRepository = CreateTournamentRepository()) { foreach (string tournamentName in tournamentNames) { tournamentRepository.CreateTournament(tournamentName); } tournamentRepository.Save(); IEnumerable <Tournament> tournaments = tournamentRepository.GetTournaments(); tournaments.Should().HaveCount(tournamentNames.Count); foreach (string tournamentName in tournamentNames) { tournaments.FirstOrDefault(tournament => tournament.Name == tournamentName).Should().NotBeNull(); } } }