private Task <StorageAccountGetResponse> CreateGetResponse(string serviceName) { Task <StorageAccountGetResponse> resultTask; var data = accounts.FirstOrDefault(a => a.Name == serviceName); if (data != null) { var storageServiceGetResponse = new StorageAccountGetResponse { StorageAccount = new StorageAccount { Name = data.Name, Properties = new StorageAccountProperties { Endpoints = { new Uri(data.BlobEndpoint), new Uri(data.QueueEndpoint), new Uri(data.TableEndpoint) } } } }; resultTask = Tasks.FromResult(storageServiceGetResponse); } else { resultTask = Tasks.FromException <StorageAccountGetResponse>(ClientMocks.Make404Exception()); } return(resultTask); }
private Task <HostedServiceGetDetailedResponse> CreateGetDetailedResponse(string serviceName) { var service = Services.FirstOrDefault(s => s.Name == serviceName); Task <HostedServiceGetDetailedResponse> resultTask; if (service != null) { var response = new HostedServiceGetDetailedResponse { ServiceName = service.Name, StatusCode = HttpStatusCode.OK, }; if (service.ProductionDeployment != null) { response.Deployments.Add(CreateDeploymentResponse(service.ProductionDeployment)); } if (service.StagingDeployment != null) { response.Deployments.Add(CreateDeploymentResponse(service.StagingDeployment)); } resultTask = Tasks.FromResult(response); } else { resultTask = Tasks.FromException <HostedServiceGetDetailedResponse>(ClientMocks.Make404Exception()); } return(resultTask); }
private Task <DeploymentGetResponse> CreateDeploymentGetResponse(string serviceName, DeploymentSlot slot) { var service = Services.FirstOrDefault(s => s.Name == serviceName); var failedResponse = Tasks.FromException <DeploymentGetResponse>(ClientMocks.Make404Exception()); if (service == null) { return(failedResponse); } if (slot == DeploymentSlot.Production && service.ProductionDeployment == null || slot == DeploymentSlot.Staging && service.StagingDeployment == null) { return(failedResponse); } var response = new DeploymentGetResponse { Name = serviceName, Configuration = "config", DeploymentSlot = slot, Status = DeploymentStatus.Starting, PersistentVMDowntime = new PersistentVMDowntime { EndTime = DateTime.Now, StartTime = DateTime.Now, Status = "", }, LastModifiedTime = DateTime.Now }; return(Tasks.FromResult(response)); }
private Task <StorageAccountGetKeysResponse> CreateGetKeysResponse(string serviceName) { Task <StorageAccountGetKeysResponse> resultTask; var data = accounts.FirstOrDefault(a => a.Name == serviceName); if (data != null) { var response = new StorageAccountGetKeysResponse { PrimaryKey = data.PrimaryKey, SecondaryKey = data.SecondaryKey, StatusCode = HttpStatusCode.OK }; resultTask = Tasks.FromResult(response); } else { resultTask = Tasks.FromException <StorageAccountGetKeysResponse>(ClientMocks.Make404Exception()); } return(resultTask); }
public void AddUserAgentTest() { WindowsAzureSubscription subscription = new WindowsAzureSubscription { Certificate = It.IsAny<X509Certificate2>(), IsDefault = true, ServiceEndpoint = new Uri("https://www.azure.com"), SubscriptionId = Guid.NewGuid().ToString(), SubscriptionName = Data.Subscription1, }; WindowsAzureEnvironment environment = WindowsAzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud]; ClientMocks clientMocks = new ClientMocks(subscription.SubscriptionId); SubscriptionClient subscriptionClient = clientMocks.SubscriptionClientMock.Object; SubscriptionClient actual = environment.AddUserAgent(subscriptionClient); // verify the UserAgent is set in the subscription client Assert.IsTrue(actual.UserAgent.Contains(ApiConstants.UserAgentValue), "Missing proper UserAgent string."); }