コード例 #1
0
        public async Task ShouldCalculateAverageTemperatureFromListOfResults(IList <double> fakeData)
        {
            _fakeBomService.GetTemperatureDataAsync().Returns(fakeData);

            var actual = await _sut.CalculateAverageTempAsync();

            var expected = fakeData.Average();

            actual.Should().Be(expected);
        }
コード例 #2
0
ファイル: Weather.cs プロジェクト: engo63/WeatherClient
        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;
            }
        }