public void ConvertBuidingDataResponse_Into_BuildingMeterData() { MeterType meterType = MeterType.Electricity; int buildingID = 2; long data = 5; long time = 1442102340000; DateTime dateTime = new DateTime(2015, 9, 12); BuildingDataResponse response = new BuildingDataResponse(meterType, buildingID); response.HistoricalData.Add(new HistoricalData() { data = data, time = time }); BuildingMeterData meterData = service.ConvertBuildingDataResponse(response); Assert.AreEqual(buildingID, meterData.BuildingID); Assert.AreEqual(meterType, meterData.MeterType); Assert.AreEqual(1, meterData.DateValues.Count()); Assert.IsTrue(meterData.DateValues.ContainsKey(dateTime)); Assert.AreEqual(data, meterData.DateValues[dateTime]); }
public BuildingMeterData ConvertBuildingDataResponse(BuildingDataResponse response) { BuildingMeterData meterData = new BuildingMeterData(); meterData.BuildingID = response.BuildingID; meterData.MeterType = response.MeterType; foreach(HistoricalData data in response.HistoricalData) { DateTime dateValue = ConvertUnixEpochTimeToDateTime(data.time).ToUniversalTime().Date; meterData.DateValues.Add(dateValue, data.data); } return meterData; }