public void GetShouldReturnTournamentWithNameWhenMatchInfoContainsInnerText()
        {
            HtmlNode matchInfo = HtmlNodesLoader.Load("<div><div class='__app-PromoMatchBody-tournament promoMatchBody__tournament___1M0Aj'>TournamentName</div></div>");

            TournamentFeedModel tournament = tournamentsProvider.Get(matchInfo);

            Assert.IsFalse(string.IsNullOrEmpty(tournament.Name));
        }
        public void GetShouldReturnTournamentWithoutNameWhenMatchInfoIsInvalid()
        {
            HtmlNode matchInfo = HtmlNodesLoader.Load("<div></div>");

            TournamentFeedModel tournament = tournamentsProvider.Get(matchInfo);

            Assert.IsTrue(string.IsNullOrEmpty(tournament.Name));
        }
Example #3
0
        public TournamentFeedModel Get(HtmlNode matchInfo)
        {
            HtmlNode node = matchInfo?.SelectSingleNode(TournamentXPaths.NODE);
            string   name = WebUtility.HtmlDecode(node?.InnerText);

            TournamentFeedModel tournament = ObjectFactory.CreateTournament(name);

            return(tournament);
        }
Example #4
0
        public MatchFeedModel Get(HtmlNode matchContainer)
        {
            HtmlNode matchInfo = matchContainer.SelectSingleNode(MatchXPaths.HEADER_INFO_BOX);

            MatchFeedType type = GetType(matchInfo);
            IEnumerable <TeamFeedModel> teams      = teamsProvider.Get(matchContainer);
            TournamentFeedModel         tournament = tournamentsProvider.Get(matchInfo);

            MatchFeedModel match = ObjectFactory.CreateMatch(type, teams.First(), teams.Last(), tournament);

            match.Markets = marketsProvider.Get(matchContainer, match);

            return(match);
        }
Example #5
0
        public string Manage(TournamentFeedModel feedModel)
        {
            TournamentByNameQuery query      = new TournamentByNameQuery(feedModel.Name);
            Tournament            tournament = queryDispatcher.Dispatch <TournamentByNameQuery, Tournament>(query);

            if (tournament != null)
            {
                return(tournament.Id);
            }

            CreateTournamentCommand command = Mapper.Map <CreateTournamentCommand>(feedModel);
            string tournamentId             = commandDispatcher.Dispatch <CreateTournamentCommand, string>(command);

            return(tournamentId);
        }
Example #6
0
 public static MatchFeedModel CreateMatch(MatchFeedType type, TeamFeedModel homeTeam, TeamFeedModel awayTeam, TournamentFeedModel tournament)
 {
     return(new MatchFeedModel()
     {
         Type = type,
         HomeTeam = homeTeam,
         AwayTeam = awayTeam,
         Tournament = tournament
     });
 }
        public void GetShouldReturnTournamentWithoutNameWhenMatchInfoIsNull()
        {
            TournamentFeedModel tournament = tournamentsProvider.Get(null);

            Assert.IsTrue(string.IsNullOrEmpty(tournament.Name));
        }