public void GetAppointmentsByPatientId_Count_AppointmentsResponse_Test() { //Arrage IDbContext dbContext = new MedicalAppointmentContext(); IRepository repository = new AppointmentRepository(dbContext); var sut = new AppointmentsController(repository); var expectedResult = 1; //Act var result = sut.GetByPatientId(1) as OkNegotiatedContentResult <IEnumerable <IAppointment> >; var appointmentListResult = result.Content as List <Appointment>; //Assert Assert.AreEqual(expectedResult, appointmentListResult.Count); }
public void GetAppointmentByPatientId_NotNullResponse_Test() { //Arrage IDbContext dbContext = new MedicalAppointmentContext(); IRepository repository = new AppointmentRepository(dbContext); var sut = new AppointmentsController(repository); //Act var result = sut.GetByPatientId(1) as OkNegotiatedContentResult <IEnumerable <IAppointment> >; var appointmentListResult = result.Content as List <Appointment>; //Assert Assert.IsNotNull(result); Assert.IsNotNull(appointmentListResult); }
public void GetAppointmentsByPatientId_ValidDataResponse_Test() { //Arrage IDbContext dbContext = new MedicalAppointmentContext(); IRepository repository = new AppointmentRepository(dbContext); var sut = new AppointmentsController(repository); var expectedResult = new Appointment() { Id = 1, PatientId = 1, AppointmentTypeId = 1, Date = new DateTime(2019, 8, 10, 12, 30, 00), IsActive = true }; //Act var result = sut.GetByPatientId(1) as OkNegotiatedContentResult <IEnumerable <IAppointment> >; var appointmentListResult = result.Content as List <Appointment>; var appointmentResult = appointmentListResult.First(); //Assert Assert.AreEqual(expectedResult.Id, appointmentResult.Id); Assert.AreEqual(expectedResult.PatientId, appointmentResult.PatientId); Assert.AreEqual(expectedResult.AppointmentTypeId, appointmentResult.AppointmentTypeId); Assert.AreEqual(expectedResult.Date, appointmentResult.Date); Assert.AreEqual(expectedResult.IsActive, appointmentResult.IsActive); }