Пример #1
0
        public void GetTwoPairs_TwoPairsAndThreeOfAKind_SumOfTwoScorePairs()
        {
            Yatzy instance = new Yatzy(6, 6, 1, 1, 1);
            int   actual   = instance.GetTwoPairs();

            Assert.Equal(14, actual);
        }
Пример #2
0
        public void GetYatzy_OnlyFourOfAKind_Zero()
        {
            Yatzy instance = new Yatzy(4, 1, 4, 4, 4);
            int   actual   = instance.GetYatzy();

            Assert.Equal(0, actual);
        }
Пример #3
0
        public void GetTwos_SumOfAllTwos()
        {
            Yatzy instance = new Yatzy(1, 2, 3, 2, 6);
            int   actual   = instance.GetTwos();

            Assert.Equal(4, actual);
        }
Пример #4
0
        public void GetThreeOfAKind_SumOfThreeEqualScores()
        {
            Yatzy instance = new Yatzy(5, 3, 5, 4, 5);
            int   actual   = instance.GetThreeOfAKind();

            Assert.Equal(15, actual);
        }
Пример #5
0
        public void GetYatzy_Return50()
        {
            Yatzy instance = new Yatzy(6, 6, 6, 6, 6);
            int   actual   = instance.GetYatzy();

            Assert.Equal(50, actual);
        }
Пример #6
0
        public void GetSumOfAllScores_SumOfAllScores()
        {
            Yatzy instance = new Yatzy(2, 3, 4, 5, 1);
            int   actual   = instance.GetSumOfAllScores();

            Assert.Equal(15, actual);
        }
Пример #7
0
        public void GetOnePair_SumOfLargestScorePair()
        {
            Yatzy instance = new Yatzy(5, 3, 6, 6, 5);
            int   actual   = instance.GetOnePair();

            Assert.Equal(12, actual);
        }
Пример #8
0
        public void GetLargeStraight_SumOfFiveScoresInARow()
        {
            Yatzy instance = new Yatzy(2, 3, 4, 5, 6);
            int   actual   = instance.GetLargeStraight();

            Assert.Equal(20, actual);
        }
Пример #9
0
        public void GetFullHouse_SumOfTwoAndThreeOfAKind()
        {
            Yatzy instance = new Yatzy(6, 2, 2, 2, 6);
            int   actual   = instance.GetFullHouse();

            Assert.Equal(18, actual);
        }
Пример #10
0
        public void GetSmallStraight_SumOfFiveScoresInARow()
        {
            Yatzy instance = new Yatzy(2, 3, 4, 5, 1);
            int   actual   = instance.GetSmallStraight();

            Assert.Equal(15, actual);
        }
Пример #11
0
        public void GetSmallStraight_NoStraight_Zero()
        {
            Yatzy instance = new Yatzy(2, 3, 1, 5, 1);
            int   actual   = instance.GetSmallStraight();

            Assert.Equal(0, actual);
        }
Пример #12
0
        public void GetOnes_SumOfAllOnes()
        {
            Yatzy instance = new Yatzy(1, 2, 1, 4, 5);
            int   actual   = instance.GetOnes();

            Assert.Equal(2, actual);
        }
Пример #13
0
        public void GetTwoPairs_NoPairs_Zero()
        {
            Yatzy instance = new Yatzy(5, 4, 3, 2, 1);
            int   actual   = instance.GetTwoPairs();

            Assert.Equal(0, actual);
        }
Пример #14
0
        public void GetTwoPairs_TwoIdenticalPairs_Zero()
        {
            Yatzy instance = new Yatzy(3, 3, 3, 4, 3);
            int   actual   = instance.GetTwoPairs();

            Assert.Equal(0, actual);
        }
Пример #15
0
        public void GetThrees_SumOfAllThrees()
        {
            Yatzy instance = new Yatzy(1, 2, 3, 2, 3);
            int   actual   = instance.GetThrees();

            Assert.Equal(6, actual);
        }
Пример #16
0
        public void GetFullHouse_AllScoresAreTheSame_Zero()
        {
            Yatzy instance = new Yatzy(2, 2, 2, 2, 2);
            int   actual   = instance.GetFullHouse();

            Assert.Equal(0, actual);
        }
Пример #17
0
        public void GetFives_SumOfAllFives()
        {
            Yatzy instance = new Yatzy(4, 4, 5, 5, 5);
            int   actual   = instance.GetFives();

            Assert.Equal(15, actual);
        }
Пример #18
0
        public void GetFullHouse_OnlyThreeOfAKind_Zero()
        {
            Yatzy instance = new Yatzy(2, 2, 2, 3, 4);
            int   actual   = instance.GetFullHouse();

            Assert.Equal(0, actual);
        }
Пример #19
0
        public void GetSixes_SumOfAllSixes()
        {
            Yatzy instance = new Yatzy(6, 5, 6, 6, 5);
            int   actual   = instance.GetSixes();

            Assert.Equal(18, actual);
        }
