public void Should_Throw_Argument_Exception_When_Invalid_Maze_Loaded_Expect_Maze_Not_To_Be_Displayed_As_ArgumentExceptionThrown() { this.mazeLoaderMock.Setup(x => x.LoadMaze()).Returns(MazeTestValues.ValidMazeExample()); this.mazeValidatorMock.Setup(x => x.IsMazeValid(It.IsAny <string[]>())).Returns(false); var mazeGrid = this.mazeGridGenerator.DisplayGrid(); }
public void Should_Be_Able_To_Display_Grid_When_Valid_Maze_Is_Loaded_Expect_Grid_To_Be_Displayed() { this.mazeGridGeneratorMock.Setup(x => x.DisplayGrid()).Returns(MazeTestValues.ValidMazeExample()); var result = this.maze.DisplayGrid(); result.Should().BeEquivalentTo(MazeTestValues.ValidMazeExample()); }
public void Should_Be_Able_To_Load_MazeFile_Expect_MazeFile_Is_Same_When_Loaded() { string mazeFileName = "ExampleMaze.txt"; IMazeLoader mazeFileLoader = new MazeFileLoader(mazeFileName); mazeFileLoader.LoadMaze().Should().NotBeNull(); mazeFileLoader.LoadMaze().Should().BeEquivalentTo(MazeTestValues.ValidMazeExample()); }
private void SetUpExplorerRecordedMovesMock() { this.mazeMock.Setup(x => x.DisplayStartPoint()).Returns(MazeTestValues.GetCurrentPositionMock()); this.moveHandlerMock.Setup(x => x.MoveForward(It.IsAny <Facing>(), It.IsAny <Position>())) .ReturnsInOrder(new Position(4, 11), new Position(5, 11), new Position(6, 11)); this.movementAnalyserMock.Setup(x => x.GetAllPossibleMovements(It.IsAny <Facing>(), It.IsAny <Position>())) .Returns(this.GetAllMovementOptionMock()); }
public void Should_Throw_ArgumentException_When_No_Grid_Is_Created_Expect_ArgumentException_To_Be_Thrown() { this.mazeLoaderMock.Setup(x => x.LoadMaze()).Returns(MazeTestValues.InValidMazeNoStartExample()); this.mazeValidatorMock.Setup(x => x.IsMazeValid(It.IsAny <string[]>())).Returns(false); this.mazeGridGenerator.CreateGrid(); this.mazeGridGenerator.GetStartPoint(); }
public void Should_Move_Explorer_Forward_When_Facing_West_Expect_Position_Updated() { this.explorerPosition.Setup(x => x.West(It.IsAny <Position>())).Returns(new Position(2, 11)); var newPosition = this.moveHandler.MoveForward(Facing.West, MazeTestValues.GetCurrentPositionMock()); var expectedPositon = new Position(2, 11); newPosition.xCoordinate.Should().Be(2); newPosition.yCoordinate.Should().Be(11); }
public void Should_Be_Able_To_Create_Maze_Grid_When_Maze_Loaded_IsValid_Expect_Maze_Grid_To_Be_Created() { this.mazeLoaderMock.Setup(x => x.LoadMaze()).Returns(MazeTestValues.ValidMazeExample()); this.mazeValidatorMock.Setup(x => x.IsMazeValid(It.IsAny <string[]>())).Returns(true); var mazeGrid = this.mazeGridGenerator.CreateGrid(); mazeGrid.Should().NotBeNull(); }
public void Should_Be_Able_To_DisplayGrid_when_Maze_Loaded_IsValid_Expect_Maze_To_Be_Displayed() { this.mazeLoaderMock.Setup(x => x.LoadMaze()).Returns(MazeTestValues.ValidMazeExample()); this.mazeValidatorMock.Setup(x => x.IsMazeValid(It.IsAny <string[]>())).Returns(true); var mazeGrid = this.mazeGridGenerator.DisplayGrid(); mazeGrid.Should().NotBeNull(); mazeGrid.Should().BeEquivalentTo(MazeTestValues.ValidMazeExample()); }
public void Should_Be_Able_To_Find_Maze_Start_Point_Expect_Start_Point_To_Be_Returned() { int x = 0; int y = 8; var expectedLocation = new Position(x, y); var result = this.mazePositionFinder.FindStart(MazeTestValues.GetValidMazeGrid()); result.Should().Be(expectedLocation); }
public void Should_Drop_Explorer_At_Start_Point_Expect_Explorer_To_Be_At_Start_Coordinate_3_11() { this.mazeMock.Setup(i => i.DisplayStartPoint()).Returns(MazeTestValues.GetCurrentPositionMock()); var explorerPosition = explorer.DropAtStartPoint(); var expectedPosition = MazeTestValues.GetCurrentPositionMock(); explorerPosition.Should().Be(expectedPosition); explorerPosition.xCoordinate.Should().Be(3); explorerPosition.yCoordinate.Should().Be(11); }
public void Should_Be_Able_To_Get_Maze_Start_Point_Expect_Start_Point_To_Be_Returned() { this.mazePositionFinder.Setup(i => i.FindStart(It.IsAny <string[, ]>())).Returns(new Position(11, 3)); this.mazeValidatorMock.Setup(i => i.IsMazeValid(It.IsAny <string[]>())).Returns(true); this.mazeLoaderMock.Setup(i => i.LoadMaze()).Returns(MazeTestValues.ValidMazeExample()); int x = 11; int y = 3; var expectedLocation = new Position(x, y); this.mazeGridGenerator.CreateGrid(); var result = this.mazeGridGenerator.GetStartPoint(); result.Should().Be(expectedLocation); }
public void Should_UnderStand_What_Is_Ahead_Infront_Of_Explorer_When_Faced_With_NoWall_Expect_NoWall_Detected() { this.movementAnalyserMock.Setup(i => i.GetMovementAhead(It.IsAny <Facing>(), It.IsAny <Position>())) .Returns(new MovementOption() { Position = MazeTestValues.GetCurrentPositionMock(), Value = noWall }); var movementOption = this.explorer.GetMovementAheadOption(); var expectedPosition = MazeTestValues.GetCurrentPositionMock(); movementOption.Position.Should().Be(expectedPosition); string expectnoWall = noWall; movementOption.Value.Should().Be(expectnoWall); }
public void Should_Be_Able_To_View_Recorded_Moves_Made_By_Explorer_When_Exit_Found_Expect_A_Recoreded_List_Of_Moves() { this.SetUpExplorerRecordedMovesMock(); this.explorer.DropAtStartPoint(); this.explorer.MoveForward(); this.explorer.MoveForward(); this.explorer.MoveForward(); this.explorer.TurnRight(); this.explorer.TurnLeft(); var movesMade = this.explorer.ExitMaze(MazeTestValues.GetCurrentPositionMock()); movesMade[0].Should().Be("Explorer Moved Forward to position (4,11)."); movesMade[1].Should().Be("Explorer Moved Forward to position (5,11)."); movesMade[2].Should().Be("Explorer Moved Forward to position (6,11)."); movesMade[3].Should().Be("Explorer Turned Right now facing North."); movesMade[4].Should().Be("Explorer Turned Left now facing North."); movesMade[5].Should().Be("Explorer has Exit the Maze at position (3,11)."); }
public void Should_UnderStand_What_Is_Infront_Of_Explorer_When_Faced_With_NoWall_Expect_NoWall_Detected() { this.mazeMock.Setup(x => x.DisplayCellValue(It.IsAny <Position>())).Returns(noWall); var movementOption = this.movementAnalyser.GetMovementAhead(Facing.North, MazeTestValues.GetCurrentPositionMock()); var expectedPosition = new Position(3, 11); movementOption.Position.Should().Be(expectedPosition); string expectNoWall = string.Empty; movementOption.Value.Should().Be(expectNoWall); }
public void Should_Understand_All_Options_Of_Movement_Before_Explorer_Moves_At_Position_Expect_List_Of_Options_To_Be_Provided() { this.mazeMock.Setup(x => x.DisplayCellValue(It.IsAny <Position>())).ReturnsInOrder(wall, noWall, wall, wall); this.SetUpExplorerPositionMock(); var movementOptions = this.movementAnalyser.GetAllPossibleMovements(Facing.East, MazeTestValues.GetCurrentPositionMock()); movementOptions[0].Position.Should().Be(new Position(3, 12)); movementOptions[0].Value.Should().Be(wall); movementOptions[1].Position.Should().Be(new Position(4, 11)); movementOptions[1].Value.Should().Be(string.Empty); movementOptions[2].Position.Should().Be(new Position(3, 10)); movementOptions[2].Value.Should().Be(wall); movementOptions[3].Position.Should().Be(new Position(2, 11)); movementOptions[3].Value.Should().Be(wall); }
public void Should_Throw_ArgumentException_When_Grid_Has_No_Start_Point_Expect_ArgumentException_To_Be_Thrown() { var result = this.mazePositionFinder.FindStart(MazeTestValues.GetInValidMazeGrid()); }
Should_Check_Has_Only_One_Exit_F_Exists_When_Loaded_With_Valid_MazeData_Expect_True_To_Be_Returned() => this.mazeValidator.HasOnlyOneExit(MazeTestValues.GetValidMazeCellElements()).Should().BeTrue();
public void Init() { this.mazeGridGeneratorMock = new Mock <IMazeGridGenerator>(); this.maze = new core.Maze(mazeGridGeneratorMock.Object); this.mazeGridGeneratorMock.Setup(x => x.CreateGrid()).Returns(MazeTestValues.GetValidMazeGrid()); }
Should_Check_Is_Not_Maze_Valid_When_Loaded_With_InValid_MazeData_Expect_False_To_Be_Returned() => this.mazeValidator.IsMazeValid(MazeTestValues.InValidMazeExample()).Should().BeFalse();
Should_Check_Is_Maze_Valid_When_Loaded_With_Valid_MazeData_Expect_True_To_Be_Returned() => this.mazeValidator.IsMazeValid(MazeTestValues.ValidMazeExample()).Should().BeTrue();
Should_Check_Has_MoreThan_One_Exit_F_Exists_When_Loaded_With_Invalid_MazeData_Expect_False_To_Be_Returned() => this.mazeValidator.HasOnlyOneExit(MazeTestValues.GetInValidMazeCellElements()).Should().BeFalse();