/// <summary>
        /// Adds new startup task to the given role.
        /// </summary>
        /// <param name="roleName">The role name</param>
        /// <param name="commandLine">The startup task command line</param>
        /// <param name="context">The execution context</param>
        /// <param name="variables">The environment variables</param>
        public void AddStartupTask(
            string roleName,
            string commandLine,
            ExecutionContext context,
            params Variable[] variables)
        {
            Startup roleStartup = GetRoleStartup(roleName) ?? new Startup();
            Task newTask = new Task
            {
                Environment = variables,
                commandLine = commandLine,
                executionContext = context
            };

            roleStartup.Task = GeneralUtilities.ExtendArray<Task>(roleStartup.Task, newTask);
        }
Пример #2
0
 public static void StartupTaskExists(Task[] tasks, string startupCommand)
 {
     Assert.IsTrue(Array.Exists<Task>(tasks, t => t.commandLine == startupCommand));
 }
Пример #3
0
 public static void RuntimeIdExists(Task[] tasks, string runtimeValue)
 {
     Assert.IsTrue(Array.Exists<Task>(tasks, t => Array.Exists<Variable>(t.Environment,
         e => e.value != null && e.value.Contains(runtimeValue))));
 }
Пример #4
0
 public static void RuntimeUrlAndIdExists(Task[] tasks, string runtimeValue)
 {
     Assert.IsTrue(Array.Exists<Task>(tasks, t => Array.Exists<Variable>(t.Environment,
         e => e.value != null && e.value.Contains(runtimeValue))));
     Assert.IsTrue(Array.Exists<Task>(tasks, t => Array.Exists<Variable>(t.Environment,
         e => e.value != null && e.value.Contains(string.Format("http://az413943.vo.msecnd.net/{0}/", runtimeValue)))));
 }
        /// <summary>
        /// Return the value for the specified setting, if it exists in the given runtime environment
        /// </summary>
        /// <param name="environment">The runtime environment to search</param>
        /// <param name="key">The name of the setting</param>
        /// <param name="value">The value of the setting, if it is found, null otherwise</param>
        /// <returns>true if the setting is found in the given environment</returns>
        private static bool TryGetEnvironmentValue(Task[] tasks, string key, out string value)
        {
            value = string.Empty;

            foreach (Task task in tasks)
            {
                Variable[] environment = task.Environment;
                value = null;
                if (environment != null)
                {
                    foreach (Variable setting in environment)
                    {
                        if (string.Equals(setting.name, key, StringComparison.OrdinalIgnoreCase))
                        {
                            value = setting.value;
                            return true;
                        }
                    }
                }
            }

            return false;
        }