public async Task MeasurementService_GetSensorDataAsync_Tests() { //Valid Tests repoMock.Setup(t => t.GetContentAsync(It.IsAny <string>())).ReturnsAsync("2018-11-29T07:54:55,,03"); var result = await service.GetSensorDataAsync("deviceId", DateTime.Now, Sensors.Humidity); Assert.IsType <SensorData>(result); Assert.Equal(result.Sensor, Sensors.Humidity.ToString()); //Invalid Tests repoMock.Setup(t => t.GetContentAsync(It.IsAny <string>())).ThrowsAsync(new Exception()); result = await service.GetSensorDataAsync("deviceId", DateTime.Now, Sensors.Humidity); Assert.Null(result); }