Example #1
0
    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
    }
Example #2
0
        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
        }