Exemplo n.º 1
0
        public void DeleteTest()
        {
            Patient v = new Patient();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.ID       = 92;
                v.IdNumber = "9hTGN";
                v.PhotoId  = AddPhoto();
                context.Set <Patient>().Add(v);
                context.SaveChanges();
            }

            PartialViewResult rv = (PartialViewResult)_controller.Delete(v.ID.ToString());

            Assert.IsInstanceOfType(rv.Model, typeof(PatientVM));

            PatientVM vm = rv.Model as PatientVM;

            v         = new Patient();
            v.ID      = vm.Entity.ID;
            vm.Entity = v;
            _controller.Delete(v.ID.ToString(), null);

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                Assert.AreEqual(context.Set <Patient>().Count(), 1);
            }
        }
Exemplo n.º 2
0
        public void POST_Delete_Closed()
        {
            //Arrange
            _patientService.Setup(x => x.IsClosed(It.IsAny <int>())).Returns(true);

            //Act
            var result = (HttpStatusCodeResult)_controller.Delete(1);

            //Assert
            Assert.That(result.StatusCode, Is.EqualTo((int)HttpStatusCode.BadRequest));
        }
Exemplo n.º 3
0
        public async Task Delete_ReturnsOkResult_IfDeleteSuccess()
        {
            //Arrange
            Patient patientRemove = new Patient {
                Id = 1, FirstName = "San", LastName = "Bui"
            };

            unitOfWorkMock.Setup(x => x.Patient.DeleteAsync(patientRemove.Id)).ReturnsAsync(patientRemove);
            //Act
            var result = await controller.Delete(patientRemove.Id);

            //Assert
            var actionResult = Assert.IsType <ActionResult <Patient> >(result);
            var returnValue  = Assert.IsType <Patient>(actionResult.Value);

            Assert.Equal("San", returnValue.FirstName);
        }
Exemplo n.º 4
0
        public void DeleteTest()
        {
            var response = _controller.Delete("1", 1);

            Assert.IsNotNull(response);
            Assert.IsInstanceOfType(response, typeof(ViewResult));
            _repository.Verify(mock => mock.FindPatient(It.IsAny <string>(), It.IsAny <int>()), Times.Once());
        }
Exemplo n.º 5
0
        public void Delete_Test()
        {
            // Arrange
            var mockService = new Mock <IPatientService>();
            var controller  = new PatientController(mockService.Object);
            int id          = 10;
            int userId      = 1;

            // Act
            IHttpActionResult actionResult = controller.Delete(id, userId);

            // Assert
            Assert.IsInstanceOfType(actionResult, typeof(OkResult));
        }
        public void Delete_Method_Removes_A_Patient()
        {
            var patientId = 99;
            var patients  = CreateTestPatients(5);

            patients[0].Id = patientId;

            var repo       = new InMemoryPatientRepository(patients);
            var cache      = new MemoryCache(new MemoryCacheOptions());
            var controller = new PatientController(repo, cache);

            controller.Delete(patientId);

            var patientFromDb = repo.InternalData.FirstOrDefault(p => p.Id == patientId);

            Assert.Null(patientFromDb);
        }
Exemplo n.º 7
0
        public async Task Delete_ReturnsBadRequestResult_WhenModelStateIsInvalid()
        {
            var mockService = new Mock <IPatientViewModelService>();

            mockService.Setup(service => service.Delete(It.IsAny <int>()));
            var controller = new PatientController(mockService.Object);

            controller.ModelState.AddModelError("Name", "Error Massage");
            var patientViewModel = GetPatientViewModel();
            var crudModel        = new Syncfusion.EJ2.Base.CRUDModel <PatientViewModel>();

            crudModel.Value = patientViewModel;

            var result = await controller.Delete(crudModel);

            Assert.IsType <BadRequestObjectResult>(result);
        }
Exemplo n.º 8
0
        public async Task Delete_DeletePatientAndReturnsIndex_WhenModelStateIsValid()
        {
            var mockService = new Mock <IPatientViewModelService>();

            mockService.Setup(service => service.Delete(It.IsAny <int>()))
            .Returns(Task.CompletedTask)
            .Verifiable();
            var controller = new PatientController(mockService.Object);
            var crudModel  = new Syncfusion.EJ2.Base.CRUDModel <PatientViewModel>();

            crudModel.Value = GetPatientViewModel();
            crudModel.Key   = (Int64)crudModel.Value.Id;

            var result = await controller.Delete(crudModel);

            var viewResult = Assert.IsType <ViewResult>(result);

            Assert.Equal("Index", viewResult.ViewName);
        }