public void Attack_SuperMode_ShouldAttackOpponentWithDoubleStrength() { //Arrange IHero hero = new HeroBuilder().WithSuperModeLikeliness(1.0f).Build(); Mock <IHero> opponentMock = new HeroMockBuilder().Build(); //Act hero.Attack(opponentMock.Object); //Assert opponentMock.Verify(opponent => opponent.DefendAgainstAttack(hero.Strength * 2), Times.Once, $"Should call 'DefendAgainstAttack' of opponent with strength {hero.Strength * 2}."); }
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."); }
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."); }