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);
        }
예제 #2
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);
        }
        public void ShouldCallGameEvaluationResultWhenEvaluationSucceeds()
        {
            //ARRANGE
            var gameMock = new GameMock();

            var result = new SuccessGameEvaluationResult(GameCategory.ROYAL_FLUSH, null);

            var evaluation = new EvaluationMock();
            evaluation.EvaluateReturns(result);

            var subject = new GameEvaluationCommand(evaluation);

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

            //ASSERT
            Assert.AreSame(result, gameMock.ReceivedEvaluationResult);
        }
예제 #4
0
        public void ShouldCallGameEvaluationResultWhenEvaluationSucceeds()
        {
            //ARRANGE
            var gameMock = new GameMock();

            var result = new SuccessGameEvaluationResult(GameCategory.ROYAL_FLUSH, null);

            var evaluation = new EvaluationMock();

            evaluation.EvaluateReturns(result);

            var subject = new GameEvaluationCommand(evaluation);

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

            //ASSERT
            Assert.AreSame(result, gameMock.ReceivedEvaluationResult);
        }
        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);
        }
        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);
        }
예제 #7
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);
        }
예제 #8
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);
        }