Last active
July 18, 2023 15:08
-
-
Save shubhamsgit/9156c961c13d7623bd1d89c1f2281460 to your computer and use it in GitHub Desktop.
Sample Test for Appointment Repository
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test | |
| fun createTimeSlotWithQuery_success_returnsTimeSlot() { | |
| val startDate = "2023-07-15T10:00:00Z" | |
| val endDate = "2023-07-15T11:00:00Z" | |
| val appointmentBlockGet = appointmentBlockGet | |
| enqueueMockResponse("mocked_responses/AppointmentRepository/TimeSlotCreate-success.json") | |
| val result: TimeSlot = appointmentRepository.createTimeSlot(startDate, endDate, appointmentBlockGet).toBlocking().first() | |
| assertEquals(result.endDate, endDate) | |
| } | |
| fun enqueueMockResponse(fileName: String) { | |
| avaClass.classLoader?.let { | |
| val inputStream = it.getResourceAsStream(fileName) | |
| val source = inputStream.source().buffer() | |
| val mockResponse = MockResponse() | |
| mockResponse.setBody(source.readString(Charsets.UTF_8)) | |
| mockResponse.setResponseCode(200) | |
| mockWebServer.enqueue(mockResponse) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment