Esempio n. 1
0
        public void Returns_Players_Based_On_Settings()
        {
            var ai           = new MockIntelligence();
            var gameSettings = new GameSettings {
                GamePlayerType  = GamePlayerType.HumanVsComputer,
                PlayerStartType = PlayerStartType.LastPlayerFirst,
                PlayerSettings  = new List <PlayerSettings> {
                    new PlayerSettings {
                        Name   = "John Doe",
                        Symbol = '@'
                    },
                    new PlayerSettings {
                        Name   = "Jane Doe",
                        Symbol = '#'
                    }
                }
            };
            var factory = BuildPlayersFactory();

            var players = factory.Create(gameSettings, ai);

            players.Count().Should().Be(2);
            var first = players.First();

            first.Should().BeOfType <ComputerPlayer>();
            first.Name.Should().Be("John Doe");
            first.Symbol.Should().Be('@');
            var last = players.Last();

            last.Should().BeOfType <HumanPlayer>();
            last.Name.Should().Be("Jane Doe");
            last.Symbol.Should().Be('#');
        }
Esempio n. 2
0
        public void Throws_Exception_With_Invalid_Game_Player_Type()
        {
            var ai           = new MockIntelligence();
            var gameSettings = new GameSettings();
            var factory      = BuildPlayersFactory();

            Action action = () => factory.Create(gameSettings, ai);

            action.ShouldThrow <ArgumentException>();
        }
Esempio n. 3
0
        public void Returns_Computer_vs_Computer_Last_Computer_Goes_First()
        {
            var ai           = new MockIntelligence();
            var gameSettings = new GameSettings {
                GamePlayerType  = GamePlayerType.ComputerVsComputer,
                PlayerStartType = PlayerStartType.LastPlayerFirst
            };
            var factory = BuildPlayersFactory();

            var players = factory.Create(gameSettings, ai);

            players.Count().Should().Be(2);
            players.First().Should().BeOfType <ComputerPlayer>();
            players.Last().Should().BeOfType <ComputerPlayer>();
        }
Esempio n. 4
0
        public void Returns_Human_vs_Human_First_Human_Goes_First()
        {
            var ai           = new MockIntelligence();
            var gameSettings = new GameSettings {
                GamePlayerType  = GamePlayerType.HumanVsHuman,
                PlayerStartType = PlayerStartType.FirstPlayerFirst
            };
            var factory = BuildPlayersFactory();

            var players = factory.Create(gameSettings, ai);

            players.Count().Should().Be(2);
            players.First().Should().BeOfType <HumanPlayer>();
            players.Last().Should().BeOfType <HumanPlayer>();
        }
Esempio n. 5
0
        public void Creates_New_Game_With_Players()
        {
            var ai             = new MockIntelligence();
            var gameSettings   = BuildGameSettings();
            var aiFactory      = new MockIntelligenceFactory().CreateStubbedToReturn(ai);
            var playersFactory = new MockPlayersFactory().CreateStubbedToReturn(new List <IPlayer> {
                new MockPlayer()
            });
            var initializer = BuildGameInitializer(playersFactory, aiFactory: aiFactory);

            var game = initializer.Create(gameSettings);

            game.Should().NotBeNull();
            game.Board.Size.Should().Be(3);
            game.Players.Count().Should().Be(1);
            playersFactory.VerifyCreatedCalled(gameSettings, ai);
        }