Esempio n. 1
0
        public void ShouldStopWhenEvaluationSucceeds()
        {
            // ARRANGE
            var game = new Game(
                CardBuilder.Ace().Hearths(),
                CardBuilder.King().Hearths(),
                CardBuilder.Queen().Hearths(),
                CardBuilder.Jack().Hearths(),
                CardBuilder.Ten().Hearths());

            var evaluationMock = new EvaluationMock();

            evaluationMock.EvaluateReturns(new SuccessGameEvaluationResult(GameCategory.ROYAL_FLUSH, game.Cards));

            var subject = new GameEvaluationChain(new IGameEvaluation[] {
                new WrongEvaluation(),
                new RightEvaluation(),
                evaluationMock
            });

            // ACT
            subject.Evaluate(game);

            // ASSERT
            Assert.IsFalse(evaluationMock.EvaluateWasCalled);
        }
Esempio n. 2
0
 public static Game HearthsRoyalFlush()
 {
     return(new Game(
                CardBuilder.Ace().Hearths(),
                CardBuilder.King().Hearths(),
                CardBuilder.Queen().Hearths(),
                CardBuilder.Jack().Hearths(),
                CardBuilder.Ten().Hearths()));
 }
Esempio n. 3
0
        public void StraightFlush()
        {
            // ARRANGE
            var game = new Game(
                CardBuilder.Eight().Hearths(),
                CardBuilder.Seven().Hearths(),
                CardBuilder.Nine().Hearths(),
                CardBuilder.Ten().Hearths(),
                CardBuilder.Jack().Hearths());

            // ACT
            new GameEvaluator().Evaluate(game);

            // ASSERT
            Assert.AreEqual(GameCategory.STRAIGHT_FLUSH, game.Category);
        }
Esempio n. 4
0
        public void RoyalFlush()
        {
            // ARRANGE
            var game = new Game(
                CardBuilder.Ace().Hearths(),
                CardBuilder.King().Hearths(),
                CardBuilder.Queen().Hearths(),
                CardBuilder.Jack().Hearths(),
                CardBuilder.Ten().Hearths());

            // ACT
            new GameEvaluator().Evaluate(game);

            // ASSERT
            Assert.AreEqual(GameCategory.ROYAL_FLUSH, game.Category);
        }
Esempio n. 5
0
        public void ShouldReturnTrueWhenEvaluationSucceeds()
        {
            //ARRANGE
            var game = new Game(
                CardBuilder.Ace().Hearths(),
                CardBuilder.King().Hearths(),
                CardBuilder.Queen().Hearths(),
                CardBuilder.Jack().Hearths(),
                CardBuilder.Ten().Hearths());

            var evaluation = new EvaluationMock();

            evaluation.EvaluateReturns(new SuccessGameEvaluationResult(GameCategory.ROYAL_FLUSH, game.Cards));

            var subject = new GameEvaluationCommand(evaluation);

            //ACT
            var actual = subject.Evaluate(game);

            //ASSERT
            Assert.IsTrue(actual);
        }
Esempio n. 6
0
        public void ShouldReturnFalseWhenEvaluationFails()
        {
            //ARRANGE
            var game = new Game(
                CardBuilder.Ace().Hearths(),
                CardBuilder.King().Hearths(),
                CardBuilder.Queen().Hearths(),
                CardBuilder.Jack().Hearths(),
                CardBuilder.Ten().Hearths());

            var evaluation = new EvaluationMock();

            evaluation.EvaluateReturns(new FailedGameEvaluationResult());

            var subject = new GameEvaluationCommand(evaluation);

            //ACT
            var actual = subject.Evaluate(game);

            //ASSERT
            Assert.IsFalse(actual);
        }