Exemplo n.º 1
0
        public void PlayMatchWithOneTeam()
        {
            SetupFootballMatchTests(out List <Team> teams, out FootballMatchFactory matchFactory, out HistoryLeagueStats leagueStats);
            var          potentialOutcomeCalculator = new PoissonPotentialOutcomeCalculator(new PoissonEvaluator(), new PoissonEvaluator());
            var          match        = new MatchHandler(matchFactory, potentialOutcomeCalculator);
            MatchRequest matchRequest = matchFactory.CreateRequest(new List <Team> {
                teams.FirstOrDefault()
            }, leagueStats);
            var result = match.Handle(matchRequest);

            Assert.IsTrue(result.Scores.GetValueOrDefault(teams[0]) == 3);
            Assert.IsTrue(result.winner.TeamName == teams[0].TeamName);
            Assert.IsTrue(result.winRemarks.Name == "WinByDefault");
            Assert.IsTrue(result.GetType() == typeof(MatchResult));
        }
Exemplo n.º 2
0
        public void PlayNormalMatch()
        {
            SetupFootballMatchTests(out List <Team> teams, out FootballMatchFactory matchFactory, out HistoryLeagueStats leagueStats);
            var potentialOutcomeCalculator = new PoissonPotentialOutcomeCalculator(new PoissonEvaluator(), new PoissonEvaluator());

            var          match        = new MatchHandler(matchFactory, potentialOutcomeCalculator);
            MatchRequest matchRequest = matchFactory.CreateRequest(teams, leagueStats);
            var          result       = match.Handle(matchRequest);

            if (result.Scores.GetValueOrDefault(teams[0]) == result.Scores.GetValueOrDefault(teams[1]))
            {
                Assert.IsTrue(result.Scores.GetValueOrDefault(teams[0]) == result.Scores.GetValueOrDefault(teams[1]), "Tie match");
                Assert.IsTrue(result.winner == null, "No winner of the match");
            }
            Assert.IsTrue(result.winRemarks.Name == "NoRemarks");
            Assert.IsTrue(result.GetType() == typeof(MatchResult));
        }