コード例 #1
0
        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 Microsoft.WindowsAzure.Management.CloudService.Model.ServiceComponents(new Microsoft.WindowsAzure.Management.CloudService.Model.ServicePathInfo(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);
        }
コード例 #2
0
 public static void AreEqualServiceComponents(ServiceComponents actual)
 {
     Assert.IsNotNull(actual.CloudConfig);
     Assert.IsNotNull(actual.Definition);
     Assert.IsNotNull(actual.LocalConfig);
     Assert.IsNotNull(actual.Settings);
 }
コード例 #3
0
ファイル: AzureService.cs プロジェクト: nickchal/pash
        public AzureService(string serviceParentDirectory, string name, string scaffoldingPath)
            : this()
        {
            Validate.ValidateDirectoryFull(serviceParentDirectory, Resources.ServiceParentDirectory);
            Validate.ValidateStringIsNullOrEmpty(name, "Name");
            Validate.ValidateFileName(name, string.Format(Resources.InvalidFileName, "Name"));
            Validate.ValidateDnsName(name, "Name");

            string newServicePath = Path.Combine(serviceParentDirectory, name);
            if (Directory.Exists(newServicePath))
            {
                throw new ArgumentException(string.Format(Resources.ServiceAlreadyExistsOnDisk, name, newServicePath));
            }

            SetScaffolding(scaffoldingPath);
            Paths = new ServicePathInfo(newServicePath);
            CreateNewService(Paths.RootPath, name);
            Components = new ServiceComponents(Paths);
            ConfigureNewService(Components, Paths, name);
        }
コード例 #4
0
        public AzureService(string serviceParentDirectory, string name, string scaffoldingPath)
            : this()
        {
            Validate.ValidateDirectoryFull(serviceParentDirectory, Resources.ServiceParentDirectory);
            Validate.ValidateStringIsNullOrEmpty(name, "Name");
            Validate.ValidateFileName(name, string.Format(Resources.InvalidFileName, "Name"));
            Validate.ValidateDnsName(name, "Name");

            string newServicePath = Path.Combine(serviceParentDirectory, name);

            if (Directory.Exists(newServicePath))
            {
                throw new ArgumentException(string.Format(Resources.ServiceAlreadyExistsOnDisk, name, newServicePath));
            }

            SetScaffolding(scaffoldingPath);
            Paths = new ServicePathInfo(newServicePath);
            CreateNewService(Paths.RootPath, name);
            Components = new ServiceComponents(Paths);
            ConfigureNewService(Components, Paths, name);
        }
コード例 #5
0
        /// <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);
        }
コード例 #6
0
ファイル: AzureService.cs プロジェクト: nickchal/pash
 private void ConfigureNewService(ServiceComponents components, ServicePathInfo paths, string serviceName)
 {
     Components.Definition.name = serviceName;
     Components.CloudConfig.serviceName = serviceName;
     Components.LocalConfig.serviceName = serviceName;
     Components.Save(paths);
 }
コード例 #7
0
ファイル: AzureService.cs プロジェクト: nickchal/pash
 public AzureService(string rootPath, string scaffoldingPath)
 {
     SetScaffolding(scaffoldingPath);
     Paths = new ServicePathInfo(rootPath);
     Components = new ServiceComponents(Paths);
 }
コード例 #8
0
        public void ServiceComponentsTestSettingsDoesNotExistFail()
        {
            new NewAzureServiceProjectCommand().NewAzureServiceProcess(Directory.GetCurrentDirectory(), serviceName);
            ServicePathInfo paths = new ServicePathInfo(serviceName);

            try
            {
                File.Delete(paths.Settings);
                ServiceComponents components = new ServiceComponents(paths);
                Assert.Fail("No exception was thrown");
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex is FileNotFoundException);
                Assert.AreEqual<string>(string.Format(Resources.PathDoesNotExistForElement, Resources.ServiceSettings, paths.Settings), ex.Message);
            }
        }
コード例 #9
0
 public void ServiceComponentsTestNullPathsFail()
 {
     try
     {
         ServiceComponents components = new ServiceComponents(null);
         Assert.Fail("No exception was thrown");
     }
     catch (Exception ex)
     {
         Assert.IsTrue(ex is ArgumentException);
         Assert.AreEqual<string>(ex.Message, string.Format(Resources.NullObjectMessage, "paths"));
     }
 }
コード例 #10
0
 public void ServiceComponentsTest()
 {
     new NewAzureServiceProjectCommand().NewAzureServiceProcess(Directory.GetCurrentDirectory(), serviceName);
     ServiceComponents components = new ServiceComponents(new ServicePathInfo(serviceName));
     AzureAssert.AreEqualServiceComponents(components);
 }
コード例 #11
0
        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 Microsoft.WindowsAzure.Management.CloudService.Model.ServiceComponents(new Microsoft.WindowsAzure.Management.CloudService.Model.ServicePathInfo(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);
        }
コード例 #12
0
 public AzureService(string rootPath, string scaffoldingPath)
 {
     SetScaffolding(scaffoldingPath);
     Paths      = new ServicePathInfo(rootPath);
     Components = new ServiceComponents(Paths);
 }