public static Player RegisterNewPlayer(string name, IPlayerMapper playerMapper = null) { // If a PlayerMapper was not passed in, use a real one. // This allows us to pass in a "mock" PlayerMapper (for testing), // but use a real PlayerMapper, when running the program. if (playerMapper == null) { playerMapper = new PlayerMapper(); } if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentException("Player name can’t be empty."); } // Throw an exception if there is already a player with this name in the database. if (playerMapper.IsPlayerNameExistsInDb(name)) { throw new ArgumentException("Player name already exists."); } // Add the player to the database. playerMapper.AddNewPlayerIntoDb(name); return(new Player("Test", 23, "India", 30)); }
public PlayerContext(IPlayerRepository playerRepository, IGameRepository gameRepository, IPlayerMapper playerMapper, IGameMapper gameMapper) { _playerRepository = playerRepository; _gameRepository = gameRepository; _playerMapper = playerMapper; _gameMapper = gameMapper; }
public RegisterFacade(IRatingService ratingService, ITeamMapper teamMapper, IPlayerMapper playerMapper, ITeamService teamService, IPlayerService playerService) { _ratingService = ratingService; _teamMapper = teamMapper; _playerMapper = playerMapper; _teamService = teamService; _playerService = playerService; }
public void Init() { mockPlayerMapper = Mock.Of <IPlayerMapper>(); Mock.Get(mockPlayerMapper) .Setup(m => m.IsPlayerNameExistsInDb(It.IsAny <string>())) .Returns(false); Mock.Get(mockPlayerMapper) .Setup(m => m.AddNewPlayerIntoDb(It.IsAny <string>())); //player = new Player(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<string>(), It.IsAny<int>()); }
public static Player RegisterNewPlayer(string name, IPlayerMapper playermapper = null) { if (playermapper == null) { playermapper = new PlayerMapper(); } if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentException("Player name can't be empty."); } if (playermapper.IsPlayerNameExistsInDb(name)) { throw new ArgumentException("Player name alredy exists."); } playermapper.AddNewPlayerIntoDb(name); return(new Player(name, 23, "India", 30)); }
public PlayerManager(IPlayerMapper playerMapper) { this._playerMapper = playerMapper; }
public PlayerController(IPlayerMapper playerMapper, IPlayerService playerService) { _mapper = playerMapper; _playerService = playerService; }
public PlayersContext(IPlayerRepository playerRepository, IPlayerMapper mapper) { _mapper = mapper; _playerRepository = playerRepository; }
public ApplicationServicePlayer(IPlayerService PlayerService, IPlayerMapper PlayerMapper) { _playerService = PlayerService; _playerMapper = PlayerMapper; }
public PlayersRepository(IPlayerDataProvider dataProvider, IPlayerMapper mapper) { _dataProvider = dataProvider; _mapper = mapper; }
public Player(IPlayerMapper playerMapper) { this.PlayerMapper = playerMapper; }
public PlayerService(IBaseballDBContext database, IPlayerMapper mapper) { _database = database; _mapper = mapper; }