public void Human_HitPoints_ShouldBe10()
        {
            var strategy         = new HumanBaseHitPointsStrategy();
            var characterService = new BaseHitPointsService(strategy);
            var cha = Mother.CreateCharacter_Human();
            var hp  = characterService.GetBaseHitPoints(cha);

            Assert.AreEqual(10, hp);
        }
        public void Elf_HitPoints_ShouldBe8()
        {
            var strategy         = new ElfBaseHitPointsStrategy();
            var characterService = new BaseHitPointsService(strategy);
            var cha = Mother.CreateCharacter_Elf();
            var hp  = characterService.GetBaseHitPoints(cha);

            Assert.AreEqual(8, hp);
        }
        public void Dwarf_HitPoints_ShouldBe12()
        {
            var strategy         = new DwarfBaseHitPointsStrategy();
            var characterService = new BaseHitPointsService(strategy);
            var cha = Mother.CreateCharacter_Dwarf();
            var hp  = characterService.GetBaseHitPoints(cha);

            Assert.AreEqual(12, hp);
        }
Example #4
0
        public static void Main(string[] args)
        {
            Func <Character, int> humanStrategy = GetHumanBaseHitPoints;
            //2 ways to do the same strategy
            Func <Character, int> elfStrategy   = delegate(Character cha) { return(cha.HitPoints - 2); };
            Func <Character, int> dwarfStrategy = cha => cha.HitPoints + 2;


            Character character = Mother.CreateCharacter();

            var baseHitPointsService = new BaseHitPointsService();

            Console.WriteLine("Human hit points: " + baseHitPointsService.GetBaseHitPoints(character, humanStrategy));
            Console.WriteLine("Elf hit points: " + baseHitPointsService.GetBaseHitPoints(character, elfStrategy));
            Console.WriteLine("Dwarf hit points: " + baseHitPointsService.GetBaseHitPoints(character, dwarfStrategy));
            Console.ReadKey();
        }