Пример #1
0
        public void HeldDiceShouldNotGetRerolled()
        {
            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("1,1,1")
            .Returns("q");
            var player    = new Player(mockInput.Object);
            var scorecard = new ScoreCard();
            var yatzy     = new YatzyGame(player, scorecard, mockRng.Object);
            var round     = new Round();

            round.RollDice(yatzy.DiceCup, mockRng.Object);
            yatzy.HandleResponse(player.Respond(), round);
            Assert.Equal(3, yatzy.DiceCup.Count(die => die.IsHeld));
        }
Пример #2
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);
        }