Beispiel #1
0
        public void Should_Create_Instance_Of_Specified_Type()
        {
            var plant = new BasePlant();
              plant.DefinePropertiesOf<Person>(new { FirstName = "" });

              Assert.IsInstanceOf(typeof(Person), plant.Create<Person>());
        }
Beispiel #2
0
        public void Should_Call_AfterBuildCallback_AfterConstructor_Population()
        {
            var testPlant = new BasePlant();
            testPlant.DefineConstructionOf<House>(new { Color = "Red", SquareFoot = 3000 },
            (h) => h.Summary = h.Color + h.SquareFoot);

            Assert.AreEqual("Blue3000", testPlant.Create<House>(new { Color = "Blue" }).Summary);
        }
Beispiel #3
0
 public void Should_Call_AfterBuildCallback_After_Properties_Populated()
 {
     var testPlant = new BasePlant();
     testPlant.DefinePropertiesOf<Person>(new {FirstName = "Angus", LastName = "MacGyver"},
     (p) => p.FullName = p.FirstName + p.LastName);
     var builtPerson = testPlant.Create<Person>();
     Assert.AreEqual(builtPerson.FullName, "AngusMacGyver");
 }
Beispiel #4
0
        public void Should_Build_Relation()
        {
            var plant = new BasePlant();
            plant.DefinePropertiesOf(new House() { Color = "blue", SquareFoot = 50 });
            plant.DefinePropertiesOf(new Person() { FirstName = "Leo" });

            var person = plant.Build<Person>();

            Assert.IsNotNull(person.HouseWhereILive);
        }
Beispiel #5
0
        public void Is_Event_Created_Called()
        {
            var plant = new BasePlant();
            plant.DefinePropertiesOf(new House { Color = "blue", SquareFoot = 50 });
            plant.DefinePropertiesOf(new Person { FirstName = "Leo" });

            plant.BluePrintCreated += plant_BluePrintCreated;
            plant.Create<House>();
            plant.Create<Person>();
        }
Beispiel #6
0
        public void Can_Create_Two_Different_House()
        {
            var plant = new BasePlant();
            plant.DefinePropertiesOf(new House { Color = "blue", SquareFoot = 50 });
            plant.DefinePropertiesOf(new Person { FirstName = "Leo" });

            var house = plant.Create<House>();
            var redHouse = plant.Create(new House { Color = "red" });

            Assert.AreNotEqual(house, redHouse);
            Assert.AreNotEqual(house.Color, redHouse.Color);
        }
Beispiel #7
0
        public void Should_Lazily_Evaluate_Delegate_Properties()
        {
            var    plant          = new BasePlant();
            string lazyMiddleName = null;

            plant.DefinePropertiesOf <Person>(new
            {
                MiddleName = new LazyProperty <string>(() => lazyMiddleName)
            });

            Assert.AreEqual(null, plant.Create <Person>().MiddleName);
            lazyMiddleName = "Johnny";
            Assert.AreEqual("Johnny", plant.Create <Person>().MiddleName);
        }
Beispiel #8
0
        public void Should_Create_Variation_With_Extension()
        {
            var plant = new BasePlant();

            plant.DefinePropertiesOf(new House {
                Color = "blue"
            }, OnPropertyPopulation);
            plant.DefineVariationOf("My", new House {
                Color = "My"
            }, OnPropertyPopulationVariatoion);

            Assert.AreEqual(plant.Create <House>().Persons.First().FirstName, "Pablo");
            Assert.AreEqual(plant.Create <House>("My").Persons.First().FirstName, "Pedro");
        }
Beispiel #9
0
        public async Task <IHttpActionResult> DeleteBasePlant(int id)
        {
            BasePlant basePlant = await db.BasePlants.FindAsync(id);

            if (basePlant == null)
            {
                return(NotFound());
            }

            db.BasePlants.Remove(basePlant);
            await db.SaveChangesAsync();

            return(Ok(basePlant));
        }
