示例#1
0
        public void AddRoot_PlantDoesntExist_PlantCreatedAndRootAdded()
        {
            Gramene g = new Gramene();

            int rootId = g.TestAddRoot();

            // Verify that the canopy is created.

            int canopy = rootId;

            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(rootId);

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

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

            Assert.AreEqual("plant0", plantLabel);

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

            Assert.AreEqual(rootId, g.GetCursor());
        }
示例#2
0
        public void AddCanopy_NoCanopyBefore_CanopyAddedAndCursorMoved()
        {
            // Add a canopy

            Gramene g        = new Gramene();
            int     canopyId = g.TestAddCanopy();

            // Compare the expected scale of the canopy and the actual one.

            int scaleOfCanopy = g.labelsOfScales.FirstOrDefault(x => x.Value == "canopy").Key;

            Assert.AreEqual(1, scaleOfCanopy);

            Assert.AreEqual(1, g.Scale(canopyId));

            // Verify that the components are correct.

            CollectionAssert.AreEqual(new List <int>()
            {
                canopyId
            }, g.Components(0));

            // Verify that the cursor moved to the newly created canopy.

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

            // Verify that the label of the canopy is "canopy".

            Assert.AreEqual("canopy", g.GetVertexProperties(canopyId)["label"]);
        }