示例#1
0
        /// <summary>
        /// Get list of matches from either store or API of exists
        /// </summary>
        /// <param name="startYear">season year</param>
        /// <param name="teamId">team id</param>
        /// <returns>List of matches</returns>
        public List <Match> GetListOfMatchsFromEitherStoreOrAPI(int startYear, int teamId)
        {
            List <Match> matches = new();

            if (storeData.CheckStoreAlreadyExists(startYear))
            {
                matches = readWrite.ReadFromStore(startYear);
            }

            if (matches.Any(x => x.TeamLogoFileName.Contains(teamId.ToString())))
            {
                return(matches.Where(x => x.TeamLogoFileName.Contains(teamId.ToString())).ToList());
            }
            else
            {
                var apiResult = restClient.GetAllMatchesForSeason(startYear, teamId);
                matches.AddRange(apiResult.Where(x => !matches.Any(y => y.MatchId == x.MatchId)));
                readWrite.WriteToStore(matches, startYear);
                return(matches.Where(x => x.TeamLogoFileName.Contains(teamId.ToString())).ToList());
            }
        }
示例#2
0
        public void ReadFromStoreTestStringNoFileTest()
        {
            var result = readWrite.ReadFromStore("test");

            Assert.IsNull(result);
        }