private void RunExecuterWithExpectedBlobsInternal(IDictionary <string, int> blobNameMap, IBlobListenerStrategy product, LambdaBlobTriggerExecutor executor, int expectedCount)
        {
            if (blobNameMap.Count == 0)
            {
                executor.ExecuteLambda = (_) =>
                {
                    throw new InvalidOperationException("shouldn't be any blobs in the container");
                };
                product.Execute().Wait.Wait();
            }
            else
            {
                int count = 0;
                executor.ExecuteLambda = (b) =>
                {
                    Assert.Contains(blobNameMap.Keys, blob => blob == b.Name);
                    blobNameMap[b.Name]++;

                    if (b.DownloadText() == "throw")
                    {
                        // only increment if it's the first time.
                        // other calls are re-tries.
                        if (blobNameMap[b.Name] == 1)
                        {
                            count++;
                        }
                        return(false);
                    }
                    count++;
                    return(true);
                };
                product.Execute();
                Assert.Equal(expectedCount, count);
            }
        }
Пример #2
0
 private void RunExecuterWithExpectedBlobsInternal(List <string> expectedBlobNames, IBlobListenerStrategy product, LambdaBlobTriggerExecutor executor, int expectedCount)
 {
     if (expectedBlobNames.Count == 0)
     {
         executor.ExecuteLambda = (_) =>
         {
             throw new InvalidOperationException("shouldn't be any blobs in the container");
         };
         product.Execute().Wait.Wait();
     }
     else
     {
         int count = 0;
         executor.ExecuteLambda = (b) =>
         {
             count++;
             Assert.True(expectedBlobNames.Any(blob => blob == b.Name));
             return(true);
         };
         product.Execute();
         Assert.Equal(expectedCount, count);
     }
 }