Ejemplo n.º 1
0
        public void AddGameOwned()
        {
            var player = new Player {
                Id = 1, FirstName = "First 1", LastName = "Last 1"
            };
            var players = new List <Player> {
                player
            };
            var game = new Game {
                Id = 1, Name = "Game 1"
            };
            var games = new List <Game> {
                game
            };

            var context = _fixture.Context
                          .PlayersContain(players)
                          .GamesContain(games);
            var playerRepository = new PlayerRepository(context);

            playerRepository.AddGameOwned(player.Id, game.Id);

            var result = playerRepository.GetAllGamesBy(player.Id);

            Assert.Equal(1, result.First()
                         .Id);
            Assert.Equal("Game 1", result.First()
                         .Name);
        }
Ejemplo n.º 2
0
        public void DoesNotAddDuplicateGameOwned()
        {
            var player = new Player {
                Id = 1, FirstName = "First 1", LastName = "Last 1"
            };
            var players = new List <Player> {
                player
            };
            var game = new Game {
                Id = 1, Name = "Game 1"
            };
            var games = new List <Game> {
                game
            };

            var context = _fixture.Context
                          .PlayersContain(players)
                          .GamesContain(games);
            var playerRepository = new PlayerRepository(context);

            playerRepository.AddGameOwned(player.Id, game.Id);
            Assert.Throws <ArgumentException>(() => playerRepository.AddGameOwned(player.Id, game.Id));
        }
Ejemplo n.º 3
0
        public void DoesNotAddInvalidGameOwned(int playerId, int gameId)
        {
            var player = new Player {
                Id = playerId, FirstName = "First 1", LastName = "Last 1"
            };
            var players = playerId == 0 ? new List <Player>() : new List <Player> {
                player
            };
            var game = new Game {
                Id = gameId, Name = "Game 1"
            };
            var games = gameId == 0 ? new List <Game>() : new List <Game> {
                game
            };

            var context = _fixture.Context
                          .GamesContain(games)
                          .PlayersContain(players);
            var playerRepository = new PlayerRepository(context);

            Assert.Throws <ArgumentException>(() => playerRepository.AddGameOwned(playerId, gameId));
        }