public async Task ShouldCalculateAverageTemperatureFromListOfResults(IList <double> fakeData) { _fakeBomService.GetTemperatureDataAsync().Returns(fakeData); var actual = await _sut.CalculateAverageTempAsync(); var expected = fakeData.Average(); actual.Should().Be(expected); }
public async Task <double> CalculateAverageTempAsync() { try { var temperatureData = await _bomService.GetTemperatureDataAsync().ConfigureAwait(false); var temperatures = temperatureData.ToList(); if (!temperatures.Any()) { throw new ApplicationException("No temperature data found."); } return(temperatures.Average()); } catch (Exception) { throw; } }