Beispiel #1
0
        public void NoArgumentSpecified()
        {
            var gameRuleService = new GameRuleService();
            var args            = new string[] { };

            var actual   = gameRuleService.InitializeRules(args);
            var expected = new GameRules {
                NumberOfPlayers = 2, DeckSize = 40
            };

            Assert.Equal(expected.DeckSize, actual.DeckSize);
            Assert.Equal(expected.NumberOfPlayers, actual.NumberOfPlayers);
            Assert.Equal(expected.EnableSuits, actual.EnableSuits);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            try
            {
                var gameRuleService = new GameRuleService();
                var gameRules       = gameRuleService.InitializeRules(args);

                var cardGameService = new CardGameService(gameRules);
                cardGameService.StartGame();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Beispiel #3
0
        public void WrongArgumentSpecified()
        {
            var gameRuleService = new GameRuleService();
            var args            = new string[] { "--suits", "true", "--size", "80", "--players", "wrong!!!" };

            Exception exception = null;

            try
            {
                gameRuleService.InitializeRules(args);
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            Assert.NotNull(exception);
        }
Beispiel #4
0
        public void OneArgumentSpecified()
        {
            var gameRuleService = new GameRuleService();
            var args            = new string[] { "--suits", "spade", "diamond", "heart", "club" };

            var actual   = gameRuleService.InitializeRules(args);
            var expected = new GameRules
            {
                NumberOfPlayers = 2,
                DeckSize        = 40,
                Suits           = new List <string> {
                    "spade", "diamond", "heart", "club"
                }
            };

            Assert.Equal(expected.DeckSize, actual.DeckSize);
            Assert.Equal(expected.NumberOfPlayers, actual.NumberOfPlayers);
            Assert.Equal(expected.EnableSuits, actual.EnableSuits);
        }