Beispiel #1
0
        public void GenerateTeamsWithNotEnoughPlayers_GeneratesEmptyList()
        {
            var teams = TeamsGenerator.Generate(new List <Player> {
                new Player("test")
            });

            Assert.False(teams.Any());
        }
Beispiel #2
0
        public void GenerateTeams_GeneratesCorrectTeams()
        {
            var teams       = TeamsGenerator.Generate(TestPlayerSet.Get());
            var minDelta    = teams.Min(v => Math.Abs(v[0].AverageRating - v[1].AverageRating));
            var optimalTeam = teams.First(v => minDelta == Math.Abs(v[0].AverageRating - v[1].AverageRating));

            Assert.Equal(77.6, optimalTeam[0].AverageRating);
            Assert.Equal(77.8, optimalTeam[1].AverageRating);
        }
        public async Task GenerateNewTeams(IEnumerable <string> playersNames)
        {
            IsActiveDisliked = false;
            GeneratePollId();
            _likesForActive    = 0;
            _dislikesForActive = 0;

            var playersReadyToPlay = (await _playerRepository.GetAllAsync())
                                     .Where(p => playersNames.Contains(p.Name)).ToList();

            playersReadyToPlay.AddRange(playersNames
                                        .Where(n => !playersReadyToPlay.Any(p => p.Name == n))
                                        .Select(n => new Player(n)));

            _teamSets = TeamsGenerator.Generate(playersReadyToPlay);
            SetActive(GetRandom());
        }
 public void Init()
 {
     _target = new TeamsGenerator();
 }