Exemplo n.º 1
0
        AssertThatGetCurrentBetsAndScheduledMatchesCallsFindBetsByUseAndReturnsOnlyScheduledBetsAndMatch()
        {
            _betDao.FindBetsByUser(Arg.Any <User>()).Returns(Task.FromResult(_betsByUser));
            _teamDao.FindTeam(Arg.Any <int>()).Returns(Task.FromResult(_team));
            _matchDao.FindMatch(Arg.Any <int>()).Returns(Task.FromResult(_matchScheduled));
            _matchDao.FindByStatus(Match.ScheduledStatus).Returns(Task.FromResult(_matchesScheduled));

            var currentBetsAndMatch = await _betManager.GetCurrentBetsAndScheduledMatches(_user, 2001);

            await _betDao.Received().FindBetsByUser(Arg.Any <User>());

            await _teamDao.Received().FindTeam(Arg.Any <int>());

            await _matchDao.Received().FindMatch(Arg.Any <int>());

            await _matchDao.Received().FindByStatus(Arg.Any <string>());

            var bets    = currentBetsAndMatch.Bets as List <Bet>;
            var matches = currentBetsAndMatch.Matches as List <Match>;

            Assert.IsNotEmpty(bets, "bets empty");
            Assert.IsTrue(bets.All(b => b.Match.Status == Match.ScheduledStatus));
            Assert.IsTrue(bets.All(b => b.Match.Competition.Id == 2001));

            Assert.IsNotEmpty(matches, "matches empty");
            Assert.IsTrue(matches.All(m => m.Status == Match.ScheduledStatus));
            Assert.IsTrue(matches.All(m => m.Competition.Id == 2001));
        }
        public async Task GetAllTeams()
        {
            try
            {
                Console.WriteLine("     ----- Begin Fetch teams ----- ");
                var availableCompetitions = Competition.AvailableCompetitions;
                foreach (var availableCompetition in availableCompetitions)
                {
                    var response = await _http.GetAsync("competitions/" + availableCompetition + "/teams");

                    var responseContent = await response.Content.ReadAsStringAsync();

                    var json      = JObject.Parse(responseContent);
                    var jsonTeams = json["teams"];
                    var teams     = JsonConvert.DeserializeObject <List <Team> >(JsonConvert.SerializeObject(jsonTeams));

                    foreach (var team in teams)
                    {
                        var findTeam = _teamDao.FindTeam(team.Id).Result;
                        if (findTeam == null)
                        {
                            Console.WriteLine("Add team " + team.Id + " " + team.Name);
                            _teamDao.AddTeam(team);
                        }
                        else
                        {
                            Console.WriteLine("Replace team " + team.Id + " " + team.Name);
                            _teamDao.ReplaceTeam(findTeam.Id, team);
                        }
                    }

                    Thread.Sleep(10000);
                }

                Console.WriteLine("     ----- End Fetch teams ----- ");
            }
            catch (Exception e)
            {
                SingletonManager.Instance.EmailManager.SendWebMasterEmail(e);
                throw;
            }
        }
Exemplo n.º 3
0
 public void AssertThatFindTeamIsCalled()
 {
     _teamDao.FindTeam(1);
     _filterExpression = new ExpressionFilterDefinition <Team>(team => team.Id == _team.Id);
     _collection.Received().Find(_filterExpression);
 }
Exemplo n.º 4
0
        public async Task <List <Bet> > GetFinishBets(User user, int competitionId)
        {
            var betsByUser = await _betDao.FindBetsByUser(user);

            foreach (var bet in betsByUser)
            {
                var matchInformation = await _matchDao.FindMatch(bet.Match.Id);

                bet.Match = matchInformation;
                var awayTeamInformation = await _teamDao.FindTeam(bet.Match.AwayTeam.Id);

                if (awayTeamInformation != null)
                {
                    bet.Match.AwayTeam = awayTeamInformation;
                }
                var homeTeamInformation = await _teamDao.FindTeam(bet.Match.HomeTeam.Id);

                if (homeTeamInformation != null)
                {
                    bet.Match.HomeTeam = homeTeamInformation;
                }
            }

            var betsByCompetition = betsByUser.FindAll(bet => bet.Match.Competition.Id == competitionId);
            var betsByMatchStatus = betsByCompetition.FindAll(bet => bet.Match.Status == Match.FinishedStatus);

            return(betsByMatchStatus);
        }