public void ScheduleMeetingController_GetMeetingStartDate(DateTime startdate) { schedulepro.Setup(s => s.GetRepScheduleAsync(startdate)).Returns(Task.FromResult(new List <RepSchedule>())); var pro = new RepScheduleController(schedulepro.Object); ObjectResult data = pro.Get(startdate).Result as ObjectResult; Assert.AreEqual(404, data.StatusCode); }
public void GetSchedule_OnValidInput_returnsRepresentativesSchedule(DateTime ScheduleStartDate) { //Arrange MockRepScheduleService.Setup(m => m.CreateRepSchedule(It.IsAny <DateTime>())).Returns(Task.FromResult(_repSchedule)); RepScheduleController rep = new RepScheduleController(MockRepScheduleService.Object); //Act var response = rep.GetSchedule(ScheduleStartDate).Result as ObjectResult; //Assert Assert.AreEqual(200, response.StatusCode); }
public void GetSchedule_NullRepositoryData_returnsNotFound(DateTime ScheduleStartDate) { //Arrange _repSchedule = null; MockRepScheduleService.Setup(m => m.CreateRepSchedule(It.IsAny <DateTime>())).Returns(Task.FromResult(_repSchedule)); RepScheduleController rep = new RepScheduleController(MockRepScheduleService.Object); //Act var response = rep.GetSchedule(ScheduleStartDate).Result as ObjectResult; //Assert Assert.AreEqual(404, response.StatusCode); }
public void GetByDateFailTestController() { var mock = new Mock <IRepScheduleRepository>(); mock.Setup(x => x.Get("token")).Returns(medicinestock); RepScheduleProvider prov = new RepScheduleProvider(mock.Object); DateTime date = new DateTime(2020, 05, 24); RepScheduleController repcon = new RepScheduleController(prov); var data = repcon.Get(date); var result = data as ObjectResult; Assert.AreEqual(400, result.StatusCode); }
public void TestControllerLayerCorrectInput(DateTime startdate) { schedulepro.Setup(m => m.GetRepScheduleAsync(It.IsAny <DateTime>())).Returns(Task.FromResult(new List <RepSchedule>() { new RepSchedule { RepName = "R1", DoctorName = "D1", DateOfMeeting = "12-12-2020", DoctorContactNumber = 9099687, Medicine = "Aspirin", MeetingSlot = "1-2pm", TreatingAilment = "General" } })); var pro = new RepScheduleController(schedulepro.Object); var res = pro.Get(startdate).Result as ObjectResult; Assert.AreEqual(res.StatusCode, 200); }
public void GetSchedule_OnInvalidInput_returnsBadRequest(DateTime ScheduleStartDate) { //Arrange Mock <IDoctorRepository> doctorRepository = new Mock <IDoctorRepository>(); Mock <IRepresentativeRepository> representativeRepository = new Mock <IRepresentativeRepository>(); Mock <IMedicineStockProvider> medicineProvider = new Mock <IMedicineStockProvider>(); IRepScheduleService repService = new RepScheduleService(doctorRepository.Object, representativeRepository.Object, medicineProvider.Object); RepScheduleController rep = new RepScheduleController(repService); //Act var response = rep.GetSchedule(ScheduleStartDate).Result as ObjectResult; //Assert Assert.AreEqual(400, response.StatusCode); }