コード例 #1
0
        public void LowRollShouldMiss()
        {
            IRollable d20        = new MockDie(7);
            Player    badFighter = new Player(d20);
            Orc       anOrc      = new Orc();

            Assert.IsFalse(badFighter.Attack(anOrc));
        }
コード例 #2
0
        public void HighRollShouldHit()
        {
            IRollable d20         = new MockDie(18);
            Player    goodFighter = new Player(d20);
            Orc       anOrc       = new Orc();

            Assert.IsTrue(goodFighter.Attack(anOrc));
        }
コード例 #3
0
        public void It_Should_ReturnANumber_When_Rolled()
        {
            //arrange
            var dice = new MockDie {
                Value = 4
            };

            //act
            dice.Roll();

            //assert
            Assert.Equal(4, dice.Value);
        }
コード例 #4
0
        public void It_Should_ReturnANewValue_When_RolledAgain()
        {
            //arrange
            var dice = new MockDie {
                Value = 4
            };

            dice.Roll();
            dice.Value = 2;

            //act
            dice.Roll();

            //assert
            Assert.Equal(2, dice.Value);
        }
コード例 #5
0
        public void OrcShouldNotDie()
        {
            MockGame mockGame  = new MockGame();
            Orc      strongOrc = new Orc(mockGame, 30);

            MockDie d20 = new MockDie();

            d20.AddRoll(18);
            d20.AddRoll(10);

            Player fighter = new Player(d20);

            fighter.Attack(strongOrc);

            Assert.IsFalse(strongOrc.IsDead());
            mockGame.Verify();
        }
コード例 #6
0
        public void OrcShouldDie()
        {
            MockGame mockGame = new MockGame();
            Orc      weakOrc  = new Orc(mockGame, 10);

            mockGame.ExpectHasDied(weakOrc);

            MockDie d20 = new MockDie();

            d20.AddRoll(18);
            d20.AddRoll(10);

            Player fighter = new Player(d20);

            fighter.Attack(weakOrc);

            Assert.IsTrue(weakOrc.IsDead());
            mockGame.Verify();
        }