Exemplo n.º 1
0
        public void GetPlantLeafNumber_TwoPlants_CorrectTotal()
        {
            Gramene g = new Gramene();

            // Create a plant with two axes

            g.TestAddCanopy();
            g.TestAddPlant();
            g.TestAddRoot();
            g.TestAddShoot();

            int axis1 = g.TestAddAxis();

            // This axis contains 5 leaves

            for (int i = 0; i < 5; i++)
            {
                g.AddLeaf();
            }

            // The second axis contains one leaf

            int axis2 = g.TestAddAxis();

            g.AddLeaf();

            // Create a second plant with one axis and two leaves

            g.TestAddPlant();
            g.TestAddRoot();
            g.TestAddShoot();
            int axis3 = g.TestAddAxis();

            g.AddLeaf();
            g.AddLeaf();

            // Verify that we get the right number of leaves per axis

            Assert.AreEqual(5, g.GetLeafNumber(axis1));
            Assert.AreEqual(1, g.GetLeafNumber(axis2));
            Assert.AreEqual(2, g.GetLeafNumber(axis3));

            // Verify that the total leaf number is different for each plant

            g.SetCursor(axis1);
            Assert.AreEqual(5 + 1, g.GetPlantLeafNumber());

            g.SetCursor(axis3);
            Assert.AreEqual(2, g.GetPlantLeafNumber());
        }
Exemplo n.º 2
0
        public void AddShoot_PlantExists_ShootCreated()
        {
            Gramene g = new Gramene();

            int plantId = g.TestAddPlant();

            Assert.AreEqual(plantId, g.GetCursor());

            int shootId = g.TestAddShoot();

            Assert.AreEqual(shootId, g.GetCursor());

            // Verification of the scale.

            Assert.AreEqual(g.Scale(plantId) + 1, g.Scale(shootId));

            // Verification of the label.

            string plantNb = g.GetVertexProperties(plantId)["label"].Substring(5);

            Assert.AreEqual("shoot" + plantNb, g.GetVertexProperties(shootId)["label"]);

            // Verification of the complex.

            Assert.AreEqual(plantId, g.Complex(shootId));
        }
Exemplo n.º 3
0
        public void AddShoot_PlantDoesntExist_PlantCreatedAndShootAdded()
        {
            Gramene g = new Gramene();

            int shootId = g.TestAddShoot();

            // Verify that the canopy is created.

            int canopy = shootId;

            while (g.Scale(canopy) != 1)
            {
                canopy = (int)g.Complex(canopy);
            }

            Assert.AreEqual(1, g.Scale(canopy));
            CollectionAssert.AreEqual(new List <int>()
            {
                canopy
            }, g.Components(0));

            // Verify that the plant is created.

            int plant = (int)g.Complex(shootId);

            Assert.AreEqual(2, g.Scale(plant));

            string plantLabel = g.GetVertexProperties(plant)["label"];

            Assert.AreEqual("plant", plantLabel.Substring(0, 5));

            // Verify that the cursor is placed on the shoot.

            Assert.AreEqual(shootId, g.GetCursor());
        }
Exemplo n.º 4
0
        public void AddShoot_PlantAlreadyHasShoot_NewPlantCreatedAndShootAdded()
        {
            Gramene g = new Gramene();

            // First shoot created.

            int shootId1  = g.TestAddShoot();
            int plantId1  = (int)g.Complex(shootId1);
            int canopyId1 = (int)g.Complex(plantId1);

            // Second shoot created.

            int shootId2  = g.TestAddShoot();
            int plantId2  = (int)g.Complex(shootId2);
            int canopyId2 = (int)g.Complex(plantId2);

            // Verify that the plants aren't the same but the canopy is.

            Assert.AreEqual(canopyId1, canopyId2);
            Assert.AreNotEqual(plantId1, plantId2);

            Assert.AreEqual("shoot0", g.GetVertexProperties(shootId1)["label"]);
            Assert.AreEqual("shoot1", g.GetVertexProperties(shootId2)["label"]);
        }
Exemplo n.º 5
0
        public void GetPlantLeafNumber_TwoAxes_CorrectTotal()
        {
            Gramene g = new Gramene();

            // Create a plant with 2 axes

            g.TestAddCanopy();
            g.TestAddPlant();
            g.TestAddRoot();
            g.TestAddShoot();

            int axis1 = g.TestAddAxis();

            // First axis contains 5 leaves

            for (int i = 0; i < 5; i++)
            {
                g.AddLeaf();
            }

            // Second axis contains 2 leaves

            int axis2 = g.TestAddAxis();

            g.AddLeaf();
            g.AddLeaf();

            // Verify that we get the right number of leaves per axis

            Assert.AreEqual(5, g.GetLeafNumber(axis1));
            Assert.AreEqual(2, g.GetLeafNumber(axis2));
            Assert.AreEqual(2, g.GetLeafNumber());

            // Verify that the total is the sum of both axes

            Assert.AreEqual(7, g.GetPlantLeafNumber());
        }