static void Main(string[] args) { FlipRoll flipRoll = new FlipRoll(); Combat combat = new Combat(flipRoll); Hero hero1 = new Hero { Strength = 10, HitPoints = 100, Defence = 1 }; Hero hero2 = new Hero { Strength = 20, HitPoints = 1, Defence = 1 }; System.Console.WriteLine(hero1.HitPoints); combat.Ambush(hero2, hero1, 1); System.Console.WriteLine(hero1.HitPoints); // Method swap was tested and fixed with ref }
public void Battle_HitPointsAre0InHarmlessHero_ShouldReturnTrue() { //Arrange FlipRoll flipRoll = new FlipRoll(); Combat combat = new Combat(flipRoll); Hero hero1 = new Hero { Strength = 4, HitPoints = 1, Defence = 1 }; Hero hero2 = new Hero { Strength = 2, HitPoints = 1, Defence = 1 }; //Act combat.Battle(hero1, hero2); //Assert Assert.True(hero2.HitPoints == 0); }
public void HitAndRun_HitPointsAre0InHitHeroWhenRollIs1_ShouldReturnTrue() { //Arrange FlipRoll flipRoll = new FlipRoll(); Combat combat = new Combat(flipRoll); Hero hero1 = new Hero { Strength = 10, HitPoints = 2, Defence = 0 }; Hero hero2 = new Hero { Strength = 4, HitPoints = 1, Defence = 1 }; //Act combat.HitAndRun(hero2, hero1, 1); //Assert Assert.True(hero2.HitPoints > 0); Assert.Equal(0, hero1.HitPoints); }
public void Ambush_HitPointsAre0InAmbushedHeroWhenRollIs1_ShouldReturnTrue() { //Arrange FlipRoll flipRoll = new FlipRoll(); Combat combat = new Combat(flipRoll); Hero hero1 = new Hero { Strength = 10, HitPoints = 4, Defence = 0 }; Hero hero2 = new Hero { Strength = 4, HitPoints = 1, Defence = 1 }; //Act combat.Ambush(hero2, hero1, 1); //Assert Assert.Equal(0, hero1.HitPoints); //Added ref to fix Method swap wasn't working because it changed just the thing inside the method //also added rollValue to make it easier to test and have more control over the randomness }
public Combat(FlipRoll flipRoll) { this.flipRoll = flipRoll; }