Skip to content

Commit

Permalink
update CustomTestStorageAccountProvider to use IStorageServiceClientP…
Browse files Browse the repository at this point in the history
…roviderFactory
  • Loading branch information
nytian committed Nov 13, 2024
1 parent 9facae2 commit cbedfe5
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions test/Common/CustomTestStorageAccountProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System;
using Azure.Data.Tables;
using Azure.Storage.Blobs;
using Azure.Storage.Queues;
using DurableTask.AzureStorage;
using Microsoft.WindowsAzure.Storage;
using Microsoft.Azure.WebJobs.Extensions.DurableTask.Storage;

namespace Microsoft.Azure.WebJobs.Extensions.DurableTask.Tests
{
internal class CustomTestStorageAccountProvider : IStorageAccountProvider
internal class CustomTestStorageAccountProvider : IStorageServiceClientProviderFactory
{
private readonly string customConnectionString;
private readonly string customConnectionName;
Expand All @@ -18,11 +21,14 @@ public CustomTestStorageAccountProvider(string connectionName)
this.customConnectionString = $"DefaultEndpointsProtocol=https;AccountName=test;AccountKey={GenerateRandomKey()};EndpointSuffix=core.windows.net";
}

public CloudStorageAccount GetCloudStorageAccount(string name) =>
CloudStorageAccount.Parse(name != this.customConnectionName ? TestHelpers.GetStorageConnectionString() : this.customConnectionString);
public IStorageServiceClientProvider<BlobServiceClient, BlobClientOptions> GetBlobClientProvider(string connectionName) =>
StorageServiceClientProvider.ForBlob(TestHelpers.GetStorageConnectionString());

public StorageAccountDetails GetStorageAccountDetails(string name) =>
new StorageAccountDetails { ConnectionString = name != this.customConnectionName ? TestHelpers.GetStorageConnectionString() : this.customConnectionString };
public IStorageServiceClientProvider<QueueServiceClient, QueueClientOptions> GetQueueClientProvider(string connectionName) =>
StorageServiceClientProvider.ForQueue(TestHelpers.GetStorageConnectionString());

public IStorageServiceClientProvider<TableServiceClient, TableClientOptions> GetTableClientProvider(string connectionName) =>
StorageServiceClientProvider.ForTable(TestHelpers.GetStorageConnectionString());

private static string GenerateRandomKey()
{
Expand Down

0 comments on commit cbedfe5

Please sign in to comment.