Exemplo n.º 1
0
        public void PlayTournamentGameTest()
        {
            // Arrange
            const string cupName  = "Bengans Cup3";
            const int    expected = 1;

            var adapter           = new MemberAdapter();
            var tournamentManager = TestHelper.CreateTournamentManager();

            tournamentManager.CreateTournament(cupName,
                                               DateTime.Now.AddYears(-1),
                                               DateTime.Now.AddDays(-60).AddYears(-1)
                                               );

            var members = TestHelper.SeedMembers().Take(2).ToList();
            var players = new List <Player>();

            foreach (var member in members)
            {
                players.Add(adapter.ConvertMemberToPlayer(member));
            }

            var gameManager = TestHelper.CreateGameManager(players);

            // Act
            gameManager.PlayTournamentGame(members, cupName);

            // Assert
            var tournamentGames = tournamentManager.GetTournament(cupName).Games;
            int actual          = tournamentGames.Count;

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 2
0
        private List <Player> ConvertMembersToPlayerList(List <Member> contestants)
        {
            var players = new List <Player>();

            foreach (Member member in contestants)
            {
                players.Add(_memberAdapter.ConvertMemberToPlayer(member));
            }

            return(players);
        }
Exemplo n.º 3
0
        public static void PlayTournamentGame(List <Member> members, string cupName)
        {
            var _memberAdapter = new MemberAdapter();
            var players        = new List <Player>();

            foreach (var member in members)
            {
                players.Add(_memberAdapter.ConvertMemberToPlayer(member));
            }

            var _gameManager = CreateGameManager(players);

            _gameManager.PlayTournamentGame(members, cupName);
        }
Exemplo n.º 4
0
        public void PlayGame()
        {
            // Arrange
            const string expected = "John Doe";

            var members = TestHelper.SeedMembers().Take(2);
            var adapter = new MemberAdapter();
            var players = members.Select(member => adapter.ConvertMemberToPlayer(member)).ToList();

            var _gameManager = TestHelper.CreateGameManager(players);

            // Act
            var game = _gameManager.PlayGame(TestHelper.SeedMembers());

            // Assert
            string actual = game.Winner.Name;

            Assert.AreEqual(expected, actual);
        }