public void Create_PlayerNameIsEmpty_ArgumentException() { //Arrange IGameRepository repository = RepositoryFactory.GetGameRepository(); //Act GetPlayedGamesByPlayer getPlayedTransaction = new GetPlayedGamesByPlayer(repository, string.Empty); }
public void Create_NullRepository_ArgumentException() { //Arrange IGameRepository repository = new MockGameRepository(); //Act GetPlayedGamesByPlayer getPlayedTransaction = new GetPlayedGamesByPlayer(null, "Player1"); }
public IEnumerable <GameData> Get(string id) { GetPlayedGamesByPlayer transaction = TransactionFactory.GetListGamesPlayedTransaction(id); transaction.Execute(); return(transaction.GetResult()); }
public void Execute_ValidPlayer_GamesFound() { //Arrange IGameRepository repository = RepositoryFactory.GetGameRepository(); int maxWins = 3; Move move1 = new Move("Rock"); Move move2 = new Move("Scissors"); Move move3 = new Move("Paper"); GameRules rules = new GameRules(maxWins); move1.AddKill(move2.Name); move2.AddKill(move3.Name); move3.AddKill(move1.Name); rules.AddMove(move1); rules.AddMove(move2); rules.AddMove(move3); Game game = new Game(rules, "player1", "player2"); game.Play(move1.Name, move2.Name); game.Play(move3.Name, move1.Name); game.Play(move2.Name, move3.Name); RegisterGameResult registerGameTransaction = new RegisterGameResult(repository, game); registerGameTransaction.Execute(); GetPlayedGamesByPlayer getPlayedTransaction = new GetPlayedGamesByPlayer(repository, "player1"); //Act getPlayedTransaction.Execute(); //Assert IEnumerable <GameData> result = getPlayedTransaction.GetResult(); GameData playedGame = result.ElementAt(0); Assert.AreEqual(3, playedGame.ScorePlayer1); Assert.AreEqual(0, playedGame.ScorePlayer2); Assert.AreEqual("player1", playedGame.WinnerName); }