public static void main(string[] args)
    {
        HeroBuilder builder = new HeroBuilder();

        builder.SetName("Batman")
        .SetAlterEgo("Bruce Wayne")
        .SetBaseOfOperations("Gotham City")
        .SetNemesis("The Joker, Ra's-al-Ghul, The Court of Owls")
        .WearsCape(true);

        // Breaking it up for readability:
        builder.AddStrength("Genius-level intellect")
        .AddStrength("Expert in forensics")
        .AddStrength("Trained to physical perfection")
        .AddStrength("The World's Greatest Detective")
        .AddStrength("Lives by a code of honor to never kill");

        builder.AddWeakness("Can be prey to his own anger")
        .AddWeakness("Often refuses help from others");

        // Create the character:
        SuperHero theDarkKnight = builder.BuildHero();

        // Get to know the character!
        theDarkKnight.PrintProfile();
    }
        public void An_HeroBuilder_can_build_a_warrior()
        {
            Hero actual = new HeroBuilder()
                                 .OfWarriorClass()
                                 .FillFromName()
                                 .Create();

            actual.Class.ShouldBe(HeroClass.Warrior);
        }
        public void When_built_thehero_level_is_one_by_default()
        {
            Hero actual = new HeroBuilder()
                                 .FillBeforeLevel()
                                 .FillAfterLevel()
                                 .Create();

            actual.Level.ShouldBe(1);
        }
Exemple #4
0
    private void Start()
    {
        hero = HeroBuilder.Build(PLAYER_HERO_INDEX, this);
        AbilityButton.CreateButtonsForHero(hero);

        animator    = GetComponentInChildren <Animator>();
        destination = transform.position;
        newPosition = destination;
    }
        public void WhenBuilt_a_level3_hero_is_level_3()
        {
            Hero actual = new HeroBuilder()
                                 .FillBeforeLevel()
                                 .WithLevel(3)
                                 .Create();

            actual.Level.ShouldBe(3);
        }
        public void An_HeroBuilder_can_build_a_thief()
        {
            Hero actual = new HeroBuilder()
                                 .OfThiefClass()
                                 .FillFromName()
                                 .Create();

            actual.Class.ShouldBe(HeroClass.Thief);
        }
        public void An_HeroBuilder_can_build_a_wizard()
        {
            Hero actual = new HeroBuilder()
                                 .OfWizardClass()
                                 .FillFromName()
                                 .Create();

            actual.Class.ShouldBe(HeroClass.Wizard);
        }
Exemple #8
0
        public void HeroBuilderTest(WeaponType weapon, ArmorType armor, BootType boot, ShieldType shield)
        {
            HeroBuilder builder = new HeroBuilder();
            Hero        hero    = builder.WithWeapon(weapon).WithArmor(armor).WithBoot(boot).WithShield(shield).Build();

            hero.Weapon.ShouldBe(weapon);
            hero.Armor.ShouldBe(armor);
            hero.Boot.ShouldBe(boot);
            hero.Shield.ShouldBe(shield);
        }
        public void Ctor_PassingInList_ShouldPopulateMockDbSetWithAllItems()
        {
            // Arrange
            var heroes = HeroBuilder.CreateAListOfHeros();

            // Act
            var heroDbSet = new MockDbSet <HeroEntity>(heroes);

            // Assert
            Assert.AreEqual(heroes.Count(), ((IEnumerable <HeroEntity>)heroDbSet).Count());
        }
        public void An_Hero_should_have_a_name()
        {
            var name = "The Mitghty Radgar";
            Hero actualHero = null;

            Action buildWithAName = () => actualHero = new HeroBuilder().OfWarriorClass().WithName("The Mitghty Radgar").FillAfterName().Create();
            buildWithAName.ShouldNotThrow();
            actualHero.Name.ShouldBe(name);

            Action buildWithoutAName = () => new HeroBuilder().OfWarriorClass().Create();
            buildWithoutAName.ShouldThrow<HeroBuilder.BuildingHeroWithoutNameAttempException>();
        }
Exemple #11
0
    private Character BuildCharacter(CharInfo charInfo, Transform initialSlot, bool isHero)
    {
        DivineDebug.Log("Building character " + charInfo.moniker.ToString() + " .");

        if (isHero)
        {
            return(HeroBuilder.Build(charInfo as HeroInfo, this, initialSlot.position, initialSlot.rotation));
        }
        else
        {
            return(CharBuilder.Build(charInfo, this, initialSlot.position, initialSlot.rotation));
        }
    }
Exemple #12
0
        public void TestMethod1()
        {
            var build = new HeroBuilder();
            var value = new VehicleCreator(build);

            value.CreateVehicle();
            var a = value.GetVehicle();

            Assert.AreEqual("Hero", a.Model);
            Assert.AreEqual("4 Stroke", a.Engine);
            Assert.AreEqual("Plastic", a.Body);
            Assert.AreEqual("120 km/hr", a.Transmission);
            Assert.AreEqual("Seat Cover", a.Accessories[0]);
            Assert.AreEqual("Rear Mirror", a.Accessories[1]);
        }