Beispiel #10
0
        public void Should_Build_Relation()
        {
            var plant = new BasePlant();

            plant.DefinePropertiesOf(new House {
                Color = "blue", SquareFoot = 50
            });
            plant.DefinePropertiesOf(new Person {
                FirstName = "Leo"
            });

            var person = plant.Build <Person>();

            Assert.IsNotNull(person.HouseWhereILive);
        }
Beispiel #11
0
        public PlantIdentificationGump(Mobile from, BasePlant plant)
            : base("Plante", 400, 220)
        {
            m_from  = from;
            m_plant = plant;

            int x     = XBase;
            int y     = YBase;
            int line  = 0;
            int scale = 25;

            x = 90;

            AddItem(x + 5, y + (line * scale) + 12, plant.ItemID);
            AddSection(x + 80, y + (line * scale) + 12, 300, 120, plant.Latin, plant.Description);
        }
Beispiel #12
0
        public void Is_Event_Created_Called()
        {
            var plant = new BasePlant();

            plant.DefinePropertiesOf(new House {
                Color = "blue", SquareFoot = 50
            });
            plant.DefinePropertiesOf(new Person {
                FirstName = "Leo"
            });

            plant.BluePrintCreated += plant_BluePrintCreated;
            plant.Create <House>();
            plant.Create <Person>();
            Assert.AreEqual(eventcounter, 2);
        }
Beispiel #13
0
        public void BringToHome()
        {
            Defrag();

            for (int i = 0; i < m_Plants.Count; ++i)
            {
                object o = m_Plants[i];

                if (o is BasePlant)
                {
                    BasePlant plant = (BasePlant)o;

                    plant.MoveToWorld(Location, Map);
                }
            }
        }
Beispiel #14
0
        public void Is_Event_Created_Called()
        {
            var plant = new BasePlant();

            plant.DefinePropertiesOf(new House()
            {
                Color = "blue", SquareFoot = 50
            });
            plant.DefinePropertiesOf(new Person()
            {
                FirstName = "Leo"
            });

            plant.BluePrintCreated += new BluePrintCreatedEventHandler(plant_BluePrintCreated);
            var house  = plant.Create <House>();
            var person = plant.Create <Person>();
        }
Beispiel #15
0
        public void Should_Not_Prefill_Relation_Defined()
        {
            var plant = new BasePlant();

            plant.DefinePropertiesOf(new House {
                Color = "blue", SquareFoot = 50
            });
            plant.DefinePropertiesOf(new Person {
                FirstName = "Leo", HouseWhereILive = new House {
                    Color = "Violet"
                }
            });

            var house  = plant.Create <House>();
            var person = plant.Create <Person>();

            Assert.AreEqual("Violet", person.HouseWhereILive.Color);
        }
Beispiel #16
0
    //if tile is swiped over
    public int Swiped(out BasePlant plant)
    {
        int tempScore = 0;

        plant = basePlant;

        //if the plant is already active
        if (basePlant.GetActive())
        {
            //get the score from the plant
            tempScore = basePlant.GetScore();
            Debug.Log(basePlant.GetScore());

            //if the plant is type of double plant
            if (basePlant is DoubleScorePlant)
            {
                //white text
                FloatingTextManager.CreateFloatingText("+" + basePlant.GetScore().ToString(), basePlant.transform, Color.white);
            }
            else if (basePlant is NormalPlant)
            {
                //yellow text
                FloatingTextManager.CreateFloatingText("+" + basePlant.GetScore().ToString(), basePlant.transform);
            }
            else if (basePlant is DebuffPlant)
            {
                FloatingTextManager.CreateFloatingText("+" + basePlant.GetScore().ToString(), basePlant.transform, Color.blue);
                DebuffPlant debuff = basePlant as DebuffPlant;
                Destroy(lightning);
            }

            //activate the dead plant animation
            m_animator.SetTrigger("DeadPlant");

            //Set the plant state to be inactive
            basePlant.SetActive(false);

            for (int i = 0; i < emmiters.Count; i++)
            {
                emmiters [i].Play();
            }
        }
        return(tempScore);
    }
