public void TestRead() { //createFile(); Scoreboard testBoard = new Scoreboard(fileName); testBoard.AddScore("qweqwe", 1337); testBoard.AddScore("gtegrge", 12); testBoard.AddScore("rwetwehhg", 18); //testBoard. }
public void TestAddAndSave() { //createFile(); Scoreboard testBoard = new Scoreboard(fileName); testBoard.AddScore("lolminator", 1337); testBoard.AddScore("asdf", 1337); testBoard.AddScore("3rqwe", 1337); testBoard.SaveToFile(); }
public void SaveToFileTest() { Scoreboard newScoreBoard = new Scoreboard(fileName); newScoreBoard.AddScore("Doncho", 35); newScoreBoard.AddScore("Svetlin", 88); newScoreBoard.AddScore("Niki", 35); newScoreBoard.AddScore("Joro", 35); newScoreBoard.AddScore("Ina", 3898); newScoreBoard.SaveToFile(); }
public void TestIncorrectFileName_NullPath() { Scoreboard testBoard = new Scoreboard(null); }
public void TestIncorrectFileName_FileNotFound() { Scoreboard testBoard = new Scoreboard("aoiheiqwhe"); }
public void TestConstructor_CorrectFileName() { //createFile(); Scoreboard testBoard = new Scoreboard(fileName); }
/// <summary> /// Represents the Cows And Bulls game UI /// </summary> public static void Main() { SecretNumber bullsAndCowsNumber = new SecretNumber(); Scoreboard scoreBoard = new Scoreboard(SCORES_FILE); Console.WriteLine(WELCOME_MESSAGE); string command = string.Empty; while (true) { Console.Write(INPUT_MESSAGE); command = Console.ReadLine(); if (command == EXIT_COMMAND) //this stays here, not in the swich, because break the while loop { Console.WriteLine(GOOD_BYE_MESSAGE); break; } switch (command) { case TOP_COMMAND: Console.Write(scoreBoard); break; case RESTART_COMMAND: Console.WriteLine(); Console.WriteLine(WELCOME_MESSAGE); bullsAndCowsNumber = new SecretNumber(); break; case HELP_COMMAND: Console.WriteLine("The number looks like {0}.", bullsAndCowsNumber.GetCheat()); break; default: try { Result guessResult = bullsAndCowsNumber.CheckUserGuess(command); if (guessResult.Bulls == 4) { string attempt = bullsAndCowsNumber.GuessesCount == 1 ? "attempt" : "attempts"; string cheat = bullsAndCowsNumber.CheatsCount == 1 ? "cheat" : "cheats"; if (bullsAndCowsNumber.CheatsCount == 0) { Console.Write(NUMBER_GUESSED_WITHOUT_CHEATS, bullsAndCowsNumber.GuessesCount, attempt); string name = Console.ReadLine(); scoreBoard.AddScore(name, bullsAndCowsNumber.GuessesCount); } else { Console.WriteLine(NUMBER_GUESSED_WITH_CHEATS, bullsAndCowsNumber.GuessesCount, attempt, bullsAndCowsNumber.CheatsCount, cheat); } Console.Write(scoreBoard); Console.WriteLine(); Console.WriteLine(WELCOME_MESSAGE); bullsAndCowsNumber = new SecretNumber(); } else { Console.WriteLine("{0} {1}", WRONG_NUMBER_MESSAGE, guessResult); } } catch (Exception ex) { //Modified by KrisNickson => this way it will catch all //expcetions the new validation in CheckUserGuess throws if (ex is ArgumentException || ex is FormatException) { Console.WriteLine(INVALID_COMMAND_MESSAGE); } } break; } } scoreBoard.SaveToFile(); }
public void ConstructorTest() { Scoreboard newScoreBoard = new Scoreboard(fileName); }