Beispiel #1
0
        public ScriptTask(
            string safeDirectoryPathForScripts,
            TaskConfiguration taskConfiguration,
            IProcessService processService)
        {
            Guard.Requires<ArgumentNullException>(safeDirectoryPathForScripts != null);
            Guard.Requires<ArgumentException>(
                Directory.Exists(safeDirectoryPathForScripts) == true,
                "Path specified for SafeDirectoryPathForScripts does not exist");

            Guard.Requires<ArgumentNullException>(taskConfiguration != null);
            Guard.Requires<TaskConfigurationException>(taskConfiguration.EntryExists(ScriptName) == true);
            Guard.Requires<TaskConfigurationException>(
                taskConfiguration.ReadEntryValue(ScriptName) != null && 
                taskConfiguration.ReadEntryValue(ScriptName) != string.Empty);

            filePath = Path.Combine(safeDirectoryPathForScripts, taskConfiguration.ReadEntryValue(ScriptName).ToString());
            Guard.Requires<FileNotFoundException>(File.Exists(filePath) == true);

            Guard.Requires<ArgumentNullException>(processService != null);

            this.taskConfiguration = taskConfiguration;
            this.safeDirectoryPathForScripts = safeDirectoryPathForScripts;
            this.processService = processService;
        }
            public void Assure_null_entries_are_ignored()
            {
                var config = new TaskConfiguration();
                config.Entries.Add(null);
                config.Entries.Add(new TaskConfigurationEntry(){Name = "testName", Value = "myValue",Type = typeof(string)});

                config.ReadEntryValue("testName").ShouldBe("myValue");
            }
Beispiel #3
0
        protected virtual IRepository<ProjectInfoServer> Assemble(TaskConfiguration config)
        {
            var remainingField = (string) config.ReadEntryValue(TFSProjectInfoSettingsConstants.REMAINING_SETTING_NAME);
            var estimatedField = (string) config.ReadEntryValue(TFSProjectInfoSettingsConstants.ESTIMATED_SETTING_NAME);

            var configDictionary = new Dictionary<String, String>();
            configDictionary["tfswi-remaining-field"] = (remainingField != "")
                                                            ? remainingField
                                                            : "Work Remaining (Scrum v3)";
            configDictionary["tfswi-estimated-field"] = (estimatedField != "")
                                                            ? estimatedField
                                                            : "Estimated Effort (Scrum v3)";


            var serverUrl = (string)config.ReadEntryValue(TFSProjectInfoSettingsConstants.URL_SETTING_NAME);
            var projectName = (string)config.ReadEntryValue(TFSProjectInfoSettingsConstants.PROJECT_SETTING_NAME);
            var username = (string)config.ReadEntryValue(TFSProjectInfoSettingsConstants.USERNAME_SETTING_NAME);
            var password = (string)config.ReadEntryValue(TFSProjectInfoSettingsConstants.PASSWORD_SETTING_NAME);
			string domain = username.Contains('\\') ? username.Substring(0, username.IndexOf('\\')) : null;
			username = username.Contains('\\') ? username.Substring(username.IndexOf('\\') + 1) : username;
			var cred = string.IsNullOrEmpty(domain) ? new NetworkCredential(username, password) : new NetworkCredential(username, password, domain);


            return new ScrumForTFSRepository(serverUrl, projectName, configDictionary, cred);
        }
        public TFSChangesetHarvesterTask(IRepository<Changeset> changesetDbRepository, IPersistDomainModels<Changeset> databasePersister, TaskConfiguration config) 
            : base(changesetDbRepository, databasePersister, config)
        {
            Guard.Requires<ArgumentNullException>(changesetDbRepository != null);
            Guard.Requires<ArgumentNullException>(databasePersister != null);
            Guard.Requires<ArgumentNullException>(config != null);
            Guard.Requires<TaskConfigurationException>(config.Entries.Count() >= 4);

            var projectSettingValue = config.ReadEntryValue(PROJECT_SETTING_NAME) as string;

            Guard.Requires<ArgumentException>(
                projectSettingValue != null &&
                projectSettingValue.StartsWith("$\\"),
                string.Format("The setting named '{0}' needs to start with $\\, but was '{1}'", PROJECT_SETTING_NAME, projectSettingValue ?? "null" ));

            Interval = TimeSpan.FromMilliseconds(config.DispatchInterval);
        }