Beispiel #17
0
        public void Create_WhenVariationHasLazyPropertyOverwrittenByUser_DoesNotInvokeVariationLazyProperty()
        {
            var plant = new BasePlant();
            const string variationName = "Self";
            var wasVariantLazyPropertyAssigned = false;
            plant.DefinePropertiesOf<Person>(new { FirstName = "default" });
            plant.DefineVariationOf<Person>(variationName, new
            {
                FirstName = new LazyProperty<string>(() =>
                {
                    wasVariantLazyPropertyAssigned = true;
                    return "overwritten";
                })
            });

            plant.Create<Person>(new { FirstName = "UserDefined" }, variationName);

            Assert.IsFalse(wasVariantLazyPropertyAssigned);
        }
Beispiel #18
0
        public void Should_Prefill_Relation()
        {
            var plant = new BasePlant();

            plant.DefinePropertiesOf(new House {
                Color = "blue", SquareFoot = 50
            });
            plant.DefinePropertiesOf(new Person {
                FirstName = "Leo"
            });

            var house  = plant.Create <House>();
            var person = plant.Create <Person>();

            Assert.IsNotNull(person.HouseWhereILive);
            Assert.AreEqual(house, person.HouseWhereILive);
            Assert.AreEqual(house.Color, person.HouseWhereILive.Color);
            Assert.AreEqual(house.SquareFoot, person.HouseWhereILive.SquareFoot);
        }
Beispiel #19
0
        public void Can_Create_Two_Different_House()
        {
            var plant = new BasePlant();

            plant.DefinePropertiesOf(new House {
                Color = "blue", SquareFoot = 50
            });
            plant.DefinePropertiesOf(new Person {
                FirstName = "Leo"
            });

            var house    = plant.Create <House>();
            var redHouse = plant.Create(new House {
                Color = "red"
            });

            Assert.AreNotEqual(house, redHouse);
            Assert.AreNotEqual(house.Color, redHouse.Color);
        }
Beispiel #20
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 1:
            {
                m_EarthType = (EarthType)reader.ReadInt();
                m_Plant     = (BasePlant)reader.ReadItem();
                goto case 0;
            }

            case 0:
            {
                break;
            }
            }
        }
Beispiel #21
0
        public void Defrag()
        {
            for (int i = 0; i < m_Plants.Count; ++i)
            {
                object o = m_Plants[i];

                if (o is BasePlant)
                {
                    BasePlant plant = (BasePlant)o;

                    if (plant.Deleted || plant.Parent != null || plant.IsGathered)
                    {
                        m_Plants.RemoveAt(i);
                        --i;
                    }
                }
                else
                {
                    m_Plants.RemoveAt(i);
                    --i;
                }
            }
        }
Beispiel #22
0
        public void Should_Lazily_Evaluate_Delegate_Properties()
        {
            var plant = new BasePlant();
            string lazyMiddleName = null;
            plant.DefinePropertiesOf<Person>(new
            {
                // ReSharper disable once AccessToModifiedClosure
                MiddleName = new LazyProperty<string>(() => lazyMiddleName)
            });

            Assert.AreEqual(null, plant.Create<Person>().MiddleName);
            lazyMiddleName = "Johnny";
            Assert.AreEqual("Johnny", plant.Create<Person>().MiddleName);
        }
Beispiel #23
0
 public void SetupPlant(BasePlant p)
 {
     p.DefinePropertiesOf <House>(new { Color = "red" });
 }
Beispiel #24
0
 public void Should_increment_values_in_a_sequence_with_property_construction()
 {
     var testPlant = new BasePlant();
     testPlant.DefinePropertiesOf<Person>(new
     {
         FirstName = new Sequence<string>(i => "FirstName" + i)
     });
     Assert.AreEqual("FirstName0", testPlant.Create<Person>().FirstName);
     Assert.AreEqual("FirstName1", testPlant.Create<Person>().FirstName);
 }