Пример #20
0
        public void GetFullHouse_NoFullHouse_Zero()
        {
            Yatzy instance = new Yatzy(6, 5, 1, 3, 4);
            int   actual   = instance.GetFullHouse();

            Assert.Equal(0, actual);
        }
Пример #21
0
        public void GetOnePair_NoPair_Zero()
        {
            Yatzy instance = new Yatzy(1, 2, 3, 4, 5);
            int   actual   = instance.GetOnePair();

            Assert.Equal(0, actual);
        }
Пример #22
0
        public void GetTwos_AllScoresAreTwos_SumOfAllTwos()
        {
            Yatzy instance = new Yatzy(2, 2, 2, 2, 2);
            int   actual   = instance.GetTwos();

            Assert.Equal(10, actual);
        }
Пример #23
0
        public void GetFourOfAKind_SumOfFourEqualScores()
        {
            Yatzy instance = new Yatzy(5, 5, 5, 4, 5);
            int   actual   = instance.GetFourOfAKind();

            Assert.Equal(20, actual);
        }
Пример #24
0
 public void Test_1s()
 {
     Assert.True(Yatzy.Ones(1, 2, 3, 4, 5) == 1);
     Assert.Equal(2, Yatzy.Ones(1, 2, 1, 4, 5));
     Assert.Equal(0, Yatzy.Ones(6, 2, 2, 4, 5));
     Assert.Equal(4, Yatzy.Ones(1, 2, 1, 1, 1));
 }
Пример #25
0
        public void YatzyShouldReturn50Or0(List <int> rolledDice, int expectedOutcome)
        {
            var yatzy  = new Yatzy();
            var result = yatzy.CalculateScore(rolledDice);

            Assert.Equal(expectedOutcome, result);
        }
Пример #26
0
        public void Chance_scores_sum_of_all_dice()
        {
            int expected = 15;
            int actual   = Yatzy.Chance(2, 3, 4, 5, 1);

            Assert.Equal(expected, actual);
            Assert.Equal(16, Yatzy.Chance(3, 3, 4, 5, 1));
        }
Пример #27
0
        static void Main(string[] args)
        {
            Console.SetWindowSize(110, 45);

            Menu.ShowIntro();


            bool playAgain = true;

            while (playAgain)
            {
                Console.Clear();
                Menu.ShortIntro();

                Menu.ShowMenu();
                int choiceOfGame = Menu.Input(8);
                Console.Clear();
                switch (choiceOfGame)
                {
                case 0:
                    Console.WriteLine("Tack för den här gången. Välkommen åter!");
                    playAgain = false;
                    break;

                case 1:
                    BattleShipGame.PlayBattleShip();
                    break;

                case 2:
                    Yatzy.PlayYatzy();
                    break;

                case 3:
                    HangMan.PlayHangMan();
                    break;

                case 4:
                    SecretCodeGame.PlaySecretCode();
                    break;

                case 5:
                    FlappyBirdGame.PlayFlappyBird();
                    break;

                case 6:
                    SnakeGame.PlaySnake();
                    break;

                case 7:
                    Highscore.RunHighscore();
                    break;

                default:
                    break;
                }
            }
            Console.ReadLine();
        }
Пример #28
0
        public void Yatzy_scores_50()
        {
            int expected = 50;
            int actual   = Yatzy.yatzy(4, 4, 4, 4, 4);

            Assert.Equal(expected, actual);
            Assert.Equal(50, Yatzy.yatzy(6, 6, 6, 6, 6));
            Assert.Equal(0, Yatzy.yatzy(6, 6, 6, 6, 3));
        }
Пример #29
0
        public void Yatzy_scores_50()
        {
            var expected = 50;
            var actual   = Yatzy.Yams(4, 4, 4, 4, 4);

            Assert.Equal(expected, actual);
            Assert.Equal(50, Yatzy.Yams(6, 6, 6, 6, 6));
            Assert.Equal(0, Yatzy.Yams(6, 6, 6, 6, 3));
        }
Пример #30
0
        public void should_be_straight_2()
        {
            var y = new Yatzy(
                new FakeDice6(5),
                new FakeDice6(1),
                new FakeDice6(3),
                new FakeDice6(2),
                new FakeDice6(4)
                );

            y.Roll();

            bool result = y.IsSmallStraight();

            Assert.IsTrue(result);
        }
Пример #31
-1
    public static void Main(string[] args)
    {
        if (args.Length < 1)
        {
            PrintUsage();
            return;
        }

        var rulesetArg = args[0];
        Ruleset ruleset;

        switch (rulesetArg)
        {
            case "yahtzee":
                ruleset = new Yahtzee();
                break;
            case "yatzy":
                ruleset = new Yatzy();
                break;
            default:
                Console.WriteLine("Unknown ruleset " + rulesetArg);
                return;
        }

        var solver = new Solver(ruleset);

        if (args.Length > 1)
        {
            var startStep = int.Parse(args[1]);
            solver.Solve(startStep);
        }
        else
        {
            solver.Solve();
        }
    }