예제 #1
0
        public void GetStudentByID_Returns404NotFound_WhenNonExistentIDProvided()
        {
            //Arrange
            mockRepo.Setup(repo =>
                           repo.GetStudentById(0)).Returns(() => null);

            var controller = new LabController(mockRepo.Object, mapper);

            //Act
            var result = controller.GetStudentById(1);

            //Assert
            Assert.IsType <NotFoundResult>(result.Result);
        }
예제 #2
0
        public void GetStudentByID_ReturnsCorreectType_WhenValidIDProvided()
        {
            //Arrange
            mockRepo.Setup(repo =>
                           repo.GetStudentById(1)).Returns(new Student
            {
                Index       = 121111,
                Grade       = 5,
                Score       = 100,
                Name        = "Jas",
                Surrname    = "Abacki",
                Description = "Great!"
            });

            var controller = new LabController(mockRepo.Object, mapper);

            //Act
            var result = controller.GetStudentById(1);

            //Assert
            Assert.IsType <ActionResult <StudentReadDto> >(result);
        }