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."); }