示例#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)");
        }
示例#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)");
        }
示例#3
0
        public void FindBlockIndex()
        {
            //arrange
            int       height   = 15;
            int       width    = 15;
            IDesigner theLevel = new Designer();

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

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

            //assert
            Assert.AreEqual(testing, "Block at 2,2. Block at 3,2. ");
        }
示例#4
0
        public void AddBlock()
        {
            int       width    = 10;
            int       height   = 12;
            IDesigner theLevel = new Designer();

            theLevel.LevelBuilder(width, height);

            theLevel.AddBlock(2, 5);
            Assert.AreEqual(theLevel.GetPartAtIndex(2, 5), Parts.Block);
        }
示例#5
0
        public void GetMoveableBlockAtIndex()
        {
            int       width    = 10;
            int       height   = 12;
            IDesigner theLevel = new Designer();

            theLevel.LevelBuilder(width, height);

            //act
            theLevel.AddBlock(1, 5);

            Assert.AreEqual(theLevel.GetPartAtIndex(1, 5), Parts.Block);
        }
示例#6
0
        public void TestIfBlockReturnsString()
        {
            //arrange
            int       height   = 15;
            int       width    = 15;
            IDesigner theLevel = new Designer();

            theLevel.LevelBuilder(height, width);

            theLevel.AddBlock(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, "Block");
        }
示例#7
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);
        }
示例#8
0
        public void ThrowAssertForAddingBlockOutsideAGrid()
        {
            //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.AddBlock(5, 9);
            }
            catch (ArgumentException e)
            {
                // assert
                StringAssert.Contains(e.Message, OutOfGridMessage);
                return;
            }
            Assert.Fail("No exception was thrown. (Was allowed to place Block outside of Grid)");
        }