Exemplo n.º 1
0
        public void AddCoolableContainersToStackwithLowestWeight_FillsStacksCorrectly()
        {
            //Assign
            containers = new List <Container>();
            var container  = new Container(Container.type.coolable, 5000);
            var container1 = new Container(Container.type.coolable, 30000);
            var container2 = new Container(Container.type.coolable, 25000);
            var container3 = new Container(Container.type.coolable, 26000);
            var container4 = new Container(Container.type.coolable, 10000);
            var container5 = new Container(Container.type.coolable, 8000);
            var container6 = new Container(Container.type.coolable, 17000);
            var container7 = new Container(Container.type.coolable, 4000);
            var container8 = new Container(Container.type.coolable, 15000);

            containers.Add(container);
            containers.Add(container1);
            containers.Add(container2);
            containers.Add(container3);
            containers.Add(container4);
            containers.Add(container5);
            containers.Add(container6);
            containers.Add(container7);
            containers.Add(container8);


            controlStacks = new List <Stack>();

            for (int i = 0; i < 5; i++)
            {
                Stack stack = new Stack();

                switch (i)
                {
                case 0:
                    stack.AddContainerToStack(containers[1]);
                    break;

                case 1:
                    stack.AddContainerToStack(containers[3]);
                    break;

                case 2:
                    stack.AddContainerToStack(containers[2]);
                    stack.AddContainerToStack(containers[0]);
                    break;

                case 3:
                    stack.AddContainerToStack(containers[6]);
                    stack.AddContainerToStack(containers[5]);
                    stack.AddContainerToStack(containers[7]);
                    break;

                case 4:
                    stack.AddContainerToStack(containers[8]);
                    stack.AddContainerToStack(containers[4]);
                    break;

                default:
                    break;
                }

                controlStacks.Add(stack);
            }

            //Act
            List <Stack> testStack = row.AddCoolablesToStackWithLowestWeight(containers);

            //Assert
            for (int stackId = 0; stackId < testStack.Count(); stackId++)
            {
                for (int containerId = 0; containerId < testStack[stackId].Containers.Count(); containerId++)
                {
                    Assert.AreEqual(controlStacks[stackId].Containers.ElementAt(containerId).ContainerWeight, testStack[stackId].Containers.ElementAt(containerId).ContainerWeight);
                }
            }
        }