コード例 #1
0
        public void CreatePuzzle_ShouldReturnPuzzleResponseObject()
        {
            mockLogger     = new Mock <ILogger <SudokuController> >();
            logger         = mockLogger.Object;
            mockService    = new Mock <IPuzzleService>();
            service        = mockService.Object;
            mockRepository = new Mock <IPuzzleRepository>();
            repository     = mockRepository.Object;
            sut            = new SudokuController(logger, service, repository);
            var actualResult = sut.CreatePuzzle(0);

            Assert.IsInstanceOfType(actualResult, typeof(ActionResult <PuzzleResponse>));
        }
コード例 #2
0
        public void CreatePuzzle_ShouldReturnNotNullObject()
        {
            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);

            Assert.IsNotNull(actualResult);
        }
コード例 #3
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);
        }