// This method is used to setup the data. public void Setup() { patientDetail = new PatientDetail() { ForeName = "Vishwa", SurName = "Reddy", Gender = "Male" }; List <PatientDetail> lstPatient = new List <PatientDetail>(); lstPatient.Add(new PatientDetail() { ForeName = "Vishwa", SurName = "Reddy", DateofBirth = DateTime.Now.AddDays(-20), Gender = "Male" }); lstPatient.Add(new PatientDetail() { ForeName = "Aadit", SurName = "Reddy", DateofBirth = DateTime.Now.AddDays(-20), Gender = "Male" }); PatientPagingModel patientPagingModel = new PatientPagingModel() { TotalRecords = 5, PatientDetails = lstPatient }; ////Used MOQ framework to return predefined data var PatientDemographicRepository = new Mock <IPatientDemographicsRepository>(); PatientDemographicRepository.Setup(x => x.GetAllPatientDemographics(1, 4)).Returns(patientPagingModel); PatientDemographicRepository.Setup(x => x.PostPatientDetails(patientDetail)).Returns(true); _PatientDemographicsRepository = PatientDemographicRepository.Object; }
//Repository object is inected using Unity Container public PatientsController(IPatientDemographicsRepository patientDemographicsRepository) { _patientDemographicsRepository = patientDemographicsRepository; }