Beispiel #1
0
        /// <summary>
        /// Rendering the objects inside of the container.
        /// </summary>
        /// <param name="objectsInformation">The information of the objects
        /// which shall be visualized</param>
        public void RenderObjects(List <ObjectInfo> objectsInformation)
        {
            RectTransform rectTransform = container.GetComponent <RectTransform>();

            rectTransform.sizeDelta = new Vector2(containerWidth, containerHeight);
            if (itemToShow != null)
            {
                DeleteItems();

                if (objectsInformation.Count > 0)
                {
                    ObjectInfo firstObject = objectsInformation[0];

                    Vector3 scaleSize = FormationUtility.GetScaleSize(itemToShow, firstObject.Width);

                    foreach (ObjectInfo objectInfo in objectsInformation)
                    {
                        GameObject currentItem = GameObject.Instantiate(itemToShow);
                        currentItem.transform.parent        = container.transform;
                        currentItem.transform.localPosition = objectInfo.Position;

                        currentItem.transform.localScale = scaleSize;

                        itemList.Add(currentItem);
                    }
                }
            }
        }
        public void HeightGreaterWidthTest()
        {
            int containerWidth  = 50;
            int containerHeight = 100;
            int itemCount       = 4;

            List <ObjectInfo> objectsInfoList = FormationUtility.GetGridFormationObjectsInformation(containerWidth, containerHeight, itemCount);

            Assert.AreEqual(objectsInfoList.Count, itemCount);

            Vector2[] expectedPositions = new Vector2[4];
            expectedPositions[0] = new Vector2(0.0f, 0.0f);
            expectedPositions[1] = new Vector2(25.0f, 0.0f);
            expectedPositions[2] = new Vector2(0.0f, -25.0f);
            expectedPositions[3] = new Vector2(25.0f, -25.0f);

            for (int i = 0; i < objectsInfoList.Count; i++)
            {
                ObjectInfo objectInfo = objectsInfoList[i];
                Assert.AreEqual(expectedPositions[i].x, objectInfo.Position.x);
                Assert.AreEqual(expectedPositions[i].y, objectInfo.Position.y);

                objectInfo.Width = 25;
            }
        }
Beispiel #3
0
        public void OnRandomFormationClick()
        {
            if (itemToShow != null)
            {
                List <ObjectInfo> objectInformation = FormationUtility.GetRandomFormationObjectsInformation(containerWidth, containerHeight, itemCount);

                RenderObjects(objectInformation);
            }
        }
        public void HeightGreaterWidthOverlapTest()
        {
            int containerWidth  = 50;
            int containerHeight = 100;
            int itemCount       = 4;

            List <ObjectInfo> objectsInfoList = FormationUtility.GetGridFormationObjectsInformation(containerWidth, containerHeight, itemCount);

            TestHelper.OverLappingTest(objectsInfoList);
        }
Beispiel #5
0
        public void HorizontalLineFormationOverlappingTest()
        {
            int containerWidth  = 300;
            int containerHeight = 100;
            int itemCount       = 10;

            List <ObjectInfo> objectsInfoList = FormationUtility.GetHorizontalLineFormationObjectsInformation(containerWidth, containerHeight, itemCount);

            TestHelper.OverLappingTest(objectsInfoList);
        }
        public void ZeroItemsTest()
        {
            int containerWidth  = 100;
            int containerHeight = 100;
            int itemCount       = 0;

            List <ObjectInfo> objectsInfoList = FormationUtility.GetGridFormationObjectsInformation(containerWidth, containerHeight, itemCount);

            Assert.AreEqual(objectsInfoList.Count, itemCount);
        }
        public void TwoItemsOverlapTest()
        {
            int containerWidth  = 100;
            int containerHeight = 100;
            int itemCount       = 2;

            List <ObjectInfo> objectsInfoList = FormationUtility.GetCircleFormationObjectsInformation(containerWidth, containerHeight, itemCount);

            TestHelper.OverLappingTest(objectsInfoList);
        }
        public void WidthHeightUnequalTest()
        {
            int containerWidth  = 50;
            int containerHeight = 100;
            int itemCount       = 5;

            List <ObjectInfo> objectsInfoList = FormationUtility.GetCircleFormationObjectsInformation(containerWidth, containerHeight, itemCount);

            Assert.AreEqual(objectsInfoList.Count, itemCount);
        }
Beispiel #9
0
        public void OneItemOverlappingTest()
        {
            int containerWidth  = 100;
            int containerHeight = 100;
            int itemCount       = 1;

            List <ObjectInfo> objectsInfoList = FormationUtility.GetRandomFormationObjectsInformation(containerWidth, containerHeight, itemCount);

            TestHelper.OverLappingTest(objectsInfoList);
        }
Beispiel #10
0
        public void OneItemTest()
        {
            int containerWidth  = 100;
            int containerHeight = 100;
            int itemCount       = 1;

            List <ObjectInfo> objectsInfoList = FormationUtility.GetRandomFormationObjectsInformation(containerWidth, containerHeight, itemCount);

            Assert.AreEqual(objectsInfoList.Count, itemCount);
        }
        public void TenItemContainingTest()
        {
            int containerWidth  = 100;
            int containerHeight = 100;
            int itemCount       = 10;

            Rect containerBounds = new Rect(0, 0, containerWidth, containerHeight);

            List <ObjectInfo> objectsInfoList = FormationUtility.GetGridFormationObjectsInformation(containerWidth, containerHeight, itemCount);

            TestHelper.CheckIfAllObjectsInsideContainer(containerBounds, objectsInfoList);
        }
Beispiel #12
0
        public void HorizontalLineFormationTest()
        {
            int containerWidth  = 300;
            int containerHeight = 100;
            int itemCount       = 10;

            List <ObjectInfo> objectsInfoList = FormationUtility.GetHorizontalLineFormationObjectsInformation(containerWidth, containerHeight, itemCount);

            Assert.AreEqual(objectsInfoList.Count, itemCount);

            foreach (ObjectInfo objectInfo in objectsInfoList)
            {
                Assert.AreEqual(-35, objectInfo.Position.y);
            }
        }
        public void OneItemTest()
        {
            int containerWidth  = 100;
            int containerHeight = 100;
            int itemCount       = 1;

            List <ObjectInfo> objectsInfoList = FormationUtility.GetCircleFormationObjectsInformation(containerWidth, containerHeight, itemCount);

            Assert.AreEqual(objectsInfoList.Count, itemCount);

            Assert.AreEqual(25.0f, objectsInfoList[0].Position.x);
            Assert.AreEqual(-25.0f, objectsInfoList[0].Position.y);

            Assert.AreEqual(50.0f, objectsInfoList[0].Width);
        }
        public void TwoItemsTest()
        {
            int containerWidth  = 100;
            int containerHeight = 100;
            int itemCount       = 2;

            List <ObjectInfo> objectsInfoList = FormationUtility.GetCircleFormationObjectsInformation(containerWidth, containerHeight, itemCount);

            Assert.AreEqual(objectsInfoList.Count, itemCount);

            Vector2[] expectedPositions = new Vector2[2];
            expectedPositions[0] = new Vector2(25, 0);
            expectedPositions[1] = new Vector2(25, -50);

            for (int i = 0; i < objectsInfoList.Count; i++)
            {
                Assert.AreEqual(expectedPositions[i].x, objectsInfoList[i].Position.x, 0.0001);
                Assert.AreEqual(expectedPositions[i].y, objectsInfoList[i].Position.y, 0.0001);
            }
        }