private void ValidateDataList(TimeSeriesDataListInt dataList) { Assert.IsNotNull(dataList); Assert.IsNotNull(dataList.DataList); Assert.AreEqual(7, dataList.DataList.Count); var item = dataList.DataList.First(); dataList.DataList.Remove(item); Assert.AreEqual(7428, item.Value); Assert.AreEqual(DateTime.Parse("2014-09-04"), item.DateTime); item = dataList.DataList.First(); dataList.DataList.Remove(item); Assert.AreEqual(9846, item.Value); Assert.AreEqual(DateTime.Parse("2014-09-05"), item.DateTime); item = dataList.DataList.First(); dataList.DataList.Remove(item); Assert.AreEqual(4274, item.Value); Assert.AreEqual(DateTime.Parse("2014-09-06"), item.DateTime); item = dataList.DataList.First(); dataList.DataList.Remove(item); Assert.AreEqual(7595, item.Value); Assert.AreEqual(DateTime.Parse("2014-09-07"), item.DateTime); item = dataList.DataList.First(); dataList.DataList.Remove(item); Assert.AreEqual(0, item.Value); Assert.AreEqual(DateTime.Parse("2014-09-08"), item.DateTime); item = dataList.DataList.First(); dataList.DataList.Remove(item); Assert.AreEqual(9499, item.Value); Assert.AreEqual(DateTime.Parse("2014-09-09"), item.DateTime); item = dataList.DataList.First(); dataList.DataList.Remove(item); Assert.AreEqual(7026, item.Value); Assert.AreEqual(DateTime.Parse("2014-09-10"), item.DateTime); Assert.AreEqual(0, dataList.DataList.Count); }
/// <summary> /// GetTimeSeriesDataList has to do some custom manipulation with the returned representation /// </summary> /// <param name="serializer"></param> /// <param name="timeSeriesDataJson"></param> /// <returns></returns> internal static TimeSeriesDataListInt GetTimeSeriesDataListInt(this JsonDotNetSerializer serializer, string timeSeriesDataJson) { if (string.IsNullOrWhiteSpace(timeSeriesDataJson)) { throw new ArgumentNullException("timeSeriesDataJson", "timeSeriesDataJson can not be empty, null or whitespace."); } var dataPoints = JToken.Parse(timeSeriesDataJson)[serializer.RootProperty]; var result = new TimeSeriesDataListInt { DataList = (from item in dataPoints select new TimeSeriesDataListInt.Data { DateTime = DateTime.Parse(item["dateTime"].ToString()), Value = int.Parse(item["value"].ToString()) }).ToList() }; return result; }