public TeamSelection SelectStartingTeamForGameweek(IList<PredictedPlayerScore> predictedPlayerScores)
        {
            if(predictedPlayerScores.Count != 15)throw new Exception("Incorrect number of players to select starting team from");

            var selection = new TeamSelection
                                {
                                    Team = SelectTeam(predictedPlayerScores)
                                };
            selection.PredictedTotalTeamScore = CalculatePredictedTeamScore(
                predictedPlayerScores.ToDictionary(ps => ps.Player.Id, ps => ps.PredictedScore),
                selection.Team);

            return selection;
        }
        public static void LogTeamSelection(TeamSelection teamSelection, int gameweek, List<PredictedPlayerScore> predictedPlayerPoints, ILogger logger, bool important = false)
        {
            logger.Log(Tag.Prediction, string.Format("Selected team for gameweek {0}", gameweek), important);
            logger.Log(Tag.Prediction, string.Format("Predicted points: {0}", teamSelection.PredictedTotalTeamScore.ToFormatted()), important);
            LogTeamFormation(teamSelection.Team, logger);

            for (var i = 0; i < teamSelection.Team.Players.Count; i++)
            {
                if (i == 11)
                {
                    logger.Log(Tag.Team, "---");
                }

                var player = teamSelection.Team.Players[i];
                var fixtures = player.FutureFixtures.Where(x => x.GameWeek == gameweek);
                var extraData = new StringBuilder(" ");
                foreach (var fixture in fixtures)
                {
                    extraData.Append(fixture.OppositionClubCode);
                    extraData.Append(fixture.Home ? "(H) " : "(A) ");
                }
                var playerGameweekPoints = predictedPlayerPoints.Single(p => p.Player == player).PredictedScore;
                extraData.Append(playerGameweekPoints.ToFormatted());
                if (teamSelection.Team.Captain == player)
                {
                    extraData.Append("(");
                    extraData.Append((playerGameweekPoints * 2).ToFormatted());
                    extraData.Append(")");
                }

                LogPlayer(player, teamSelection.Team, logger, extraData.ToString(), important);
            }

            LogTeamCost(teamSelection.Team, logger, important);
        }
        public void team_gameweek_selection_calculates_team_gameweek_selection_predicts_scores_for_gameweek()
        {
            // Arrange
            var teamSelection = new TeamSelection { Team = new Team() };
            _teamGameweekSelectorMock.Setup(
                x => x.SelectStartingTeamForGameweek(It.IsAny<IList<PredictedPlayerScore>>())).Returns(teamSelection);

            // Act
            _complexStrategy.PickGameweekTeam(_seasonState);

            // Assert
            foreach(var player in _team.Players)
            {
                Player player1 = player;
                _playerScorePredictorMock.Verify(x => x.PredictPlayerGameweekPoints(player1, _gameweek, _allPlayers));
            }
        }
        public void team_gameweek_selection_uses_team_selector_to_select_team()
        {
            // Arrange
            var teamSelection = new TeamSelection{Team = new Team()};

            _playerScorePredictorMock.Setup(
                x => x.PredictPlayerGameweekPoints(It.IsAny<Player>(), It.IsAny<int>(), It.IsAny<IList<Player>>())).
                Returns((Player p, int gameweek, IList<Player> allPlayers) => p.Id);

            _teamGameweekSelectorMock.Setup(
                x => x.SelectStartingTeamForGameweek(It.Is<IList<PredictedPlayerScore>>(ps => ps.All(p => (int)p.PredictedScore == p.Player.Id)))).Returns(
                    teamSelection);

            // Act
            var selectedTeam = _complexStrategy.PickGameweekTeam(_seasonState);

            // Assert
            Assert.That(teamSelection.Team, Is.EqualTo(selectedTeam));
        }
        public void SetUp()
        {
            _gameweek = 1;

            _team = TeamCreationHelper.CreateTestTeam();

            _allPlayers = TeamCreationHelper.CreatePlayerList(10, 10, 10, 10);

            _teamSelectorMock = new Mock<ITeamGameweekSelector>();
            _teamSelection = CreateSelectorResult();
            _teamSelectorMock.Setup(x => x.SelectStartingTeamForGameweek(It.IsAny<IList<PredictedPlayerScore>>())).Returns(_teamSelection);

            _playerScorePredictorMock = new Mock<IPlayerScorePredictor>();

            _teamScorePredictorMock = new Mock<TeamScorePredictor>(_teamSelectorMock.Object, new Mock<ILogger>().Object, _playerScorePredictorMock.Object){CallBase = true};
        }
        private static TeamSelection CreateSelectorResult()
        {
            var teamSelectorResult = new TeamSelection
            {
                Team = TeamCreationHelper.CreateTestTeam()
            };

            return teamSelectorResult;
        }