Ejemplo n.º 1
0
        public void TestTop()
        {
            var box   = Factory.CreateBox("Box", 10, 10, 10, 0, 10, 10, 10, 100);
            var itemA = Factory.CreateItem("Item A", 5, 10, 10, 10, true);
            var itemB = Factory.CreateItem("Item B", 5, 10, 10, 20, true);

            var packedItemA = new PackedItem(itemA, 0, 0, 0, 5, 10, 10);
            var packedItemB = new PackedItem(itemB, 0, 0, 0, 5, 10, 10);

            var packedItemListA = new PackedItemList();

            packedItemListA.Insert(packedItemA);
            var packedBoxA = new PackedBox(box, packedItemListA);

            var packedItemListB = new PackedItemList();

            packedItemListB.Insert(packedItemB);
            var packedBoxB = new PackedBox(box, packedItemListB);

            var pBoxArray = new PackedBox[] { packedBoxA, packedBoxB };

            var packedBoxList = new PackedBoxList();

            packedBoxList.Insert(packedBoxA);
            packedBoxList.Insert(packedBoxB);

            Assert.Equal(packedBoxA, packedBoxList.Top());
        }
Ejemplo n.º 2
0
        public void TestInsertAndCount()
        {
            var box   = Factory.CreateBox("Box", 10, 10, 10, 0, 10, 10, 10, 100);
            var itemA = Factory.CreateItem("Item A", 5, 10, 10, 10, true);
            var itemB = Factory.CreateItem("Item B", 5, 10, 10, 20, true);

            var packedItemA = new PackedItem(itemA, 0, 0, 0, 5, 10, 10);
            var packedItemB = new PackedItem(itemB, 0, 0, 0, 5, 10, 10);

            var packedItemListA = new PackedItemList();

            packedItemListA.Insert(packedItemA);
            var packedBoxA = new PackedBox(box, packedItemListA);

            var packedItemListB = new PackedItemList();

            packedItemListB.Insert(packedItemB);
            var packedBoxB = new PackedBox(box, packedItemListB);

            var packedBoxList = new PackedBoxList();

            packedBoxList.Insert(packedBoxA);
            packedBoxList.Insert(packedBoxB);

            Assert.Equal(2, packedBoxList.Count);
        }
Ejemplo n.º 3
0
        public void TestGetters()
        {
            var box   = Factory.CreateBox("Box", 370, 375, 60, 140, 364, 374, 40, 3000);
            var oItem = new OrientatedItem(
                Factory.CreateItem("Item", 230, 330, 6, 320, true),
                230,
                330,
                6
                );

            var packedItemList = new PackedItemList();

            packedItemList.Insert(PackedItem.FromOrientatedItem(oItem, 0, 0, 0));

            var pBox = new PackedBox(box, packedItemList);

            Assert.Equal(box.Reference, pBox.Box.Reference);
            Assert.Equal(460, pBox.TotalWeight);

            Assert.Equal(134, pBox.RemainingWidth);
            Assert.Equal(44, pBox.RemainingLength);
            Assert.Equal(34, pBox.RemainingDepth);

            Assert.Equal(2540, pBox.RemainingWeight);

            Assert.Equal(5445440, pBox.InnerVolume);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Generate a single list of items packed.
        /// </summary>
        /// <returns></returns>
        private PackedItemList GetPackedItemList()
        {
            var packedItemList = new PackedItemList();

            foreach (var layer in layers)
            {
                foreach (var packedItem in layer.Items)
                {
                    packedItemList.Insert(packedItem);
                }
            }

            return(packedItemList);
        }
Ejemplo n.º 5
0
        public void TestVolumeUtilisation()
        {
            var box  = Factory.CreateBox("Box", 10, 10, 10, 0, 10, 10, 10, 10);
            var item = Factory.CreateItem("Item", 5, 10, 10, 10, true);

            var packedItem = new PackedItem(item, 0, 0, 0, 5, 10, 10);

            var packedItemList = new PackedItemList();

            packedItemList.Insert(packedItem);
            var packedBox = new PackedBox(box, packedItemList);

            var packedBoxList = new PackedBoxList();

            packedBoxList.Insert(packedBox);

            Assert.Equal(50f, packedBoxList.GetVolumeUtilisation());
        }
Ejemplo n.º 6
0
        public void TestVolumeUtilisation()
        {
            var box   = Factory.CreateBox("Box", 10, 10, 20, 10, 10, 10, 20, 10);
            var oItem = new OrientatedItem(
                Factory.CreateItem("Item", 4, 10, 10, 10, true),
                4,
                10,
                10
                );

            var packedItemList = new PackedItemList();

            packedItemList.Insert(PackedItem.FromOrientatedItem(oItem, 0, 0, 0));

            var pBox = new PackedBox(box, packedItemList);

            Assert.Equal(400, pBox.UsedVolume);
            Assert.Equal(1600, pBox.UnusedVolume);
            Assert.Equal(20, pBox.VolumeUtilizationPercent);
        }