Exemple #1
0
        public void OutputCorrect()
        {
            Mock <IConsole>   console    = new Mock <IConsole>(MockBehavior.Strict);
            Mock <IDieRoller> diceRoller = new Mock <IDieRoller>(MockBehavior.Strict);


            console.Setup(x => x.Read()).Returns("D1 D2 D4");

            var printSequence = new Moq.MockSequence();

            console.InSequence(printSequence).Setup(x => x.Write("Category: Ones")).Verifiable();
            console.InSequence(printSequence).Setup(x => x.Write("Dice: D1:2 D2:4 D3:1 D4:6 D5:1")).Verifiable();
            console.InSequence(printSequence).Setup(x => x.Write("[1] Dice to re-run:")).Verifiable();
            console.InSequence(printSequence).Setup(x => x.Write("Dice: D1:1 D2:5 D3:1 D4:2 D5:1")).Verifiable();
            console.InSequence(printSequence).Setup(x => x.Write("[2] Dice to re-run: ")).Verifiable();

            var fakeDieRoller = new FakeDieRoller(new List <int> {
                2, 4, 1, 6, 1, 1, 5, 2
            });


            var yathtzee = new Yathzee(console.Object, fakeDieRoller);

            yathtzee.Play();


            console.VerifyAll();
        }