public async Task Handle_Fetch_Should_GetPatients_Return_Empty() { // Arrange var query = new GetPatient.Query(Guid.NewGuid()); var mockAppDbRepository = new Mock <IAppDbRepository>(); mockAppDbRepository .Setup(x => x.GetPatientByIdAsync(It.IsAny <Guid>())) .ReturnsAsync((Patient)null); var handler = new GetPatient.Handler(mockAppDbRepository.Object); // Act // Assert await Assert.ThrowsAsync <NotFoundException>(() => handler.Handle(query, new CancellationToken())); }
public async Task Handle_Fetch_Should_GetPatient_Return_Hospital() { // Arrange var patientId = Guid.NewGuid(); var query = new GetPatient.Query(patientId); var patient = new Patient { PatientId = patientId, Address = new Address() }; var mockAppDbRepository = new Mock <IAppDbRepository>(); mockAppDbRepository .Setup(x => x.GetPatientByIdAsync(It.IsAny <Guid>())) .ReturnsAsync(patient); var handler = new GetPatient.Handler(mockAppDbRepository.Object); // Act var result = await handler.Handle(query, new CancellationToken()); // Assert Assert.Equal(patientId, result.Id); }