Пример #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 HasDied(Orc orc)
        {
            if (orc != orcExpectedToDie)
            {
                Assert.Fail("Unexpected orc died.");
            }

            deadOrc = orc;
        }
Пример #4
0
 public Boolean Attack(Orc anOrc)
 {
     if (myD20.Roll() >= 13)
     {
         return(hit(anOrc));
     }
     else
     {
         return(miss());
     }
 }
Пример #5
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();
        }
Пример #6
0
 private bool hit(Orc anOrc)
 {
     anOrc.Injure(myD20.Roll());
     return true;
 }
Пример #7
0
 public Boolean Attack(Orc anOrc)
 {
     if (myD20.Roll() >= 13)
     {
         return hit(anOrc);
     }
     else
     {
         return miss();
     }
 }
Пример #8
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();
        }
Пример #9
0
 public void ExpectHasDied(Orc orc)
 {
     orcExpectedToDie = orc;
 }
Пример #10
0
 private bool hit(Orc anOrc)
 {
     anOrc.Injure(myD20.Roll());
     return(true);
 }