public async void WeDoGetDataFromBlobStorage() { var acc = new Mock <ICloudStorageAccount>(); var blobClient = new Mock <CloudBlobClient>(new Uri("https://ww.google.com"), new StorageCredentials()); var blobContainer = new Mock <CloudBlobContainer>(new Uri("https://www.google.com")); var blob = new Mock <CloudBlob>(new Uri("https://waterfinder.blob.core.windows.net/data")); var riverList = new List <River>() { new River() }; var listString = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(riverList)); using (var val = new MemoryStream(listString)) { blob.Setup(b => b.OpenReadAsync()).ReturnsAsync(val); blobContainer.Setup(bc => bc.GetBlobReference(It.IsAny <string>())).Returns(blob.Object); blobClient.Setup(b => b.GetContainerReference(It.IsAny <string>())).Returns(blobContainer.Object); acc.Setup(c => c.CreateCloudBlobClient()).Returns(blobClient.Object); var fac = new AzureStorageFactory(acc.Object) { CollectionName = "PIZZA" }; var stuff = await fac.GetAsync <List <River> >("TACOS"); Assert.NotEmpty(stuff); } }
public async void ReturnsListKeyValuePair() { var mock = GetTableQuerySegments(); TableMock.Setup(tt => tt.ExistsAsync()).ReturnsAsync(true); TableMock.Setup(tt => tt.ExecuteQuerySegmentedAsync(It.IsAny <TableQuery>(), It.IsAny <TableContinuationToken>())) .ReturnsAsync(mock); var fac = new AzureStorageFactory(AccountMock.Object) { CollectionName = "RiversUnitedStates" }; var query = new TableQuery() .Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "search")); var stuff = await fac.GetAsync <List <KeyValuePair <string, string> > >(query); Assert.IsType <List <KeyValuePair <string, string> > > (stuff); }