public void SaveAndOpenTest()
        {
            SettingDocument document = SettingDocumentType.New();

            document.ConnectUri     = new Uri("https://tfs.codeplex.com:443/tfs/TFS12");
            document.BugFilterField = "Work Item Type";
            document.BugFilterValue = "Bugs";
            document.UserName       = "******";
            document.Password       = "******";
            document.PriorityRed    = "1;2";
            document.PropertyMappingCollection["ID"] = "ID";

            SettingDocumentType.Save(document);
            Assert.IsTrue(File.Exists(SettingDocumentType.FilePath));

            SettingDocument openDocument = SettingDocumentType.Open();

            Assert.AreEqual(document.ConnectUri.AbsoluteUri, openDocument.ConnectUri.AbsoluteUri);
            Assert.AreEqual(document.BugFilterField, openDocument.BugFilterField);
            Assert.AreEqual(document.BugFilterValue, openDocument.BugFilterValue);
            Assert.AreEqual(document.UserName    = "******", openDocument.UserName);
            Assert.AreEqual(document.Password    = "******", openDocument.Password);
            Assert.AreEqual(document.PriorityRed = "1;2", openDocument.PriorityRed);
            Assert.AreEqual(document.PropertyMappingCollection["ID"], openDocument.PropertyMappingCollection["ID"]);
        }
Beispiel #2
0
        /// <summary>
        /// Do something afters close setting dialog.
        /// </summary>
        /// <param name="submit">If the dialog is return as submit..</param>
        public override void AfterCloseSettingDialog(bool submit)
        {
            RemoveWeakEventListener(this.settingViewModel, SettingViewModelPropertyChanged);

            if (!submit)
            {
                UpdateStateValues(this.document.PropertyMappingCollection["State"], this.tfsFieldsCache);
                return;
            }

            this.document.ConnectUri = this.settingViewModel.ConnectUri;
            this.document.UserName   = this.settingViewModel.UserName;
            this.document.Password   = this.settingViewModel.Password;

            this.document.PropertyMappingCollection.Clear();
            foreach (var mapping in this.settingViewModel.PropertyMappingCollection)
            {
                this.document.PropertyMappingCollection.Add(mapping.Key, mapping.Value);
            }

            this.tfsFieldsCache.Clear();
            this.tfsFieldsCache.AddRange(this.settingViewModel.TFSFields);

            this.document.BugFilterField = this.settingViewModel.BugFilterField;
            this.document.BugFilterValue = this.settingViewModel.BugFilterValue;
            this.document.PriorityRed    = this.settingViewModel.PriorityRed;

            this.CanQuery = false;

            if ((this.settingViewModel.ProgressType == ProgressTypes.Success ||
                 this.settingViewModel.ProgressType == ProgressTypes.SuccessWithError)
                &&
                (!string.IsNullOrWhiteSpace(this.settingViewModel.BugFilterField) &&
                 !string.IsNullOrWhiteSpace(this.settingViewModel.BugFilterValue) &&
                 this.settingViewModel.PropertyMappingCollection
                 .Where(x => !ignoreField.Contains(x.Key))
                 .Any(x =>
            {
                return(!string.IsNullOrWhiteSpace(x.Value));
            })))
            {
                this.CanQuery = true;
            }

            SettingDocumentType.Save(this.document);
        }