public void CreateMines_StringCommandInput_ReturnsMineCount(string boardInput, string stringMineInput, int[] mineInput1, int[] mineInput2, int[] mineInput3, int expectedResult) { var mineServiceStub = new Mock <IMineService>(); mineServiceStub.Setup(x => x.CreateMine(mineInput1)) .Returns(new Mine { Position = new Coordinate { X = mineInput1[0], Y = mineInput1[1] } }); mineServiceStub.Setup(x => x.CreateMine(mineInput2)) .Returns(new Mine { Position = new Coordinate { X = mineInput2[0], Y = mineInput2[1] } }); mineServiceStub.Setup(x => x.CreateMine(mineInput3)) .Returns(new Mine { Position = new Coordinate { X = mineInput3[0], Y = mineInput3[1] } }); var coordinateServiceStub = new Mock <ICoordinateService>(); var boardService = new BoardService(mineServiceStub.Object, coordinateServiceStub.Object); boardService.Create(boardInput); boardService.CreateMines(stringMineInput); var result = boardService.GetBoard().Mines.Count; Assert.Equal(expectedResult, result); }
public void CreateMines_EmptyBoard_ThrowsNullException() { var mineServiceStub = new Mock <IMineService>(); var coordinateServiceStub = new Mock <ICoordinateService>(); var boardService = new BoardService(mineServiceStub.Object, coordinateServiceStub.Object); Assert.Throws <NullReferenceException>(() => boardService.CreateMines("0,0 0,0")); }
public void CreateMines_InvalidPosition_ThrowsNullException() { var mineServiceStub = new Mock <IMineService>(); var coordinateServiceStub = new Mock <ICoordinateService>(); var boardService = new BoardService(mineServiceStub.Object, coordinateServiceStub.Object); boardService.Create("1 1"); Assert.Throws <Exception>(() => boardService.CreateMines("2,2")); }
public void CreateExit_MineExistsInLocation_ThrowsNullException() { 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"); boardService.CreateMines("1,1"); Assert.Throws <Exception>(() => boardService.CreateExit("2 2")); }