コード例 #1
0
ファイル: UnitTest1.cs プロジェクト: jav244/sokoban
        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
ファイル: UnitTest1.cs プロジェクト: jav244/sokoban
        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
ファイル: UnitTest1.cs プロジェクト: jav244/sokoban
        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
ファイル: UnitTest1.cs プロジェクト: jav244/sokoban
        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
ファイル: UnitTest1.cs プロジェクト: jav244/sokoban
        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
ファイル: UnitTest1.cs プロジェクト: jav244/sokoban
        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
ファイル: UnitTest1.cs プロジェクト: jav244/sokoban
        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
ファイル: UnitTest1.cs プロジェクト: jav244/sokoban
        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
ファイル: UnitTest1.cs プロジェクト: jav244/sokoban
        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)");
        }