Beispiel #25
0
 public void Should_Set_User_Properties_That_Are_Not_Defaulted()
 {
     var plant = new BasePlant();
     plant.DefinePropertiesOf<Person>(new { FirstName = "Barbara" });
     Assert.AreEqual("Brechtel", plant.Create<Person>(new { LastName = "Brechtel" }).LastName);
 }
Beispiel #26
0
 public void Should_Throw_PropertyNotFound_Exception_When_Given_Invalid_Property()
 {
     var plant = new BasePlant();
     plant.DefinePropertiesOf<Person>(new { Foo = "" });
     plant.Create<Person>();
 }
Beispiel #27
0
 public void Should_Only_Set_Properties_Once()
 {
     var testPlant = new BasePlant();
     testPlant.DefinePropertiesOf<WriteOnceMemoryModule>(new { Value = 5000 });
     Assert.AreEqual(10, testPlant.Create<WriteOnceMemoryModule>(new { Value = 10 }).Value);
 }
Beispiel #28
0
        public void Should_Prefill_Relation()
        {
            var plant = new BasePlant();
            plant.DefinePropertiesOf(new House { Color = "blue", SquareFoot = 50 });
            plant.DefinePropertiesOf(new Person { FirstName = "Leo" });

            var house = plant.Create<House>();
            var person = plant.Create<Person>();

            Assert.IsNotNull(person.HouseWhereILive);
            Assert.AreEqual(house, person.HouseWhereILive);
            Assert.AreEqual(house.Color, person.HouseWhereILive.Color);
            Assert.AreEqual(house.SquareFoot, person.HouseWhereILive.SquareFoot);
        }
Beispiel #29
0
 public void Should_Create_Instance_With_Requested_Properties_Specified_By_Instance()
 {
     var testPlant = new BasePlant();
     testPlant.DefinePropertiesOf(new Person { FirstName = "David" });
     Assert.AreEqual("James", testPlant.Create(new Person { FirstName = "James" }).FirstName);
 }
Beispiel #30
0
 public void Should_Create_Objects_Via_Constructor()
 {
     var testPlant = new BasePlant();
     testPlant.DefineConstructionOf<Car>(new { Make = "Toyota" });
     Assert.AreEqual("Toyota", testPlant.Create<Car>().Make);
 }
Beispiel #31
0
 public static BaseSeed GetSeed(BasePlant plant)
 {
     return(plant.GetSeed());
 }
Beispiel #32
0
 public void Should_Create_Instance_With_Requested_Properties()
 {
     var plant = new BasePlant();
     plant.DefinePropertiesOf<Person>(new { FirstName = "" });
     Assert.AreEqual("James", plant.Create<Person>(new { FirstName = "James" }).FirstName);
 }
Beispiel #33
0
    //add randomised plant component
    public void AddNewPlantComponent()
    {
        //Set up a random percentage chance
        int chance = Random.Range(0, 100);


        //if the chance is greater than 90 (10% chance)
        if (chance >= 75)
        {
            //spawn debuff plant (lightning plant)
            plantComponentType = PlantComponentType.DEBUFFPLANT;
        }
        //if the chance is greater than 70 but less than 90 (20% chance)
        else if (chance > 55 && chance < 75)
        {
            //Spawn double score plant
            plantComponentType = PlantComponentType.DOUBLESCOREPLANT;
        }
        //otherwise just spawn a generic 1 point plant (70%)
        else
        {
            //Spawn Normal Plant
            plantComponentType = PlantComponentType.NORMALPLANT;
        }

        m_animator.SetTrigger("Spawn");

        switch (plantComponentType)
        {
        case PlantComponentType.NORMALPLANT:
            m_animator.enabled = false;
            basePlant          = gameObject.AddComponent <NormalPlant> ();
            basePlant.SetSprite(sprites [0]);
            sr.sprite          = sprites [0];
            m_animator.enabled = true;
            m_animator.SetTrigger("BulbPlant");
            break;

        case PlantComponentType.DOUBLESCOREPLANT:
            m_animator.enabled = false;
            basePlant          = gameObject.AddComponent <DoubleScorePlant> ();
            basePlant.SetSprite(sprites [1]);
            sr.sprite          = sprites [1];
            m_animator.enabled = true;
            m_animator.SetTrigger("VenusPlant");
            break;

        case PlantComponentType.DEBUFFPLANT:
            m_animator.enabled = false;
            basePlant          = gameObject.AddComponent <DebuffPlant> ();
            basePlant.SetSprite(sprites [2]);
            sr.sprite          = sprites [2];
            m_animator.enabled = true;
            m_animator.SetTrigger("YellowPlant");
            break;

        case PlantComponentType.ELECTRICPLANT:
            basePlant = gameObject.AddComponent <ElectricPlant> ();
            basePlant.SetSprite(sprites [3]);
            sr.sprite = sprites [3];

            break;
        }
        basePlant.SetActive(true);
        FirstTimeSpawn = false;
    }
