示例#1
0
        public void CreatePuzzle_ShouldReturnPuzzleForId0()
        {
            mockLogger     = new Mock <ILogger <SudokuController> >();
            logger         = mockLogger.Object;
            mockService    = new Mock <IPuzzleService>();
            service        = mockService.Object;
            mockRepository = new Mock <IPuzzleRepository>();
            mockRepository.Setup(x => x.GetPuzzleById(0))
            .Returns(new Puzzle(testData.GetValidPuzzle0()
                                ));
            repository = mockRepository.Object;
            sut        = new SudokuController(logger, service, repository);
            var actualResult   = sut.CreatePuzzle(0);
            var expectedResult = new PuzzleResponse(Constants.Code.OK, Constants.Message.Success, testData.GetValidPuzzle0());

            Assert.AreEqual(expectedResult.Equals(actualResult.Value), true);
        }
示例#2
0
        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);
        }