public async void LoadLatestDeviceTelemetrySummaryAsyncTest()
        {
            var year = 2016;
            var month = 7;
            var date = 5;
            var minTime = new DateTime(year, month, date);

            var blobReader = new Mock<IBlobStorageReader>();
            var blobData = "deviceid,averagehumidity,minimumhumidity,maxhumidity,timeframeminutes" + Environment.NewLine +
                           "test2,37.806204872115607,37.806204872115607,37.806204872115607,5";
            var stream = new MemoryStream(Encoding.UTF8.GetBytes(blobData));
            var blobContents = new BlobContents {Data = stream, LastModifiedTime = DateTime.UtcNow};
            var blobContentIterable = new List<BlobContents>();
            blobContentIterable.Add(blobContents);

            blobReader.Setup(x => x.GetEnumerator()).Returns(blobContentIterable.GetEnumerator());
            _blobStorageClientMock.Setup(x => x.GetReader(It.IsNotNull<string>(), It.IsAny<DateTime?>()))
                .ReturnsAsync(blobReader.Object);
            var telemetrySummaryList =
                await deviceTelemetryRepository.LoadLatestDeviceTelemetrySummaryAsync("test2", minTime);
            Assert.NotNull(telemetrySummaryList);
            Assert.Equal(telemetrySummaryList.DeviceId, "test2");
            Assert.Equal(telemetrySummaryList.AverageHumidity, 37.806204872115607);
            Assert.Equal(telemetrySummaryList.MinimumHumidity, 37.806204872115607);
            Assert.Equal(telemetrySummaryList.MaximumHumidity, 37.806204872115607);
            Assert.Equal(telemetrySummaryList.TimeFrameMinutes, 5);
        }
        public async void LoadLatestAlertHistoryAsyncTest()
        {
            var year = 2016;
            var month = 7;
            var date = 5;
            var value = "10.0";
            var minTime = new DateTime(year, month, date);

            await Assert.ThrowsAsync<ArgumentOutOfRangeException>(async () => await alertsRepository.LoadLatestAlertHistoryAsync(minTime, 0));

            var blobReader = new Mock<IBlobStorageReader>();
             var blobData = $"deviceid,reading,ruleoutput,time,{Environment.NewLine}Device123,{value},RuleOutput123,{minTime.ToString("o")}";
            var stream = new MemoryStream(Encoding.UTF8.GetBytes(blobData));
            var blobContents = new BlobContents {Data = stream, LastModifiedTime = DateTime.UtcNow};
            var blobContentIterable = new List<BlobContents>();
            blobContentIterable.Add(blobContents);

            blobReader.Setup(x => x.GetEnumerator()).Returns(blobContentIterable.GetEnumerator());

            _blobStorageClientMock
                .Setup(x => x.GetReader(It.IsNotNull<string>(), It.IsAny<DateTime?>()))
                .ReturnsAsync(blobReader.Object);

            var alertsList = await alertsRepository.LoadLatestAlertHistoryAsync(minTime, 5);
            Assert.NotNull(alertsList);
            Assert.NotEmpty(alertsList);
            Assert.Equal(alertsList.First().Value, value);
            Assert.Equal(alertsList.First().Timestamp, minTime);
        }
        public async void LoadLatestDeviceTelemetryAsyncTest()
        {
            var year = 2016;
            var month = 7;
            var date = 5;
            var minTime = new DateTime(year, month, date);

            var blobReader = new Mock<IBlobStorageReader>();
            var blobData = "deviceid,temperature,humidity,externaltemperature,eventprocessedutctime,partitionid,eventenqueuedutctime,IoTHub" +
                Environment.NewLine +
                "test1,34.200411299709423,32.2233033525866,,2016-08-04T23:07:14.2549606Z,3," + minTime.ToString("o") + ",Record";
            var stream = new MemoryStream(Encoding.UTF8.GetBytes(blobData));
            var blobContents = new BlobContents {Data = stream, LastModifiedTime = DateTime.UtcNow};
            var blobContentIterable = new List<BlobContents>();
            blobContentIterable.Add(blobContents);

            blobReader.Setup(x => x.GetEnumerator()).Returns(blobContentIterable.GetEnumerator());
            _blobStorageClientMock.Setup(x => x.GetReader(It.IsNotNull<string>(), It.IsAny<DateTime?>()))
                .ReturnsAsync(blobReader.Object);
            var telemetryList = await deviceTelemetryRepository.LoadLatestDeviceTelemetryAsync("test1", null, minTime);
            Assert.NotNull(telemetryList);
            Assert.NotEmpty(telemetryList);
            Assert.Equal(telemetryList.First().DeviceId, "test1");
            Assert.Equal(telemetryList.First().Timestamp, minTime);
        }