public LeagueResult FindWinningTeam(FileOutput fileOutput)
        {
            IList <LeagueResult> leagueResults = _leagueResultParser.ReadIntoLeagueResults(fileOutput.HeaderColumnList, fileOutput.DataRows);
            LeagueResult         winningTeam   = FindWinningTeam(leagueResults);

            return(winningTeam);
        }
예제 #2
0
        public IList <LeagueResult> ReadIntoLeagueResults(IList <string> headerColumnList, IList <string> dataRows)
        {
            int indexOfTeamCol    = GetIndexOfColumn(headerColumnList, Constants.ColTeamName);
            int indexOfForCol     = GetIndexOfColumn(headerColumnList, Constants.ColFor);
            int indexOfAgainstCol = GetIndexOfColumn(headerColumnList, Constants.ColAgainst);

            List <LeagueResult> leagueResults = new List <LeagueResult>();

            foreach (string dataRow in dataRows)
            {
                List <string> dataRowValues = dataRow.Split(_configReader.Delimiter.ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList();
                if (!_validator.ValidateDataRowValues(dataRowValues, indexOfTeamCol, indexOfForCol, indexOfAgainstCol))
                {
                    continue;
                }
                var leagueResult = new LeagueResult
                {
                    TeamName     = dataRowValues[indexOfTeamCol].Trim(),
                    GoalsFor     = int.Parse(dataRowValues[indexOfForCol]),
                    GoalsAgainst = int.Parse(dataRowValues[indexOfAgainstCol])
                };

                leagueResults.Add(leagueResult);
            }

            return(leagueResults);
        }