コード例 #1
0
        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));
        }
コード例 #2
0
 public PlayerContext(IPlayerRepository playerRepository, IGameRepository gameRepository,
                      IPlayerMapper playerMapper, IGameMapper gameMapper)
 {
     _playerRepository = playerRepository;
     _gameRepository   = gameRepository;
     _playerMapper     = playerMapper;
     _gameMapper       = gameMapper;
 }
コード例 #3
0
 public RegisterFacade(IRatingService ratingService, ITeamMapper teamMapper,
                       IPlayerMapper playerMapper, ITeamService teamService, IPlayerService playerService)
 {
     _ratingService = ratingService;
     _teamMapper    = teamMapper;
     _playerMapper  = playerMapper;
     _teamService   = teamService;
     _playerService = playerService;
 }
コード例 #4
0
        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>());
        }
コード例 #5
0
ファイル: Player.cs プロジェクト: Arunthathi99/NUnitHandsOn
        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));
        }
コード例 #6
0
 public PlayerManager(IPlayerMapper playerMapper)
 {
     this._playerMapper = playerMapper;
 }
コード例 #7
0
 public PlayerController(IPlayerMapper playerMapper, IPlayerService playerService)
 {
     _mapper        = playerMapper;
     _playerService = playerService;
 }
コード例 #8
0
 public PlayersContext(IPlayerRepository playerRepository, IPlayerMapper mapper)
 {
     _mapper           = mapper;
     _playerRepository = playerRepository;
 }
コード例 #9
0
 public ApplicationServicePlayer(IPlayerService PlayerService, IPlayerMapper PlayerMapper)
 {
     _playerService = PlayerService;
     _playerMapper  = PlayerMapper;
 }
コード例 #10
0
 public PlayersRepository(IPlayerDataProvider dataProvider, IPlayerMapper mapper)
 {
     _dataProvider = dataProvider;
     _mapper       = mapper;
 }
コード例 #11
0
 public Player(IPlayerMapper playerMapper)
 {
     this.PlayerMapper = playerMapper;
 }
コード例 #12
0
 public PlayerService(IBaseballDBContext database, IPlayerMapper mapper)
 {
     _database = database;
     _mapper   = mapper;
 }