コード例 #1
0
        public void MapCopiesDataFromPeopleToPlayer()
        {
            People people = _testHelpers.GeneratePeople();
            Player player = _mapper.Map(people);

            AssertThatEachElementIsEqual(people, player);
        }
コード例 #2
0
        public void MapPlayerToPlayerViewModelWithGamesAndGamesOwned()
        {
            var player = new Player
            {
                Id        = 2,
                FirstName = "First Name",
                LastName  = "Last Name"
            };
            var games = new List <SelectListItem> {
                new SelectListItem {
                    Value = "1", Text = "Game 1"
                }
            };
            var gamesOwned = new List <GameViewModel> {
                new GameViewModel {
                    Id = 1, Name = "Game 1"
                }
            };
            var mapper    = new PlayerMapper();
            var viewModel = mapper.Map(player, games, gamesOwned);

            Assert.Equal(player.Id, viewModel.Id);
            Assert.Equal(player.FirstName, viewModel.FirstName);
            Assert.Equal(player.LastName, viewModel.LastName);
            Assert.Equal("First Name Last Name", viewModel.FullName);
            Assert.Equal(1, viewModel.Games.Count());
            Assert.Equal(1, viewModel.GamesOwned.Count());
        }
コード例 #3
0
        public void MapDynamoItemToModel_Scenario_ReturnsPlayerFromItem()
        {
            var draftId      = "AAA";
            var name         = "Tester";
            var connectionId = "123abc";
            var isConnected  = false;

            var item = new Dictionary <string, AttributeValue>
            {
                { "DraftId", new AttributeValue {
                      S = draftId
                  } },
                { "Name", new AttributeValue {
                      S = name
                  } },
                { "ConnectionId", new AttributeValue {
                      S = connectionId
                  } },
                { "IsConnected", new AttributeValue {
                      BOOL = isConnected
                  } }
            };

            var _playerMapper = new PlayerMapper();
            var result        = _playerMapper.Map(item);

            Assert.Equal(draftId, result.DraftId);
            Assert.Equal(name, result.Name);
            Assert.Equal(connectionId, result.ConnectionId);
            Assert.Equal(isConnected, result.IsConnected);
        }
コード例 #4
0
        public void MapNewPlayerToPlayerViewModel()
        {
            var player    = new Player();
            var mapper    = new PlayerMapper();
            var viewModel = mapper.Map(player);

            Assert.NotNull(viewModel);
        }
コード例 #5
0
        public async Task <PlayerModel> CreatePlayer(CreatePlayerCommand command)
        {
            var rating = await ratingApiClient.GetDefaultPlayerRating();

            CreatePlayerRequest createPlayerRequest = new CreatePlayerRequest(command.Name, rating.Rating, rating.Deviation, rating.Volatility);

            Player createdPlayer = await playersApiClient.CreatePlayer(createPlayerRequest);

            return(PlayerMapper.Map(createdPlayer));
        }
コード例 #6
0
        public void MapNullToPlayerViewModelWithGamesAndEmptyGamesOwnedOnly()
        {
            var games = new List <SelectListItem> {
                new SelectListItem {
                    Value = "1", Text = "Game 1"
                }
            };
            var mapper    = new PlayerMapper();
            var viewModel = mapper.Map(null, games, new List <GameViewModel>());

            Assert.NotNull(viewModel);
            Assert.Equal(1, viewModel.Games.Count());
        }
コード例 #7
0
        List <PlayerDTO> IFMService.FindPlayers(int NumberOfPlayers)
        {
            List <Player> Players = new List <Player>();

            foreach (Player P in _PlayerRepository.ListEntities())
            {
                if (_PlayerRepository.ListEntities(obj => obj.ID == P.ID).Count() == NumberOfPlayers)
                {
                    Players.Add(P);
                }
            }
            return(Players.Select(obj => PlayerMapper.Map(obj)).ToList());
        }
コード例 #8
0
    public void PlayerMapper_Can_Map_PlayerDto_To_PlayerModel()
    {
        // Arrange
        var mapper    = new PlayerMapper();
        var playerDto = new PlayerDto(Guid.NewGuid(), "PlayerName");

        // Act
        var playerModel = mapper.Map(playerDto);

        // Assert
        playerModel.Should().BeEquivalentTo(playerDto,
                                            properties => properties
                                            .Including(x => x.Id)
                                            .Including(x => x.Name));
    }
