예제 #1
0
        public async Task IsStillMovingOnAsync_ShouldReturnTrueIfDancerDoesNotMoveAnywhereDueToMines()
        {
            //Arrange
            var tiles        = new Tile[3, 2];
            var mines        = new Mine[] { new Mine(1, 1) };
            var exitPoint    = new ExitPoint(0, 0);
            var mockedTurtle = new Mock <IDancer>();

            mockedTurtle.SetupGet(x => x.Tile).Returns(mines.First());

            var movements = new Movement[] { Movement.LeftRotate, Movement.RightRotate };

            mockedMovementFactory.Setup(x => x.GetNextMovementsAsync()).Returns(Task.FromResult(movements));

            minefield = new Minefield(mockedMovementFactory.Object, tiles, mines, exitPoint, mockedTurtle.Object);

            //Act
            var isFinished = await minefield.IsStillMovingOnAsync();

            //Assert
            Assert.IsTrue(isFinished);
        }
예제 #2
0
        public async Task IsStillMovingOnAsync_ShouldReturnTrueAfterMineOrExitPointDoNotFound()
        {
            //Arrange
            var testTile = new Tile(0, 1);
            var tiles    = new Tile[3, 2];
            var mines    = new Mine[] { new Mine(1, 1), new Mine(1, 0) };

            var mockedTurtle = new Mock <IDancer>();

            mockedTurtle.SetupGet(x => x.Tile).Returns(testTile);

            var movements = new Movement[] { Movement.Move, Movement.LeftRotate, Movement.Move, Movement.RightRotate, Movement.Move };

            mockedMovementFactory.Setup(x => x.GetNextMovementsAsync()).Returns(Task.FromResult(movements));

            minefield = new Minefield(mockedMovementFactory.Object, tiles, mines, new ExitPoint(0, 0), mockedTurtle.Object);

            //Act
            var isFinished = await minefield.IsStillMovingOnAsync();

            //Assert
            Assert.IsTrue(isFinished);
        }
예제 #3
0
        public async Task IsStillMovingOnAsync_ShouldReturnFalseIfMovementsIsEmpty()
        {
            //Arrange
            var testTile     = new Tile(0, 1);
            var tiles        = new Tile[3, 2];
            var mines        = new Mine[] { new Mine(1, 1) };
            var exitPoint    = new ExitPoint(0, 0);
            var mockedTurtle = new Mock <IDancer>();

            mockedTurtle.SetupGet(x => x.Tile).Returns(testTile);

            var movements = new Movement[] {};

            mockedMovementFactory.Setup(x => x.GetNextMovementsAsync()).Returns(Task.FromResult(movements));

            minefield = new Minefield(mockedMovementFactory.Object, tiles, mines, exitPoint, mockedTurtle.Object);

            //Act
            var isFinished = await minefield.IsStillMovingOnAsync();

            //Assert
            Assert.IsFalse(isFinished);
        }