Exemplo n.º 1
0
        public async Task Update_ReturnsBadRequestResult_WhenModelStateIsInvalid()
        {
            var mockService = new Mock <IPatientViewModelService>();

            mockService.Setup(service => service.Update(It.IsAny <PatientViewModel>()));
            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.Update(crudModel);

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

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

            crudModel.Value = GetPatientViewModel();

            var result = await controller.Update(crudModel);

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

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