コード例 #1
0
        public void DeleteStudent_Returns404NotFound_WhenNonExistentResourceIDSubmitted()
        {
            //Arrange
            mockRepo.Setup(repo =>
                           repo.GetStudentById(0)).Returns(() => null);
            var controller = new LabController(mockRepo.Object, mapper);
            //Act
            var result = controller.DeleteStudent(0);

            //Assert
            Assert.IsType <NotFoundResult>(result);
        }
コード例 #2
0
        public void DeleteStudent_Returns204NoContent_WhenValidResourceIDSubmitted()
        {
            //Arrange
            mockRepo.Setup(repo =>
                           repo.GetStudentById(1)).Returns(new Student
            {
                Id          = 1,
                Index       = 121111,
                Grade       = 5,
                Score       = 100,
                Name        = "Jas",
                Surrname    = "Abacki",
                Description = "Great!"
            });
            var controller = new LabController(mockRepo.Object, mapper);
            //Act
            var result = controller.DeleteStudent(1);

            //Assert
            Assert.IsType <NoContentResult>(result);
        }