Пример #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 Level_WhenAddingPlayerTwice_ShouldRemoveFirst()
        {
            //Can't have two players, if there is already one when method called, the method should get rid of the first
            //arrange
            int       height   = 10;
            int       width    = 10;
            IDesigner theLevel = new Designer();

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

            //act
            theLevel.AddPlayer(2, 2);

            //assert
            Assert.AreEqual(theLevel.GetPartAtIndex(1, 2), Parts.Empty);
        }
Пример #3
0
        public void GetMoveablePlayerAtIndex()
        {
            int       width    = 10;
            int       height   = 12;
            IDesigner theLevel = new Designer();

            theLevel.LevelBuilder(width, height);

            //act
            theLevel.AddPlayer(1, 1);
            // X is player
            Assert.AreEqual(theLevel.GetPartAtIndex(1, 1), Parts.Player);
        }
Пример #4
0
        public void AddPlayer()
        {
            int       width    = 10;
            int       height   = 12;
            IDesigner theLevel = new Designer();

            theLevel.LevelBuilder(width, height);

            //act
            theLevel.AddPlayer(0, 0);

            //check
            Assert.AreEqual(theLevel.GetPartAtIndex(0, 0), Parts.Player);
        }
Пример #5
0
        public void FindPlayerIndex()
        {
            //arrange
            int       height   = 15;
            int       width    = 15;
            IDesigner theLevel = new Designer();

            theLevel.LevelBuilder(height, width);
            theLevel.AddPlayer(2, 2);

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

            //assert
            Assert.AreEqual(testing, "Player at 2,2. ");
        }
Пример #6
0
        public void DeletePlayerGetsRidOfPlayer()
        {
            //arrange
            int       height   = 15;
            int       width    = 14;
            IDesigner theLevel = new Designer();

            theLevel.LevelBuilder(height, width);
            theLevel.AddPlayer(2, 2);

            //act
            theLevel.deletePlayer();

            //assert
            Assert.AreEqual(theLevel.GetPartAtIndex(2, 2), Parts.Empty);
        }
Пример #7
0
        public void TestIfPlayerReturnsString()
        {
            //arrange
            int       height   = 15;
            int       width    = 15;
            IDesigner theLevel = new Designer();

            theLevel.LevelBuilder(height, width);

            theLevel.AddPlayer(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, "Player");
        }
Пример #8
0
        public void Level_WhenAddingGoalOnPlayer_ShouldHavePlayerOnGoal()
        {
            //arrange
            int       height   = 10;
            int       width    = 10;
            IDesigner theLevel = new Designer();

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

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

            //assert

            Assert.AreEqual(theLevel.GetPartAtIndex(1, 2), Parts.PlayerOnGoal);
        }
Пример #9
0
        public void ThrowAssertForAddingPLayerOutsideAGrid()
        {
            //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.AddPlayer(5, 9);
            }
            catch (ArgumentException e)
            {
                // assert
                StringAssert.Contains(e.Message, OutOfGridMessage);
                return;
            }
            Assert.Fail("No exception was thrown. (Was allowed to place Player outside of Grid)");
        }