예제 #1
0
        public ScoreBoardServiceTest()
        {
            MatchInitialize initialize = new MatchInitialize();

            _currentMatch = initialize.GetCurrentMatchDetails();
            striker       = _currentMatch.Players.First(t => t.IsOnField);
            nonStriker    = _currentMatch.Players.Last(t => t.IsOnField);
            _currentMatch.BallsRemaining = _currentMatch.OversLeft * 6;
        }
예제 #2
0
        public MatchServiceTest()
        {
            _playerScoreHelper = new Mock <IPlayerScoreHelper>();
            MatchInitialize initialize = new MatchInitialize();

            _currentMatch = initialize.GetCurrentMatchDetails();
            striker       = _currentMatch.Players.First(t => t.IsOnField);
            nonStriker    = _currentMatch.Players.Last(t => t.IsOnField);
            _currentMatch.BallsRemaining = _currentMatch.OversLeft * 6;

            target = new MatchService(_playerScoreHelper.Object);
        }
예제 #3
0
        public void MultiPlayersStrikeProbalility_Verify()
        {
            MatchInitialize initialize   = new MatchInitialize();
            var             currentMatch = initialize.GetCurrentMatchDetails();

            PlayerScoreHelper playerScoreHelper = new PlayerScoreHelper();

            foreach (var player in currentMatch.Players)
            {
                playerScoreHelper.BuildCumulativeDistribution(player);
            }
            Dictionary <string, List <int> > playerScores = new Dictionary <string, List <int> >();

            for (int i = 0; i < 10000; i++)
            {
                foreach (var player in currentMatch.Players)
                {
                    var score = player.Strike();
                    if (playerScores.ContainsKey(player.Name))
                    {
                        var scores = playerScores[player.Name];
                        scores.Add(score);
                        playerScores[player.Name] = scores;
                    }
                    else
                    {
                        playerScores.Add(player.Name, new List <int> {
                            score
                        });
                    }
                }
            }

            Assert.Contains(playerScores["Pravin"].Where(t => t == 0).Count() / 100, new double[] { 5, 4, 6 });
            Assert.Contains(playerScores["Irfan"].Where(t => t == 0).Count() / 100, new double[] { 9, 10, 11 });
            Assert.Contains(playerScores["Jalindar"].Where(t => t == 0).Count() / 100, new double[] { 19, 20, 21 });
            Assert.Contains(playerScores["Vaishali"].Where(t => t == 0).Count() / 100, new double[] { 29, 30, 31 });
        }