Esempio n. 1
0
        public void When_Container_Is_Valuable_It_Only_Ends_Up_In_Even_Stacks()
        {
            //Arrange
            ShipRow sr = new ShipRow(7);

            //Act
            for (int i = 0; i < 30; i++)
            {
                Container container = ContainerConstructor.CreateContainer(true, false, 30000);
                sr.AddContainer(container);
            }

            //Assert
            for (int i = 0; i < sr.Stacks.Count; i++)
            {
                if (i % 2 == 0)
                {
                    Assert.AreEqual(1, sr.Stacks[i].ContainerCount);
                }
                else
                {
                    Assert.AreEqual(0, sr.Stacks[i].ContainerCount);
                }
            }
        }
Esempio n. 2
0
        public void When_Stack_Already_Has_Valuable_Container_Can_Not_Add_New_Valuable_Container()
        {
            //Arrange
            Stack     s         = new Stack();
            Container valuable1 = ContainerConstructor.CreateContainer(true, false, 5000);
            Container valuable2 = ContainerConstructor.CreateContainer(true, false, 5000);

            //Act
            s.AddContainer(valuable1);

            //Assert
            bool addedContainer   = s.AddContainer(valuable2);
            bool canFindContainer = s.Containers.Contains(valuable2);

            Assert.IsFalse(addedContainer);
            Assert.IsFalse(canFindContainer);
        }
Esempio n. 3
0
        public void When_Container_Is_Cooled_It_Only_Ends_Up_In_First_Stack()
        {
            //Arange
            ShipRow sr = new ShipRow(7);

            //Act
            for (int i = 0; i < 30; i++)
            {
                Container cooledContainer = ContainerConstructor.CreateContainer(false, true, 30000);
                sr.AddContainer(cooledContainer);
            }

            //Assert
            Assert.IsTrue(sr.Stacks[0].ContainerCount > 0);
            for (int i = 1; i < sr.Stacks.Count; i++)
            {
                Assert.AreEqual(0, sr.Stacks[i].ContainerCount);
            }
        }
Esempio n. 4
0
        public void ValuableContainerIsAlwaysOnTopOfTheStack()
        {
            //Arrange
            Stack     s        = new Stack();
            Container c1       = ContainerConstructor.CreateContainer(false, false, 5000);
            Container c2       = ContainerConstructor.CreateContainer(false, false, 5000);
            Container c3       = ContainerConstructor.CreateContainer(false, false, 5000);
            Container valuable = ContainerConstructor.CreateContainer(true, false, 5000);

            //Act
            s.AddContainer(c1);
            s.AddContainer(c2);
            s.AddContainer(c3);
            s.AddContainer(valuable);

            //Assert
            int indexOfValuable = s.Containers.IndexOf(valuable);

            Assert.AreEqual(0, indexOfValuable);
        }
Esempio n. 5
0
        public void When_BottomLoad_Is_Too_High_Container_Will_Fail_To_Add()
        {
            //Arrange
            Stack s = new Stack();

            s.AddContainer(ContainerConstructor.CreateContainer(false, false, 30000));
            s.AddContainer(ContainerConstructor.CreateContainer(false, false, 30000));
            s.AddContainer(ContainerConstructor.CreateContainer(false, false, 30000));
            s.AddContainer(ContainerConstructor.CreateContainer(false, false, 30000));
            s.AddContainer(ContainerConstructor.CreateContainer(false, false, 30000));

            //Act
            Container testContainer = ContainerConstructor.CreateContainer(false, false, 4000);

            //Assert
            bool addedContainer   = s.AddContainer(testContainer);
            bool canFindContainer = s.Containers.Contains(testContainer);

            Assert.IsFalse(addedContainer);
            Assert.IsFalse(canFindContainer);
        }