示例#1
0
        public void Creating_a_game_gives_each_player_the_correct_number_of_units_dependent_on_number_of_players(int numberOfplayers, int numberOfUnplacedUnits, string gameName, Game game)
        {
            var players = new Dictionary<Guid, string>();

            "Given a game name"
                .Given(() => gameName = "Test");

            "And a number of players"
                .And(() =>
                    {
                        for (var i = 1; i <= numberOfplayers; i++)
                        {
                            players.Add(Guid.NewGuid(), "Bryan");
                        }
                    });

            "When a game is created"
                .When(() => game = new Game(gameName, players, new Board(new Dictionary<string, Continent>())));

            "Then the each player should have x number of units"
                .Then(() =>
                    {
                        foreach (var player in game.Players.Values)
                        {
                            player.UnplacedUnits.ShouldBe(numberOfUnplacedUnits);
                        }
                    });
        }
示例#2
0
        public void Creating_a_game_adds_players_to_the_game_and_names_it(int numberOfPlayers, string gameName, Game game)
        {
            var players = new Dictionary<Guid, string>();

            "Given a game name"
                .Given(() => gameName = "Test");

            "And a number of players"
                .And(() =>
                    {
                        for (var i = 1; i <= numberOfPlayers; i++)
                        {
                            players.Add(Guid.NewGuid(), "Bryan");
                        }
                    });

            "When a game is created"
                .When(() => game = new Game(gameName, players, new Board(new Dictionary<string, Continent>())));

            "Then the game is named and players added"
                .Then(() =>
                    {
                        game.Name.ShouldBe(gameName);
                        game.Players.Count.ShouldBe(numberOfPlayers);
                    });
        }
示例#3
0
        public void Creating_a_game_with_only_two_players_adds_a_neutral_army(int numberOfplayers, string gameName, Game game)
        {
            var players = new Dictionary<Guid, string>();

            "Given a game name"
                .Given(() => gameName = "Test");

            "And a number two players"
                .And(() =>
                {
                    for (var i = 1; i <= 2; i++)
                    {
                        players.Add(Guid.NewGuid(), "Bryan");
                    }
                });

            "When a game is created"
                .When(() => game = new Game(gameName, players, new Board(new Dictionary<string, Continent>())));

            "Then one neutral should be added with 40 unplaced units"
                .Then(() =>
                    {
                        var neutralPlayers = game.Players.Values.Where(p => p.IsNeutral).ToList();
                        neutralPlayers.Count().ShouldBe(1);
                        neutralPlayers.First().UnplacedUnits.ShouldBe(40);
                    });
        }