A class used to simulate the behavior of a storage account as far as existing, creation, and querying are concerned.
 private void SetupStorage(string name, MockStorageService.StorageAccountData a)
 {
     a.Name = name;
     a.BlobEndpoint = "http://awesome.blob.core.windows.net/";
     a.QueueEndpoint = "http://awesome.queue.core.windows.net/";
     a.TableEndpoint = "http://awesome.table.core.windows.net/";
     a.PrimaryKey =
         "MNao3bm7t7B/x+g2/ssh9HnG0mEh1QV5EHpcna8CetYn+TSRoA8/SBoH6B3Ufwtnz3jZLSw9GEUuCTr3VooBWq==";
     a.SecondaryKey = "secondaryKey";
 }
Exemplo n.º 2
0
        public CloudServiceClientTests()
        {
            AzurePowerShell.ProfileDirectory = Test.Utilities.Common.Data.AzureSdkAppDir;

            storageService = new MockStorageService()
                             .Add(a => SetupStorage(serviceName.ToLowerInvariant(), a))
                             .Add(a => SetupStorage(storageName.ToLowerInvariant(), a));

            services = new MockServicesHost()
                       .Add(s =>
            {
                s.Name = serviceName;
                s.AddDeployment(d =>
                {
                    d.Slot = DeploymentSlot.Production;
                    d.Name = "mydeployment";
                });
            });

            subscription = new AzureSubscription
            {
                Properties = new Dictionary <AzureSubscription.Property, string> {
                    { AzureSubscription.Property.Default, "True" }
                },
                Id   = Guid.NewGuid(),
                Name = Test.Utilities.Common.Data.Subscription1,
            };

            cloudBlobUtilityMock = new Mock <CloudBlobUtility>();
            cloudBlobUtilityMock.Setup(f => f.UploadPackageToBlob(
                                           It.IsAny <StorageManagementClient>(),
                                           It.IsAny <string>(),
                                           It.IsAny <string>(),
                                           It.IsAny <BlobRequestOptions>())).Returns(new Uri("http://www.packageurl.azure.com"));

            clientMocks = new ClientMocks(subscription.Id);

            services.InitializeMocks(clientMocks.ComputeManagementClientMock);
            storageService.InitializeMocks(clientMocks.StorageManagementClientMock);

            client = new CloudServiceClient(subscription,
                                            clientMocks.ManagementClientMock.Object,
                                            clientMocks.StorageManagementClientMock.Object,
                                            clientMocks.ComputeManagementClientMock.Object
                                            )
            {
                CloudBlobUtility = cloudBlobUtilityMock.Object
            };
        }
        public CloudServiceClientTests()
        {
            AzurePowerShell.ProfileDirectory = Test.Utilities.Common.Data.AzureSdkAppDir;

            storageService = new MockStorageService()
                .Add(a => SetupStorage(serviceName.ToLowerInvariant(), a))
                .Add(a => SetupStorage(storageName.ToLowerInvariant(), a));

            services = new MockServicesHost()
                .Add(s =>
                {
                    s.Name = serviceName;
                    s.AddDeployment(d =>
                    {
                        d.Slot = DeploymentSlot.Production;
                        d.Name = "mydeployment";
                    });
                });

            subscription = new AzureSubscription
            {
                Properties = new Dictionary<AzureSubscription.Property,string> {{AzureSubscription.Property.Default, "True"}},
                Id = Guid.NewGuid(),
                Name = Test.Utilities.Common.Data.Subscription1,
            };

            cloudBlobUtilityMock = new Mock<CloudBlobUtility>();
            cloudBlobUtilityMock.Setup(f => f.UploadPackageToBlob(
                It.IsAny<StorageManagementClient>(),
                It.IsAny<string>(),
                It.IsAny<string>(),
                It.IsAny<BlobRequestOptions>())).Returns(new Uri("http://www.packageurl.azure.com"));

            clientMocks = new ClientMocks(subscription.Id);

            services.InitializeMocks(clientMocks.ComputeManagementClientMock);
            storageService.InitializeMocks(clientMocks.StorageManagementClientMock);

            client = new CloudServiceClient(subscription,
                clientMocks.ManagementClientMock.Object,
                clientMocks.StorageManagementClientMock.Object,
                clientMocks.ComputeManagementClientMock.Object
                )
            {
                CloudBlobUtility = cloudBlobUtilityMock.Object
            };
        }