Ejemplo n.º 1
0
        public void TryPlaceContainer_ShouldMoveValuableToTop()
        {
            // Arrange
            Stack      stack           = new Stack(true, true);
            IContainer valContainer    = new ValuableContainer();
            IContainer coolContainer   = new CoolContainer();
            IContainer normalContainer = new NormalContainer();

            // Act
            stack.TryPlaceContainer(valContainer);
            stack.TryPlaceContainer(coolContainer);
            stack.TryPlaceContainer(normalContainer);

            // Assert
            Assert.Equal(valContainer, stack.Containers[2]);
        }
Ejemplo n.º 2
0
        public void Check_ShipWeight_True()
        {
            //In this test I will check the weight check.
            List <NormalContainer> listContainers = new List <NormalContainer>();
            NormalContainer        container1     = new NormalContainer(60000);
            NormalContainer        container2     = new NormalContainer(60000);

            ship.width  = 2;
            ship.length = 1;
            balanceAlgorithme.SetShip(ship);
            listContainers.Add(container1);
            listContainers.Add(container2);
            balanceAlgorithme.nList = listContainers;

            //Act
            balanceAlgorithme.FillShip();

            //Assert
            Assert.AreEqual(true, ship.CheckForCapSize());
        }
Ejemplo n.º 3
0
        public void Check_ShipBalance_True()
        {
            //In this method I will check the ship balance.
            List <NormalContainer> listContainers = new List <NormalContainer>();
            NormalContainer        container1     = new NormalContainer(60000);
            NormalContainer        container2     = new NormalContainer(60000);
            NormalContainer        container3     = new NormalContainer(60000);
            NormalContainer        container4     = new NormalContainer(60000);

            ship.width  = 2;
            ship.length = 2;
            balanceAlgorithme.SetShip(ship);
            listContainers.Add(container1);
            listContainers.Add(container2);
            balanceAlgorithme.nList = listContainers;

            //Act
            balanceAlgorithme.FillShip();
            ship.CheckBalance();
            //Assert
            Assert.AreEqual(true, ship.IsInBalance);
        }
Ejemplo n.º 4
0
        public void Check_ShipBalance_False()
        {
            //In this method I will check the ship balance.
            List <NormalContainer> listContainers = new List <NormalContainer>();
            NormalContainer        container1     = new NormalContainer(60000);
            NormalContainer        container2     = new NormalContainer(60000);
            NormalContainer        container3     = new NormalContainer(60000);

            ship.width  = 2;
            ship.length = 1;
            balanceAlgorithme.SetShip(ship);
            listContainers.Add(container1);
            listContainers.Add(container2);
            balanceAlgorithme.nList = listContainers;

            //Act
            balanceAlgorithme.FillShip();
            //Now we insert a container on the right side, this will trigger a unbalanced ship.
            ship.rows[0].Stacks[1].AddContainerToStack(container3);
            ship.CheckBalance();
            //Assert
            Assert.AreEqual(false, ship.IsInBalance);
        }
Ejemplo n.º 5
0
        public void Max_Weight_Test()
        {
            // In this test I will test my algorithm will not place the container if the weight is above 120 ton
            List <NormalContainer> listContainer = new List <NormalContainer>();
            NormalContainer        container1    = new NormalContainer(120001);
            NormalContainer        container2    = new NormalContainer(250);

            ship.width  = 2;
            ship.length = 1;
            balanceAlgorithme.SetShip(ship);
            listContainer.Add(container1);
            listContainer.Add(container2);
            balanceAlgorithme.nList = listContainer;

            //Act
            balanceAlgorithme.FillShip();
            int row1 = ship.rows[0].Stacks[0].weight;
            int row2 = ship.rows[0].Stacks[1].weight;

            //Assert
            Assert.AreEqual(120001, row1);
            Assert.AreEqual(250, row2);
        }
Ejemplo n.º 6
0
        public void Place_HeaviestContainer_OnBottom()
        {
            //In this test I will test I can place the heaviest container on the bottom I will need 2 containers
            List <NormalContainer> listContainer = new List <NormalContainer>();
            NormalContainer        container1    = new NormalContainer(250);
            NormalContainer        container2    = new NormalContainer(300);

            ship.width  = 1;
            ship.length = 1;
            balanceAlgorithme.SetShip(ship);
            listContainer.Add(container1);
            listContainer.Add(container2);
            balanceAlgorithme.nList = listContainer;

            //Act
            balanceAlgorithme.FillShip();
            int containerUnder = ship.rows[0].Stacks[0].containers[0].weight;
            int containerAbove = ship.rows[0].Stacks[0].containers[1].weight;

            //Arrange
            Assert.AreEqual(container2.weight, containerUnder);
            Assert.AreEqual(container1.weight, containerAbove);
        }