public async Task calls_download_string_method_with_correct_address_parameter() { // Arrange const string response = "{}"; var webClientMock = new Mock <IWebClientAdapter>(); webClientMock.Setup(_ => _.DownloadStringTaskAsync( _measurementsUri + _installationId.ToString())) .ReturnsAsync(response); webClientMock.SetupProperty(_ => _.Headers, new WebHeaderCollection()); var airlyMeasurementsDownloader = new AirlyMeasurementsDownloader(_config, webClientMock.Object); // Act var measurements = await airlyMeasurementsDownloader .DownloadAirQualityData(_installationId); // Assert webClientMock.Verify( _ => _.DownloadStringTaskAsync( _measurementsUri + _installationId.ToString() + _measurementsUriParameters), Times.Once()); }
public async Task returns_empty_measurements_object_when_api_response_is_empty() { // Arrange const string response = ""; var webClientMock = new Mock <IWebClientAdapter>(); webClientMock.Setup(_ => _.DownloadStringTaskAsync(It.IsAny <string>())) .ReturnsAsync(response); webClientMock.SetupProperty(_ => _.Headers, new WebHeaderCollection()); var airlyMeasurementsDownloader = new AirlyMeasurementsDownloader(_config, webClientMock.Object); // Act var measurements = await airlyMeasurementsDownloader .DownloadAirQualityData(_installationId); // Assert Assert.NotNull(measurements); }