Beispiel #34
0
        public void Should_Load_Blueprints_From_Assembly()
        {
            var plant = new BasePlant().WithBlueprintsFromAssemblyOf <TestBlueprint>();

            Assert.AreEqual("Elaine", plant.Create <Person>().MiddleName);
        }
Beispiel #35
0
 public void SetupPlant(BasePlant p)
 {
     p.DefineVariationOf <House>("appartment", new { Color = "blue" });
 }
Beispiel #36
0
 public void Should_Load_Blueprints_From_Assembly()
 {
     var plant = new BasePlant().WithBlueprintsFromAssemblyOf<TestBlueprint>();
     Assert.AreEqual("Elaine", plant.Create<Person>().MiddleName);
 }
Beispiel #37
0
 public void SetUp()
 {
     plant = new BasePlant().WithBlueprintsFromAssemblyOf <RelationshipTests>();
 }
Beispiel #38
0
        public void Should_Not_Prefill_Relation_Defined()
        {
            var plant = new BasePlant();
            plant.DefinePropertiesOf(new House { Color = "blue", SquareFoot = 50 });
            plant.DefinePropertiesOf(new Person { FirstName = "Leo", HouseWhereILive = new House { Color = "Violet" } });

            plant.Create<House>();
            var person = plant.Create<Person>();

            Assert.AreEqual("Violet", person.HouseWhereILive.Color);
        }
Beispiel #39
0
 public static Item GetRegeant(BasePlant plant)
 {
     return(plant.GetPlantReagent());
 }
Beispiel #40
0
        public void Should_Override_Default_Constructor_Arguments()
        {
            var testPlant = new BasePlant();
            testPlant.DefineConstructionOf<House>(new { Color = "Red", SquareFoot = 3000 });

            Assert.AreEqual("Blue", testPlant.Create<House>(new { Color = "Blue" }).Color);
        }
Beispiel #41
0
 public void SetupPlant(BasePlant plant)
 {
     plant.DefinePropertiesOf<Person>(new
     {
         MiddleName = "Elaine"
     });
 }
Beispiel #42
0
 public void Should_Send_Constructor_Arguments_In_Correct_Order()
 {
     var testPlant = new BasePlant();
     testPlant.DefineConstructionOf<Book>(new { Publisher = "Tor", Author = "Robert Jordan" });
     Assert.AreEqual("Tor", testPlant.Create<Book>().Publisher);
     Assert.AreEqual("Robert Jordan", testPlant.Create<Book>().Author);
 }
Beispiel #43
0
 public void SetupPlant(BasePlant p)
 {
     p.DefinePropertiesOf <Person>(new { Name = "my name" });
 }
Beispiel #44
0
        public void Should_Throw_LazyPropertyHasWrongTypeException_When_Lazy_Property_Definition_Returns_Wrong_Type()
        {
            var plant = new BasePlant();
            plant.DefinePropertiesOf<Person>(new
            {
                MiddleName = new LazyProperty<int>(() => 5)
            });

            plant.Create<Person>();
        }