コード例 #9
0
        public void MapPlayerViewModelToPlayer()
        {
            var viewModel = new PlayerViewModel
            {
                Id        = 2,
                FirstName = "First Name",
                LastName  = "Last Name"
            };
            var mapper = new PlayerMapper();
            var player = mapper.Map(viewModel);

            Assert.Equal(viewModel.Id, player.Id);
            Assert.Equal(viewModel.FirstName, player.FirstName);
            Assert.Equal(viewModel.LastName, player.LastName);
        }
コード例 #10
0
        public void MapExistingPlayerToPlayerViewModel()
        {
            var player = new Player
            {
                Id        = 2,
                FirstName = "First Name",
                LastName  = "Last Name"
            };
            var mapper    = new PlayerMapper();
            var viewModel = mapper.Map(player);

            Assert.Equal(player.Id, viewModel.Id);
            Assert.Equal(player.FirstName, viewModel.FirstName);
            Assert.Equal(player.LastName, viewModel.LastName);
            Assert.Equal("First Name Last Name", viewModel.FullName);
        }
コード例 #11
0
        public void MapPlayerToPlayerViewModelWithGamesAndGamesOwnedOnly()
        {
            var player = new Player();
            var games  = new List <SelectListItem> {
                new SelectListItem {
                    Value = "1", Text = "Game 1"
                }
            };
            var gamesOwned = new List <GameViewModel> {
                new GameViewModel {
                    Id = 1, Name = "Game 1"
                }
            };
            var mapper    = new PlayerMapper();
            var viewModel = mapper.Map(player, games, gamesOwned);

            Assert.NotNull(viewModel);
            Assert.Equal(1, viewModel.Games.Count());
        }
コード例 #12
0
        public void PlayerMapper_Can_Map_PlayerModel_To_PlayerDto()
        {
            // Arrange
            var mapper      = new PlayerMapper();
            var playerModel = new Player
            {
                Id   = Guid.NewGuid(),
                Name = "PlayerName"
            };

            // Act
            var playerDto = mapper.Map(playerModel);

            // Assert
            playerDto.Should().BeEquivalentTo(playerModel,
                                              properties => properties
                                              .Including(x => x.Id)
                                              .Including(x => x.Name));
        }
コード例 #13
0
        private void addPlayers(IEnumerable <Model.Seven.Player> sevens, IEnumerable <Model.Steam.Player> steams)
        {
            var players = sevens.Join(steams, _7 => _7.SteamId, s => s.SteamId, (_7, s) => PlayerMapper.Map(s, _7)).Select(x => new PlayerViewModel(x)).ToList();

            foreach (var player in players)
            {
                if (Players.Contains(player))
                {
                    Players.Remove(player);
                }

                Players.Add(player);
            }
        }
コード例 #14
0
ファイル: PlayerService.cs プロジェクト: Vladoffz/API-Auth
 public List <PlayerDTO> List()
 {
     return(this.ListEntities().Select(obj => PlayerMapper.Map(obj)).ToList());
 }
コード例 #15
0
ファイル: PlayerService.cs プロジェクト: Vladoffz/API-Auth
 public List <PlayerDTO> FindByFirstName(string FirstName)
 {
     return(this.FindByFirstNameEntity(FirstName).Select(obj => PlayerMapper.Map(obj)).ToList());
 }
コード例 #16
0
        public async Task <PlayerModel> GetPlayerById(string id)
        {
            Player player = await playersApiClient.GetPlayer(id);

            return(PlayerMapper.Map(player));
        }
コード例 #17
0
        public async Task <IReadOnlyCollection <PlayerModel> > GetAllPlayers()
        {
            var players = await playersApiClient.GetAllPlayers();

            return(PlayerMapper.Map(players));
        }
コード例 #18
0
ファイル: PlayerService.cs プロジェクト: Vladoffz/API-Auth
 public List <PlayerDTO> FindByAge(int Age)
 {
     return(this.FindByAgeEntity(Age).Select(obj => PlayerMapper.Map(obj)).ToList());
 }
コード例 #19
0
ファイル: PlayerService.cs プロジェクト: Vladoffz/API-Auth
 public PlayerDTO Get(int ID)
 {
     return(PlayerMapper.Map(this.GetEntity(ID)));
 }