public async Task TestGetMeasureTempCo2Humidity() { var measures = new List <Measure>() { MeasureType.Temperature, MeasureType.CO2, MeasureType.Humidity }; using var netatmoClient = new NetatmoWebClient(new MockHttpMessageHandler() .AddAuthMock() .AddMeasurements(_moduleId, measures, 30) .ToMockProvider()); var result = await netatmoClient.GetMeasure(_moduleId, _moduleId, measures); Assert.Equal(3, result.Count()); Assert.Equal(30, result.First().Value.Count()); Assert.Equal(30, result.Skip(1).First().Value.Count()); Assert.Equal(30, result.Skip(2).First().Value.Count()); Assert.Equal(21.3, result.First().Value.First().Value); Assert.Equal(524, result.Skip(1).First().Value.First().Value); Assert.Equal(58, result.Skip(2).First().Value.First().Value); Assert.Equal(21.3, result.First().Value.Skip(20).First().Value); Assert.Equal(524, result.Skip(1).First().Value.Skip(20).First().Value); Assert.Equal(58, result.Skip(2).First().Value.Skip(20).First().Value); }
private async Task <Dictionary <Tuple <ModuleId, ModuleId, Measure>, List <TimeSeries <double> > > > LoadMidresSensorValues(DateTime start, DateTime end) { var days = new TimeSeriesSpan(start.ToUniversalTime(), end.ToUniversalTime(), 1).IncludedDates().ToList(); var loadedValues = new Dictionary <Tuple <ModuleId, ModuleId, Measure>, List <TimeSeries <double> > >(); foreach (var module in _netatmoStructure.Modules) { var measureTypes = _netatmoStructure.GetModuleMeasures(module.Item2); var measures = await _netatmoClient.GetMeasure(module.Item1, module.Item2, measureTypes, MeasureScale.ScaleMax, start, end, null, true); var series = measureTypes.ToDictionary(m => m, m => Enumerable.Range(0, days.Count).Select(k => new TimeSeries <double>(new TimeSeriesSpan(days[k], days[k].AddDays(1), TimeSeriesSpan.Spacing.Spacing5Min))).ToList()); foreach (var measure in measures) { foreach (var originSeries in measure.Value) { for (int k = 0; k < series[measure.Key].Count; k++) { MapToEquidistantTimeSeries(series[measure.Key][k], originSeries); } } } foreach (var serie in series) { loadedValues.Add(new Tuple <ModuleId, ModuleId, Measure>(module.Item1, module.Item2, serie.Key), serie.Value); } } return(loadedValues); }
public async Task TestGetMeasureRain() { var measures = new List <Measure>() { MeasureType.Rain }; using var netatmoClient = new NetatmoWebClient(new MockHttpMessageHandler() .AddAuthMock() .AddMeasurements(_moduleId, measures, 5) .ToMockProvider()); var result = await netatmoClient.GetMeasure(_moduleId, _moduleId, measures); Assert.Single(result); Assert.Equal(5, result.First().Value.Count()); Assert.Equal(0, result.First().Value.First().Value); }