Beispiel #1
0
        private async Task <List <ISensorData> > Read(string deviceName, DateTime date, IParser parser)
        {
            var filePath = _filePathBuilder.BuildFilePath(deviceName, parser.Type, date);
            var blob     = _blobClientProvider.GetBlobClient(filePath);

            if (await blob.ExistsAsync())
            {
                using (var stream = await blob.OpenReadAsync())
                {
                    return(parser.ParseStream(stream));
                }
            }
            else
            {
                var historicalFilePath = _filePathBuilder.BuildHistoricalFilePath(deviceName, parser.Type);
                blob = _blobClientProvider.GetBlobClient(historicalFilePath);
                if (await blob.ExistsAsync())
                {
                    using (var stream = await blob.OpenReadAsync())
                    {
                        return(GetArchiveFile(stream, date, parser));
                    }
                }
            }
            return(new List <ISensorData>());
        }
 private void SetUpBlobClientProvider()
 {
     _blobClientProvider = Substitute.For <IBlobClientProvider>();
     _blobClientProvider.GetBlobClient(_humidityFilePath).Returns(_humidityBlob);
     _blobClientProvider.GetBlobClient(_rainfallFilePath).Returns(_rainfallBlob);
     _blobClientProvider.GetBlobClient(_temperatureFilePath).Returns(_temperatureBlob);
     _blobClientProvider.GetBlobClient(_humidityHistoricalFilePath).Returns(_humidityHistoricalBlob);
     _blobClientProvider.GetBlobClient(_rainfallHistoricalFilePath).Returns(_rainfallHistoricalBlob);
     _blobClientProvider.GetBlobClient(_temperatureHistoricalFilePath).Returns(_temperatureHistoricalBlob);
 }