public void Solution_ShouldReturnPuzzleResponseObject() { mockLogger = new Mock <ILogger <SudokuController> >(); logger = mockLogger.Object; mockService = new Mock <IPuzzleService>(); mockService.Setup(x => x.GetSolvedSudoku6x6(testData.GetValidPuzzle1())) .Returns(testData.GetValidPuzzle1Solution()); service = mockService.Object; mockRepository = new Mock <IPuzzleRepository>(); repository = mockRepository.Object; sut = new SudokuController(logger, service, repository); var actualResult = sut.Solution(new Puzzle(testData.GetValidPuzzle1())); Assert.IsInstanceOfType(actualResult, typeof(ActionResult <PuzzleResponse>)); }
public void Solution_ShouldReturnNoSolutionForInvalidPuzzle() { mockLogger = new Mock <ILogger <SudokuController> >(); logger = mockLogger.Object; var puzzle = testData.GetInvalidPuzzle(); mockService = new Mock <IPuzzleService>(); mockService.Setup(x => x.GetSolvedSudoku6x6(puzzle)) .Returns((int[][])null); service = mockService.Object; mockRepository = new Mock <IPuzzleRepository>(); repository = mockRepository.Object; sut = new SudokuController(logger, service, repository); var actualResult = sut.Solution(new Puzzle(puzzle)); var expectedResult = new PuzzleResponse(Constants.Code.OK, Constants.Message.SolutionNotFound, null); Assert.AreEqual(expectedResult.Equals(actualResult.Value), true); }