Exemple #13
0
        public void HeroGetVehicle_ShouldReturn_HeroProperties()
        {
            var build = new HeroBuilder();
            var value = new VehicleCreator(build);

            value.CreateVehicle();
            var a = value.GetVehicle();

            Assert.Equal("Hero", a.Model);
            Assert.Equal("4 Stroke", a.Engine);
            Assert.Equal("Plastic", a.Body);
            Assert.Equal("120 km/hr", a.Transmission);
            Assert.Equal("Seat Cover", a.Accessories[0]);
            Assert.Equal("Rear Mirror", a.Accessories[1]);
        }
Exemple #14
0
        private static Hero MakeCustomHero()
        {
            var  builder   = new HeroBuilder();
            bool isFlyHero = false;

            do
            {
                Console.Clear();
                Console.WriteLine("0 - Set\\Unset fly mode");
                Console.WriteLine("1 - Set name");
                Console.WriteLine("2 - Set armor");
                Console.WriteLine("3 - Set weapon");
                Console.WriteLine("4 - Build hero");
                switch (GetCommand())
                {
                case 0:
                    isFlyHero = !isFlyHero;
                    break;

                case 1:
                    Console.Write("Name: ");
                    builder.SetName(Console.ReadLine());
                    break;

                case 2:
                    Console.Write("Armor: ");
                    builder.SetArmor(Console.ReadLine());
                    break;

                case 3:
                    Console.Write("Weapon: ");
                    builder.SetWeapon(Console.ReadLine());
                    break;

                case 4:
                    if (isFlyHero)
                    {
                        return(new FlyHeroDecorator(builder.Build()));
                    }
                    else
                    {
                        return(builder.Build());
                    }
                }
            } while (true);
        }
Exemple #15
0
        private static void FillHeroes()
        {
            var defaultHero = new HeroBuilder()
                              .SetArmor("Infinity")
                              .SetName("Denis")
                              .SetWeapon("--|====>")
                              .Build();
            var flyHero = new FlyHeroDecorator(defaultHero);

            map.AddComponent(new HeroComponentAdapter(defaultHero));
            map.AddComponent(new HeroComponentAdapter(heroFactory.MakeAttackHero()));
            map.AddComponent(new HeroComponentAdapter(heroFactory.MakeDistantHero()));
            map.AddComponent(new HeroComponentAdapter(heroFactory.MakeHiddenHero()));
            map.AddComponent(new HeroComponentAdapter(flyHero));
            var winterMap = new Map();

            winterMap.Title = "Winter Map";
            winterMap.AddComponent(new HeroComponentAdapter(
                                       new HeroBuilder()
                                       .SetName("Snow")
                                       .Build())
                                   );
            map.AddComponent(winterMap);
        }
        public void a_hero_with_class_and_level_has_given_charateristics(string @class, int level, int expectedHealth, int expectedStrength, int expectedSpirit, int expectedSpeed)
        {
            Hero actual = new HeroBuilder()
                .WithStringClass(@class)
                .WithName("the name")
                .WithLevel(level)
                .Create();

            actual.Level.ShouldBe(level);
            actual.Health.ShouldBe(expectedHealth);
            actual.Strength.ShouldBe(expectedStrength);
            actual.Spirit.ShouldBe(expectedSpirit);
            actual.Speed.ShouldBe(expectedSpeed);
        }
        public void a_hero_can_be_boosted_on_strength_twice()
        {
            var heroWithoutBoost = new HeroBuilder().FillBeforeBoost().Create();
            var heroWithBoost = new HeroBuilder()
                                        .FillBeforeBoost()
                                        .BoostStrength()
                                        .BoostStrength()
                                        .Create();

            heroWithBoost.Strength.ShouldBe(heroWithoutBoost.Strength + 2);
        }
        public void a_hero_can_be_boosted_on_spirit_three_times()
        {
            var heroWithoutBoost = new HeroBuilder().FillBeforeBoost().Create();
            var heroWithBoost = new HeroBuilder()
                                        .FillBeforeBoost()
                                        .BoostSpirit(BoostCharacteristics.OfTwo)
                                        .Create();

            heroWithBoost.Spirit.ShouldBe(heroWithoutBoost.Spirit + 2);
        }
        public void a_hero_can_be_boosted_on_spirit_twice()
        {
            var heroWithoutBoost = new HeroBuilder().FillBeforeBoost().Create();
            var heroWithBoost = new HeroBuilder()
                                        .FillBeforeBoost()
                                        .BoostSpirit()
                                        .BoostSpirit()
                                        .Create();

            heroWithBoost.Spirit.ShouldBe(heroWithoutBoost.Spirit + 2);
        }
        public void a_hero_can_be_boosted_on_strength_ofTwo()
        {
            var heroWithoutBoost = new HeroBuilder().FillBeforeBoost().Create();
            var heroWithBoost = new HeroBuilder()
                                        .FillBeforeBoost()
                                        .BoostStrength(BoostCharacteristics.OfTwo)
                                        .Create();

            heroWithBoost.Strength.ShouldBe(heroWithoutBoost.Strength + 2);
        }