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)"); }
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)"); }
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. "); }
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); }
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); }
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"); }
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); }
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)"); }