1- // Copyright (c) .NET Foundation. All rights reserved.
1+ // Copyright (c) .NET Foundation. All rights reserved.
22// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33
44using System . Collections . Generic ;
@@ -11,33 +11,52 @@ namespace NgTests
1111{
1212 public class StorageFactoryTests
1313 {
14- [ Theory ]
15- [ Description ( "The regular azure factory should not compress the content if." ) ]
16- [ InlineData ( "http://localhost/reg" , "testAccount" , "DummyDUMMYpZxLeDumMyyN52gJj+ZlGE0ipRi9PaTcn9AU4epwvsngE5rLSMk9TwpazxUtzeyBnFeWFAdummyw==" , "testContainer" , "testStoragePath" , "azure" , "core.windows.net" ) ]
17- public void AzureFactory ( string storageBaseAddress ,
18- string storageAccountName ,
19- string storageKeyValue ,
20- string storageContainer ,
21- string storagePath ,
22- string storageType ,
23- string storageSuffix )
14+ private const string DummyKey = "DummyDUMMYpZxLeDumMyyN52gJj+ZlGE0ipRi9PaTcn9AU4epwvsngE5rLSMk9TwpazxUtzeyBnFeWFAdummyw==" ;
15+
16+ [ Fact ]
17+ public void AzureFactory_DefaultsToAzurePublicWithNoCompression ( )
2418 {
19+ // Arrange
2520 Dictionary < string , string > arguments = new Dictionary < string , string > ( )
2621 {
27- { Arguments . StorageBaseAddress , storageBaseAddress } ,
28- { Arguments . StorageAccountName , storageAccountName } ,
29- { Arguments . StorageKeyValue , storageKeyValue } ,
30- { Arguments . StorageContainer , storageContainer } ,
31- { Arguments . StoragePath , storagePath } ,
32- { Arguments . StorageType , storageType } ,
33- { Arguments . StorageSuffix , storageSuffix } // Without BlobServiceClient couldn't create new instance.
22+ { Arguments . StorageBaseAddress , "http://localhost/reg" } ,
23+ { Arguments . StorageAccountName , "testAccount" } ,
24+ { Arguments . StorageKeyValue , DummyKey } ,
25+ { Arguments . StorageContainer , "testContainer" } ,
26+ { Arguments . StoragePath , "testStoragePath" } ,
27+ { Arguments . StorageType , "azure" } ,
3428 } ;
3529
30+ // Act
3631 StorageFactory factory = CommandHelpers . CreateStorageFactory ( arguments , true ) ;
37- AzureStorageFactory azureFactory = factory as AzureStorageFactory ;
32+
3833 // Assert
39- Assert . True ( azureFactory != null , "The CreateCompressedStorageFactory should return an AzureStorageFactory type." ) ;
34+ var azureFactory = Assert . IsType < AzureStorageFactory > ( factory ) ;
4035 Assert . False ( azureFactory . CompressContent , "The azure storage factory should not compress the content." ) ;
36+ Assert . Equal ( "https://testaccount.blob.core.windows.net/testContainer/testStoragePath/" , azureFactory . DestinationAddress . AbsoluteUri ) ;
37+ }
38+
39+ [ Fact ]
40+ public void AzureFactory_AllowsCustomStorageSuffix ( )
41+ {
42+ // Arrange
43+ Dictionary < string , string > arguments = new Dictionary < string , string > ( )
44+ {
45+ { Arguments . StorageBaseAddress , "http://localhost/reg" } ,
46+ { Arguments . StorageAccountName , "testAccount" } ,
47+ { Arguments . StorageKeyValue , DummyKey } ,
48+ { Arguments . StorageContainer , "testContainer" } ,
49+ { Arguments . StoragePath , "testStoragePath" } ,
50+ { Arguments . StorageType , "azure" } ,
51+ { Arguments . StorageSuffix , "core.chinacloudapi.cn" } ,
52+ } ;
53+
54+ // Act
55+ StorageFactory factory = CommandHelpers . CreateStorageFactory ( arguments , true ) ;
56+
57+ // Assert
58+ var azureFactory = Assert . IsType < AzureStorageFactory > ( factory ) ;
59+ Assert . Equal ( "https://testaccount.blob.core.chinacloudapi.cn/testContainer/testStoragePath/" , azureFactory . DestinationAddress . AbsoluteUri ) ;
4160 }
4261 }
4362}
0 commit comments