Пример #1
0
        public void IsOver_AFighterHasNoHealth_ShouldReturnTrue()
        {
            //Arrange
            IHero   fighter1 = new HeroMockBuilder().WithHealth(-5).BuildObject();
            IHero   fighter2 = new HeroMockBuilder().WithHealth(10).BuildObject();
            IBattle battle   = new BattleBuilder(fighter1, fighter2).Build();

            //Act + Assert
            Assert.That(battle.IsOver, Is.True);
        }
Пример #2
0
        public void IsOver_BothFightersHaveHealth_ShouldReturnFalse()
        {
            //Arrange
            IHero   fighter1 = new HeroMockBuilder().WithHealth(20).BuildObject();
            IHero   fighter2 = new HeroMockBuilder().WithHealth(10).BuildObject();
            IBattle battle   = new BattleBuilder(fighter1, fighter2).Build();

            //Act + Assert
            Assert.That(battle.IsOver, Is.False);
        }
Пример #3
0
        public void FightRound_Fighter2HasNoHealth_ShouldOnlyLetFighter1Attack()
        {
            //Arrange
            Mock <IHero> fighter1Mock = new HeroMockBuilder().WithHealth(100).Build();
            Mock <IHero> fighter2Mock = new HeroMockBuilder().WithHealth(0).Build();
            IBattle      battle       = new BattleBuilder(fighter1Mock.Object, fighter2Mock.Object).Build();

            //Act
            battle.FightRound();

            //Assert
            fighter1Mock.Verify(f => f.Attack(fighter2Mock.Object), Times.Once, "Fighter 1 did not attack fighter 2.");
            fighter2Mock.Verify(f => f.Attack(It.IsAny <IHero>()), Times.Never, "Fighter 2 should not attack. He has no health.");
        }
Пример #4
0
        public void FightRound_ShouldLetThe2FightersAttack()
        {
            //Arrange
            Mock <IHero> fighter1Mock = new HeroMockBuilder().WithHealth(100).Build();
            Mock <IHero> fighter2Mock = new HeroMockBuilder().WithHealth(100).Build();
            IBattle      battle       = new BattleBuilder(fighter1Mock.Object, fighter2Mock.Object).Build();

            //Act
            battle.FightRound();

            //Assert
            fighter1Mock.Verify(f => f.Attack(fighter2Mock.Object), Times.Once, "Fighter 1 did not attack fighter 2.");
            fighter2Mock.Verify(f => f.Attack(fighter1Mock.Object), Times.Once, "Fighter 2 did not attack fighter 1.");
        }