Beispiel #45
0
 public void Should_increment_values_in_a_sequence_with_ctor_construction()
 {
     var testPlant = new BasePlant();
     testPlant.DefineConstructionOf<House>(new
     {
         Color = new Sequence<string>(i => "Color" + i),
         SquareFoot = 10
     });
     Assert.AreEqual("Color0", testPlant.Create<House>().Color);
     Assert.AreEqual("Color1", testPlant.Create<House>().Color);
 }
Beispiel #46
0
 public void Should_Use_Default_Instance_Values()
 {
     var testPlant = new BasePlant();
     testPlant.DefinePropertiesOf<Person>(new { FirstName = "Barbara" });
     Assert.AreEqual("Barbara", testPlant.Create<Person>().FirstName);
 }
Beispiel #47
0
        public void Spawn()
        {
            Map map = Map;

            if (map == null || map == Map.Internal || Parent != null)
            {
                return;
            }

            Defrag();

            if (m_Plants.Count >= m_Count)
            {
                return;
            }

            if (CanSpawn())
            {
                try
                {
                    int season = Map.Felucca.Season;

                    if (season < 0 || season > 3)
                    {
                        return;
                    }

                    if (season == 0 || season == 1 || season == 2)
                    {
                        season = Utility.Random(3);
                    }

                    if (m_Plant[season] == PlantType.None)
                    {
                        return;
                    }

                    Type   type = ScriptCompiler.FindTypeByName(m_Plant[season].ToString());
                    object o    = Activator.CreateInstance(type);

                    if (o is BasePlant)
                    {
                        BasePlant plant = (BasePlant)o;

                        m_Plants.Add(plant);

                        Point3D loc = GetSpawnPosition();

                        if (loc != Point3D.Zero)
                        {
                            plant.OnBeforeSpawn(loc, map);

                            plant.MoveToWorld(loc, map);

                            plant.OnAfterSpawn();
                        }
                    }
                }
                catch
                {
                }
            }
        }
Beispiel #48
0
        public void Should_Create_Variation_Of_Specified_Type()
        {
            var plant = new BasePlant();
            plant.DefinePropertiesOf<Person>(new { FirstName = "" });
            plant.DefineVariationOf<Person>("My", new { FirstName = "My" });
            plant.DefineVariationOf<Person>("Her", new { FirstName = "Her" });

            Assert.IsInstanceOf(typeof(Person), plant.Create<Person>());
            Assert.IsInstanceOf(typeof(Person), plant.Create<Person>("My"));
            Assert.IsInstanceOf(typeof(Person), plant.Create<Person>("Her"));
        }
Beispiel #49
0
        public void Should_Create_Variation_With_Extension()
        {
            var plant = new BasePlant();
            plant.DefinePropertiesOf(new House { Color = "blue" }, OnPropertyPopulation);
            plant.DefineVariationOf("My", new House { Color = "My" }, OnPropertyPopulationVariatoion);

            Assert.AreEqual(plant.Create<House>().Persons.First().FirstName, "Pablo");
            Assert.AreEqual(plant.Create<House>("My").Persons.First().FirstName, "Pedro");
        }
Beispiel #50
0
        public void Should_Create_Variation_Of_Specified_Type_With_Correct_Data()
        {
            var plant = new BasePlant();
            plant.DefinePropertiesOf<Person>(new { FirstName = "" });
            plant.DefineVariationOf<Person>("My", new { FirstName = "My" });

            var person = plant.Create<Person>("My");
            Assert.AreEqual("My", person.FirstName);
        }
 public void SetUp()
 {
     plant = new BasePlant().WithBlueprintsFromAssemblyOf <DocumentGroupTableTests>();
 }
 public void SetUp()
 {
     plant = new BasePlant().WithBlueprintsFromAssemblyOf <VariationTests>();
 }
Beispiel #53
0
 public void Should_Create_Instance_With_Null_Value()
 {
     var testPlant = new BasePlant();
     testPlant.DefinePropertiesOf<Person>(new { FirstName = "Barbara", LastName = (string)null });
     Assert.IsNull(testPlant.Create<Person>().LastName);
 }