コード例 #1
0
        public void Delete_Valid_Detail()
        {
            DoctorRep         loandata = new DoctorRep(db);
            DoctorsController obj      = new DoctorsController(loandata);
            var data     = obj.Delete(1);
            var okResult = data as OkObjectResult;

            Assert.AreEqual(200, okResult.StatusCode);
        }
コード例 #2
0
        public void Delete(int?id)
        {
            // Arrange
            DoctorsController controller = new DoctorsController();

            // Act
            ViewResult result = controller.Delete(id) as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }
コード例 #3
0
        public void ShouldCheckResultAfterDeleteFromDoctorsController_WithMock()
        {
            var doctor  = new Doctor();
            var service = new Mock <IDoctorRepository>();

            service.Setup(x => x.GetDoctorById(1)).Returns(doctor);
            _doctorsController = new DoctorsController(service.Object);

            var expected = doctor;
            var result   = _doctorsController.Delete(1);
            var actual   = ((ViewResult)result).Model as Doctor;

            Assert.AreEqual(actual, expected);
        }
コード例 #4
0
        public void ShouldCheckResultWhenDoctorIdIsWrongAfterDeleteFromDoctorsController_WithMock()
        {
            var doctor  = new Doctor();
            var service = new Mock <IDoctorRepository>();

            service.Setup(x => x.GetDoctorById(1)).Returns(doctor);
            _doctorsController = new DoctorsController(service.Object);

            var expectedErrorCode = 404;
            var result            = _doctorsController.Delete(1000000);
            var viewResult        = (HttpNotFoundResult)result;
            var actual            = viewResult.StatusCode;

            Assert.AreEqual(expectedErrorCode, actual);
        }