Exemplo n.º 1
0
        public void CreateExit_EmptyBoard_ThrowsNullException()
        {
            var mineServiceStub       = new Mock <IMineService>();
            var coordinateServiceStub = new Mock <ICoordinateService>();
            var boardService          = new BoardService(mineServiceStub.Object, coordinateServiceStub.Object);

            Assert.Throws <NullReferenceException>(() => boardService.CreateExit("0 0"));
        }
Exemplo n.º 2
0
        public void CreateExit_InvalidPosition_ThrowsException()
        {
            var mineServiceStub       = new Mock <IMineService>();
            var coordinateServiceStub = new Mock <ICoordinateService>();

            coordinateServiceStub.Setup(x => x.Create(2, 2))
            .Returns(new Coordinate {
                X = 2, Y = 2
            });
            var boardService = new BoardService(mineServiceStub.Object, coordinateServiceStub.Object);

            boardService.Create("1 1");
            Assert.Throws <Exception>(() => boardService.CreateExit("2 2"));
        }
Exemplo n.º 3
0
        public void CreateExit_StringCommand_ReturnsExitCoordinateY(string exitCoordinate, int exitCoordinateX, int exitCoordinateY, string boardDimension)
        {
            var mineServiceStub       = new Mock <IMineService>();
            var coordinateServiceStub = new Mock <ICoordinateService>();

            coordinateServiceStub.Setup(x => x.Create(exitCoordinateX, exitCoordinateY)).Returns(new Coordinate {
                X = exitCoordinateX, Y = exitCoordinateY
            });
            var boardService = new BoardService(mineServiceStub.Object, coordinateServiceStub.Object);

            boardService.Create(boardDimension);
            boardService.CreateExit(exitCoordinate);
            var result = boardService.GetBoard().ExitPoint.Y;

            Assert.Equal(exitCoordinateY, result);
        }
Exemplo n.º 4
0
        public void CreateExit_StringCommand_ReturnsExitCoordinate()
        {
            var mineServiceStub       = new Mock <IMineService>();
            var coordinateServiceStub = new Mock <ICoordinateService>();

            coordinateServiceStub.Setup(x => x.Create(0, 0)).Returns(new Coordinate {
                X = 0, Y = 0
            });
            var boardService = new BoardService(mineServiceStub.Object, coordinateServiceStub.Object);

            boardService.Create("1 1");
            boardService.CreateExit("0 0");
            var result = boardService.GetBoard().ExitPoint;

            Assert.NotNull(result);
        }