예제 #1
0
        public void TestSetup()
        {
            GlobalPathInfo.GlobalSettingsDirectory = 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 WindowsAzureSubscription
            {
                Certificate      = It.IsAny <X509Certificate2>(),
                IsDefault        = true,
                ServiceEndpoint  = new Uri("https://www.azure.com"),
                SubscriptionId   = Guid.NewGuid().ToString(),
                SubscriptionName = 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.SubscriptionId);

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

            client = new CloudServiceClient(subscription,
                                            clientMocks.ManagementClientMock.Object,
                                            clientMocks.StorageManagementClientMock.Object,
                                            clientMocks.ComputeManagementClientMock.Object
                                            )
            {
                CloudBlobUtility = cloudBlobUtilityMock.Object
            };
        }
예제 #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 void TestSetup()
        {
            GlobalPathInfo.GlobalSettingsDirectory = 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 WindowsAzureSubscription
            {
                Certificate = It.IsAny<X509Certificate2>(),
                IsDefault = true,
                ServiceEndpoint = new Uri("https://www.azure.com"),
                SubscriptionId = Guid.NewGuid().ToString(),
                SubscriptionName = 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.SubscriptionId);

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

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