Beispiel #1
0
        public void GameShouldStartARoundByRolling5Dice()
        {
            var mockRng = new Mock <IRng>();

            mockRng.Setup(rng => rng.Next(It.IsAny <int>(), It.IsAny <int>())).Returns(1);
            var mockInput = new Mock <IConsoleReader>();

            mockInput.SetupSequence(consoleReader => consoleReader.GetInput()).Returns("r").Returns("q");
            var player    = new Player(mockInput.Object);
            var scoreCard = new ScoreCard();
            var yatzy     = new YatzyGame(player, scoreCard, mockRng.Object);

            yatzy.PlayRound();
            Assert.NotEqual(0, yatzy.DiceCup[0].Value);
        }
Beispiel #2
0
        public void CategoryShouldBeUsedIfScoredInCategory()
        {
            var mockRng = new Mock <IRng>();

            mockRng.Setup(rng => rng.Next(It.IsAny <int>(), It.IsAny <int>())).Returns(1);
            var mockInput = new Mock <IConsoleReader>();

            mockInput.Setup(consoleReader => consoleReader.GetInput()).Returns("a");
            var player    = new Player(mockInput.Object);
            var scoreCard = new ScoreCard();
            var yatzy     = new YatzyGame(player, scoreCard, mockRng.Object);

            Assert.False(scoreCard.CategoryScoreCard[0].IsUsed);
            yatzy.PlayRound();
            Assert.True(scoreCard.CategoryScoreCard[0].IsUsed);
        }
Beispiel #3
0
        public void GameShouldNotScoreIfUsed()
        {
            var mockRng = new Mock <IRng>();

            mockRng.Setup(rng => rng.Next(It.IsAny <int>(), It.IsAny <int>())).Returns(1);
            var mockInput = new Mock <IConsoleReader>();

            mockInput.SetupSequence(consoleReader => consoleReader.GetInput()).Returns("a").Returns("a").Returns("q");
            var player    = new Player(mockInput.Object);
            var response  = player.Respond();
            var scorecard = new ScoreCard();
            var round     = new Round();
            var yatzy     = new YatzyGame(player, scorecard, mockRng.Object);

            yatzy.PlayRound();
            Assert.Equal(ResponseType.ScoreInCategory, response.ResponseType);
            yatzy.HandleResponse(response, round);
            Assert.Equal(ResponseType.InvalidResponse, response.ResponseType);
        }