Exemplo n.º 1
0
        public void ThrowAssertForMoreBlocksThanGoals()
        {
            //arrange
            int       height   = 15;
            int       width    = 15;
            IDesigner theLevel = new Designer();

            theLevel.LevelBuilder(height, width);

            theLevel.AddBlock(2, 3);
            theLevel.AddBlock(2, 4);
            theLevel.AddBlock(2, 5);

            theLevel.AddGoal(3, 3);
            theLevel.AddGoal(3, 4);

            theLevel.AddPlayer(1, 1);


            try
            {
                theLevel.checkValid();
            }
            catch (ArgumentException e)
            {
                // assert
                StringAssert.Contains(e.Message, "more blocks than goals");
                return;
            }
            Assert.Fail("No exception was thrown. (Was allowed to have more blocks than goals)");
        }
Exemplo n.º 2
0
        public void ThrowAssertForHavingNoPlayer()
        {
            //arrange
            int       height   = 15;
            int       width    = 15;
            IDesigner theLevel = new Designer();

            theLevel.LevelBuilder(height, width);

            theLevel.AddBlock(2, 3);
            theLevel.AddGoal(3, 5);


            try
            {
                theLevel.checkValid();
            }
            catch (ArgumentException e)
            {
                // assert
                StringAssert.Contains(e.Message, "No player");
                return;
            }
            Assert.Fail("No exception was thrown. (Was allowed to have no player)");
        }
Exemplo n.º 3
0
        public void FindGoalIndex()
        {
            //arrange
            int       height   = 15;
            int       width    = 15;
            IDesigner theLevel = new Designer();

            theLevel.LevelBuilder(height, width);
            theLevel.AddGoal(2, 2);
            theLevel.AddGoal(3, 2);
            theLevel.AddGoal(4, 2);

            //act
            string testing = theLevel.LocateParts(Parts.Goal);

            //assert
            Assert.AreEqual(testing, "Goal at 2,2. Goal at 3,2. Goal at 4,2. ");
        }
Exemplo n.º 4
0
        public void AddGoal()
        {
            int       width    = 10;
            int       height   = 12;
            IDesigner theLevel = new Designer();

            theLevel.LevelBuilder(width, height);

            theLevel.AddGoal(2, 5);
            Assert.AreEqual(theLevel.GetPartAtIndex(2, 5), Parts.Goal);
        }
Exemplo n.º 5
0
        public void TestIfGoalReturnsString()
        {
            //arrange
            int       height   = 15;
            int       width    = 15;
            IDesigner theLevel = new Designer();

            theLevel.LevelBuilder(height, width);

            theLevel.AddGoal(2, 2);

            string theType = theLevel.GetPartAtIndex(2, 2).ToString();

            Assert.IsInstanceOfType(theType, typeof(string), "Expected a string but got  something else. Please check!");

            Assert.AreEqual(theType, "Goal");
        }
Exemplo n.º 6
0
        public void Level_WhenAddingGoalOnBlock_ShouldHaveBlockOnGoal()
        {
            //arrange
            int       height   = 10;
            int       width    = 10;
            IDesigner theLevel = new Designer();

            theLevel.LevelBuilder(height, width);
            theLevel.AddBlock(1, 2);

            //act
            theLevel.AddGoal(1, 2);

            //assert

            Assert.AreEqual(theLevel.GetPartAtIndex(1, 2), Parts.BlockOnGoal);
        }
Exemplo n.º 7
0
        public void ThrowAssertForAddingGoalOutsideAGrid()
        {
            //arrange
            int       height   = 5;
            int       width    = 8;
            IDesigner theLevel = new Designer();

            theLevel.LevelBuilder(height, width);

            //Check that IndexOutOfRangeException is thrown if
            //attempting to add something outside of the grid

            try
            {
                theLevel.AddGoal(5, 9);
            }
            catch (ArgumentException e)
            {
                // assert
                StringAssert.Contains(e.Message, OutOfGridMessage);
                return;
            }
            Assert.Fail("No exception was thrown. (Was allowed to place Goal outside of Grid)");
        }