public NflPlayerService(IHtmlParserProvider htmlParserProvider, IEspnHtmlTrimService espnHtmlTrimService, IUrlConfigurationProvider urlConfigurationProvider) { _cache = new Dictionary <int, string>(); _htmlParserProvider = htmlParserProvider; _espnHtmlTrimService = espnHtmlTrimService; _urlConfigurationProvider = urlConfigurationProvider; }
public async Task Should_GetScoreboardAsync_ForValidInput() { //arrange int leagueId = 555555; int year = 2018; IHttpProvider httpProvider = A.Fake <IHttpProvider>(); IUrlConfigurationProvider urlConfigurationProvider = A.Fake <IUrlConfigurationProvider>(); IFantasyFootballService fantasyFootballService = new EspnApiFantasyFootballService(httpProvider, urlConfigurationProvider); //act LeagueScoreboard leagueScoreboard = await fantasyFootballService.GetScoreboardAsync(leagueId, year); //assert A.CallTo(() => urlConfigurationProvider.GetScoreboardEndpoint(leagueId, year)).MustHaveHappened(); A.CallTo(() => httpProvider.GetAsync <LeagueScoreboard>(null)).WithAnyArguments().MustHaveHappened(); }
public async Task Should_GetRecentActivityAsync_ForValidInput() { //arrange int leagueId = 555555; int year = 2018; IHttpProvider httpProvider = A.Fake <IHttpProvider>(); IUrlConfigurationProvider urlConfigurationProvider = A.Fake <IUrlConfigurationProvider>(); INflPlayerService nflPlayerService = A.Fake <INflPlayerService>(); IFantasyFootballService fantasyFootballService = new EspnApiFantasyFootballService(httpProvider, urlConfigurationProvider); //act RecentActivity recentActivity = await fantasyFootballService.GetRecentActivity(leagueId, year); //assert A.CallTo(() => urlConfigurationProvider.GetRecentActivityEndpoint(leagueId, year)).MustHaveHappened(); A.CallTo(() => httpProvider.GetAsync <RecentActivity>(null)).WithAnyArguments().MustHaveHappened(); }
public async Task Should_GetPlayerNameForId_ForStandardInput() { //arrange int playerId = 55555; string url = "http://www.espn.com/nfl/player/_/id/55555"; string xPath = "//head/title"; IHtmlParserProvider htmlParserProvider = A.Fake <IHtmlParserProvider>(); A.CallTo(() => htmlParserProvider.getInnerTextForFirstXPathMatch(url, xPath)).Returns("Emmanuel Sanders Stats, News, Bio | ESPN"); IEspnHtmlTrimService espnHtmlTrimService = A.Fake <IEspnHtmlTrimService>(); A.CallTo(() => espnHtmlTrimService.TrimNameFromTitleTag("Emmanuel Sanders Stats, News, Bio | ESPN")).Returns("Emmanuel Sanders"); IUrlConfigurationProvider urlConfigurationProvider = A.Fake <IUrlConfigurationProvider>(); A.CallTo(() => urlConfigurationProvider.GetNflPlayerEndpoint(playerId)).Returns(url); NflPlayerService nflPlayerService = new NflPlayerService(htmlParserProvider, espnHtmlTrimService, urlConfigurationProvider); //act string playerName = await nflPlayerService.GetPlayerNameForId(55555); //assert playerName.Should().BeEquivalentTo("Emmanuel Sanders"); }
public EspnApiFantasyFootballService(IHttpProvider httpProvider, IUrlConfigurationProvider urlConfigurationProvider) { _httpProvider = httpProvider; _urlConfigurationProvider = urlConfigurationProvider; }