public void CreateAppointmentWithInvalidRequestTest() { // Arrange IAppointmentRepository repository = new AppointmentRepository(); IAppointmentService service = new AppointmentService(repository); // Arrange CreateAppointmentRequest request = new CreateAppointmentRequest(); // Act AppointmentResponse result = service.CreateAppointment(request); // Assert Assert.IsNull(result.Appointment); Assert.IsFalse(result.Success); }
public AppointmentResponse CreateAppointment(CreateAppointmentRequest appointmentRequest) { // Create a response object AppointmentResponse response = new AppointmentResponse(); try { response.Appointment = repository.Create(appointmentRequest.Appointment); response.Success = true; } catch (Exception ex) { response.Success = false; response.Message = ex.Message; } // Return the response object return response; }
public void CreateAppointmentTest() { // Arrange IAppointmentRepository repository = new AppointmentRepository(); IAppointmentService service = new AppointmentService(repository); // Arrange Appointment appointment = new Appointment() { Patient = new Patient { FirstName = "Test", LastName = "Test" } }; // Arrange CreateAppointmentRequest request = new CreateAppointmentRequest() { Appointment = appointment }; // Act AppointmentResponse result = service.CreateAppointment(request); // Assert Assert.AreEqual(appointment.ID, result.Appointment.ID); Assert.AreEqual(appointment.Patient, result.Appointment.Patient); Assert.IsTrue(result.Success); }