public static void AreEqualServiceComponents(ServiceComponents actual) { Assert.IsNotNull(actual.CloudConfig); Assert.IsNotNull(actual.Definition); Assert.IsNotNull(actual.LocalConfig); Assert.IsNotNull(actual.Settings); }
public CloudServiceProject(string cloudConfigurationFullPath) { Components = new ServiceComponents(cloudConfigurationFullPath); //since we are deploying from a prebuilt package, it doesn't matter whether //it comes from visual studio or powershell tools. //Here we just go with powershell one, because it is simple. Paths = new PowerShellProjectPathInfo(Path.GetDirectoryName(cloudConfigurationFullPath)); }
public void ServiceComponentsTest() { TestMockSupport.TestExecutionFolder = AppDomain.CurrentDomain.BaseDirectory; newServiceCmdlet.NewAzureServiceProcess(TestMockSupport.TestExecutionFolder, serviceName); ServiceComponents components = new ServiceComponents( new PowerShellProjectPathInfo( Path.Combine(AppDomain.CurrentDomain.BaseDirectory, serviceName))); AzureAssert.AreEqualServiceComponents(components); }
public void ServiceComponentsTestNullPathsFail() { try { ServiceComponents components = new ServiceComponents(null as CloudProjectPathInfo); Assert.True(false, "No exception was thrown"); } catch (Exception ex) { Assert.True(ex is ArgumentException); Assert.Equal<string>(ex.Message, string.Format(Resources.NullObjectMessage, "paths")); } }
public CloudServiceProject(string rootPath, string scaffoldingPath) { SetScaffolding(scaffoldingPath); if (!VisualStudioProjectPathInfo.IsVisualStudioProject(rootPath)) { Paths = new PowerShellProjectPathInfo(rootPath); } else { Paths = new VisualStudioProjectPathInfo(rootPath); } Components = new ServiceComponents(Paths); }
public CloudServiceProject(string rootPath, string name, string scaffoldingPath) : this() { Validate.ValidateDirectoryFull(rootPath, Resources.ServiceParentDirectory); Validate.ValidateStringIsNullOrEmpty(name, "Name"); Validate.ValidateFileName(name, string.Format(Resources.InvalidFileName, "Name")); Validate.ValidateDnsName(name, "Name"); string newServicePath = Path.Combine(rootPath, name); if (Directory.Exists(newServicePath)) { throw new ArgumentException(string.Format(Resources.ServiceAlreadyExistsOnDisk, name, newServicePath)); } SetScaffolding(scaffoldingPath); Paths = new PowerShellProjectPathInfo(newServicePath); CreateNewService(Paths.RootPath, name); Components = new ServiceComponents(Paths); ConfigureNewService(Components, Paths, name); }
/// <summary> /// Creates a role name, ensuring it doesn't already exist. If null is passed in, a number will be appended to the defaultRoleName. /// </summary> /// <param name="name"></param> /// <param name="defaultName"></param> /// <param name="existingNames"></param> /// <returns></returns> private string GetRoleName(string name, string defaultName, IEnumerable <string> existingNames) { if (!string.IsNullOrEmpty(name)) { if (existingNames.Contains(name.ToLower())) { // Role does exist, user should pick a unique name // throw new ArgumentException(string.Format(Resources.AddRoleMessageRoleExists, name)); } if (!ServiceComponents.ValidRoleName(name)) { // The provided name is invalid role name // throw new ArgumentException(string.Format(Resources.InvalidRoleNameMessage, name)); } } if (name == null) { name = defaultName; } else { return(name); } int index = 1; string curName = name + index.ToString(); while (existingNames.Contains(curName.ToLower())) { curName = name + (++index).ToString(); } return(curName); }
/// <summary> /// Reloads the cloud service project configuration from the disk. /// </summary> public void Reload() { Paths = new ServicePathInfo(Paths.RootPath); Components = new ServiceComponents(Paths); }
/// <summary> /// Reloads the cloud service project configuration from the disk. /// </summary> public void Reload() { Components = new ServiceComponents(Paths); }
public void ServiceComponentsTestCloudConfigDoesNotExistFail() { TestMockSupport.TestExecutionFolder = AppDomain.CurrentDomain.BaseDirectory; newServiceCmdlet.NewAzureServiceProcess(TestMockSupport.TestExecutionFolder, serviceName); PowerShellProjectPathInfo paths = new PowerShellProjectPathInfo( Path.Combine(AppDomain.CurrentDomain.BaseDirectory, serviceName)); try { File.Delete(paths.CloudConfiguration); ServiceComponents components = new ServiceComponents(paths); Assert.True(false, "No exception was thrown"); } catch (Exception ex) { Assert.True(ex is FileNotFoundException); Assert.Equal<string>(ex.Message, string.Format(Resources.PathDoesNotExistForElement, Resources.ServiceConfiguration, paths.CloudConfiguration)); } }
private void ConfigureNewService(ServiceComponents components, CloudProjectPathInfo paths, string serviceName) { Components.Definition.name = serviceName; Components.CloudConfig.serviceName = serviceName; Components.LocalConfig.serviceName = serviceName; Components.Save(paths); }
public void ServiceComponentsTest() { newServiceCmdlet.NewAzureServiceProcess(Directory.GetCurrentDirectory(), serviceName); ServiceComponents components = new ServiceComponents(new PowerShellProjectPathInfo(serviceName)); AzureAssert.AreEqualServiceComponents(components); }
public void ServiceComponentsTestCloudConfigDoesNotExistFail() { newServiceCmdlet.NewAzureServiceProcess(Directory.GetCurrentDirectory(), serviceName); PowerShellProjectPathInfo paths = new PowerShellProjectPathInfo(serviceName); try { File.Delete(paths.CloudConfiguration); ServiceComponents components = new ServiceComponents(paths); Assert.True(false, "No exception was thrown"); } catch (Exception ex) { Assert.True(ex is FileNotFoundException); Assert.Equal<string>(ex.Message, string.Format(Resources.PathDoesNotExistForElement, Resources.ServiceConfiguration, paths.CloudConfiguration)); } }
public static void AzureServiceExists(string serviceRootPath, string scaffoldFilePath, string serviceName, ServiceSettings settings = null, WebRoleInfo[] webRoles = null, WorkerRoleInfo[] workerRoles = null, string webScaff = null, string workerScaff = null, RoleInfo[] roles = null) { ServiceComponents components = new ServiceComponents(new PowerShellProjectPathInfo(serviceRootPath)); ScaffoldingExists(serviceRootPath, scaffoldFilePath); if (webRoles != null) { for (int i = 0; i < webRoles.Length; i++) { ScaffoldingExists(Path.Combine(serviceRootPath, webRoles[i].Name), webScaff); } } if (workerRoles != null) { for (int i = 0; i < workerRoles.Length; i++) { ScaffoldingExists(Path.Combine(serviceRootPath, workerRoles[i].Name), workerScaff); } } AreEqualServiceConfiguration(components.LocalConfig, serviceName, roles); AreEqualServiceConfiguration(components.CloudConfig, serviceName, roles); IsValidServiceDefinition(components.Definition, serviceName, webRoles, workerRoles); AreEqualServiceSettings(settings ?? new ServiceSettings(), components.Settings); }
public CloudServiceProject(string rootPath, string scaffoldingPath) { SetScaffolding(scaffoldingPath); Paths = new ServicePathInfo(rootPath); Components = new ServiceComponents(Paths); }