public void Format_Name_Returns_Correct_Fragments() { var role = new RoleModel {RoleName = "name", DeploymentSlot = "staging", Location = "West US"}; var formattedName = role.FormatName("rp"); Assert.AreEqual("rp.staging.westus", formattedName); }
public static RoleModel GetRoleDetails([NotNull] string subscriptionId, [NotNull] string thumbprint) { RoleModel roleInfo = null; var certificate = CertificateFactory.GetStoreCertificate(thumbprint); if (certificate == null) return null; var hostedServiceNames = ServiceManagementRequest.GetHostedServiceNames(subscriptionId, certificate); if (hostedServiceNames.Count <= 0) return null; foreach (var hostedServiceName in hostedServiceNames) { if (string.IsNullOrEmpty(hostedServiceName)) continue; var data = ServiceManagementRequest.GetHostedService(hostedServiceName, subscriptionId, certificate); if (data == null) continue; var deploymentLocation = data.Element(XName.Get("HostedServiceProperties", ServiceManagementRequest.ANS)) .Element(XName.Get("Location", ServiceManagementRequest.ANS)).Value; var deploymentXElements = data.Elements(XName.Get("Deployments", ServiceManagementRequest.ANS)) .Elements(XName.Get("Deployment", ServiceManagementRequest.ANS)) .ToList(); if (deploymentXElements.Count <= 0) continue; foreach ( var deploymentSlotName in from deployment in deploymentXElements where deployment != null let currentDeploymentId = deployment.Element(XName.Get("PrivateID", ServiceManagementRequest.ANS)).Value where currentDeploymentId == RoleEnvironment.DeploymentId select deployment.Element(XName.Get("DeploymentSlot", ServiceManagementRequest.ANS)).Value ) { roleInfo = new RoleModel() { RoleName = hostedServiceName, DeploymentSlot = deploymentSlotName, Location = deploymentLocation }; break; } //Exit as soon as the role is found if (roleInfo != null) break; } return roleInfo; }
public void Set_RoleName_Returns_Value() { var role = new RoleModel {RoleName = "name", DeploymentSlot = "staging", Location = "West US"}; Assert.AreEqual("name", role.RoleName); }