public void Get_WhenCalled_ReturnsPatients() { // Act List <PatientViewModel> patients = patientController.Get(); // Assert Assert.IsType <List <PatientViewModel> >(patients); }
public async Task Get_ShouldReturnBadRequest_WhenModelStateIsInvalid() { //Arrange _patientController.ModelState.AddModelError("Error", "Modal State is invalid"); //Act var result = await _patientController.Get(0, 100); //Assert Assert.IsType <BadRequestObjectResult>(result); }
public void TestFetchSinglePatient() { var Response = _patientcontroller.Get(int.MinValue); Assert.IsNotNull(Response); Assert.IsTrue(Response.Patient_ID == 1); }
public async Task TestGetAll() { // Arrange var mockService = new Mock <IPatientService>(); mockService .Setup(x => x.GetInputModelsAll()) .ReturnsAsync(new List <PatientInputModel> { new PatientInputModel { Id = 1 } }) .Verifiable(); var controller = new PatientController(mockService.Object); // Act var result = await controller.Get(); // Assert var actionResult = Assert.IsAssignableFrom <OkObjectResult>(result.Result); var objectResult = Assert.IsAssignableFrom <IEnumerable <PatientInputModel> >(actionResult.Value); mockService .Verify(x => x.GetInputModelsAll(), Times.Once()); }
public void GetAllPatient() { var controller = new PatientController(); List <PatientInfo> patientList = controller.Get(); Assert.IsTrue(patientList.Count > 0); }
public void PatientControllerTestGetPatientGUID() { try { var result = controller.Post(GetDummyPatient()); // Assert var okObjectResult1 = result as OkObjectResult; //Assert.IsNotNull(okObjectResult); var model1 = okObjectResult1.Value as PatientModel; //Assert.IsNotNull(model); var setGUID = model1.PatientGUIID; var tempPatient = controller.Get(setGUID); // Assert var okObjectResult2 = tempPatient as OkObjectResult; //Assert.IsNotNull(okObjectResult); var model2 = okObjectResult2.Value as PatientModel; //Assert.IsNotNull(model); var receivedGUID = model2.PatientGUIID; Assert.AreEqual(setGUID, receivedGUID); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public async Task TestGetIdValid() { // Arrange var mockService = new Mock <IPatientService>(); mockService .Setup(x => x.GetInputModelById(5)) .ReturnsAsync(new PatientInputModel { Id = 5 }); var controller = new PatientController(mockService.Object); // Act var result = await controller.Get(5); // Assert var actionResult = Assert.IsAssignableFrom <OkObjectResult>(result.Result); var objectResult = Assert.IsAssignableFrom <PatientInputModel>(actionResult.Value); mockService .Verify(x => x.GetInputModelById(5), Times.Once); }
public void GetPatientInformation(long id, bool success) { dynamic res = controller.Get(id); Console.WriteLine(res.Content.success); Assert.AreEqual(res.Content.success, success); }
public async Task TestGetIdInvalid() { // Arrange var controller = new PatientController(null); // Act var result = await controller.Get(0); // Assert Assert.IsAssignableFrom <BadRequestResult>(result.Result); }
public void GetPatientsDetails_AllPatients() { //Arrange the resources var controlller = new PatientController(_patientService); //Act on functionality var patientsList = controlller.Get().Result; var okResult = patientsList as OkObjectResult; var actualPatientList = (List <PatientModel>)okResult.Value; //Assert The result against expected Assert.IsTrue(actualPatientList[0].Name != string.Empty); }
public void Check_Get_Patient_By_Id() { ConfigDB.Instance.AddTestData(); using (Context context = new Context(ConfigDB.Instance.DbContextOptions)) { IPatientRepository patientRepository = new PatientRepository(context); IPatientService patientService = new PatientService(patientRepository); var controller = new PatientController(patientService, AutoMapperConfig.Instance.Mapper); var result = controller.Get(2); var response = Assert.IsType <CommonResponse <PatientViewModel> >(result); var model = Assert.IsAssignableFrom <CommonResponse <PatientViewModel> >(result); Assert.Equal(2, model.Result.OfficialId); } }
public void PatientNotFound() { var appointment = new Patient() { Id = 2 }; mockService.Setup(x => x.GetPatient(2)).Returns(appointment); var controller = new PatientController(mockService.Object); var response = controller.Get(1); Assert.IsFalse(response.Success); }
public void GetPatientById() { var appointment = new Patient() { Id = 1 }; mockService.Setup(x => x.GetPatient(1)).Returns(appointment); var controller = new PatientController(mockService.Object); var response = controller.Get(1); Assert.AreEqual(1, response.Patient.Id); }
public void RegisterPatient() { var controller = new PatientController(_patientService); var patientsList = controller.Get().Result; var okResult = patientsList as OkObjectResult; var actualPatientList = (List <PatientModel>)okResult.Value; var result = controller.Post(actualPatientList[0]).Result; var resultFromPOST = (bool)((OkObjectResult)result).Value; Assert.IsTrue(resultFromPOST); }
public async Task TestGetIdBad() { // Arrange var mockService = new Mock <IPatientService>(); mockService .Setup(x => x.GetInputModelById(666)) .ReturnsAsync((PatientInputModel)null); var controller = new PatientController(mockService.Object); // Act var result = await controller.Get(666); // Assert Assert.IsAssignableFrom <NotFoundResult>(result.Result); }
public void should_Get() { // Arrange Assert.That(_testPatients, Is.Not.Empty); List <int> ids = _testPatients.Select(x => x.Id).ToList(); var controller = new PatientController(_patientService); // Act var patients = controller.Get().Where(x => ids.Contains(x.Id)); // Assert Assert.That(patients, Is.Not.Empty); foreach (var patient in patients) { Debug.Print(patient.ToString()); } }
public async Task TestGetAllNoEntities() { // Arrange var mockService = new Mock <IPatientService>(); mockService .Setup(x => x.GetInputModelsAll()) .ReturnsAsync(new List <PatientInputModel>()) .Verifiable(); var controller = new PatientController(mockService.Object); // Act var result = await controller.Get(); // Assert Assert.IsAssignableFrom <NotFoundObjectResult>(result.Result); mockService .Verify(x => x.GetInputModelsAll(), Times.Once()); }
public async Task TestGetNoResults() { // Arrange var models = new List <PatientDTO>(); var mockService = new Mock <IPatientService>(); mockService .Setup(x => x.GetAllAsync()) .ReturnsAsync(models); var controller = new PatientController(mockService.Object); // Act var result = await controller.Get(); // Assert var actionResult = Assert.IsAssignableFrom <OkObjectResult>(result.Result); var modelResult = Assert.IsAssignableFrom <IEnumerable <PatientDTO> >(actionResult.Value); Assert.Empty(modelResult); }
public void GetPatient() { var patients = new List <Patient>(); patients.Add(new Patient() { Id = 1 }); patients.Add(new Patient() { Id = 2 }); patients.Add(new Patient() { Id = 3 }); mockService.Setup(x => x.GetPatients()).Returns(patients); var controller = new PatientController(mockService.Object); var response = controller.Get(); CollectionAssert.AreEquivalent(patients, response.Patients); }
public void Fetch_Employees_List() { var employees = _controller.Get(); Assert.True(employees.Any()); }