public void NewTest() { SettingDocument document = SettingDocumentType.New(); Assert.IsNotNull(document); Assert.IsFalse(File.Exists(SettingDocumentType.FilePath)); }
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"]); }
/// <summary> /// The method which will execute when the Controller.Initialize() execute. /// </summary> protected override void OnInitialize() { ignoreField = new List <string>(); ignoreField.Add("Severity"); // Open the setting file if (File.Exists(SettingDocumentType.FilePath)) { try { this.document = SettingDocumentType.Open(); } catch { this.messageService.ShowError(Resources.CannotOpenFile); this.document = SettingDocumentType.New(); } } else { this.document = SettingDocumentType.New(); } // Validate Connect Information if (this.document == null || this.document.ConnectUri == null || string.IsNullOrWhiteSpace(this.document.ConnectUri.AbsoluteUri) || string.IsNullOrWhiteSpace(this.document.UserName)) { return; } // Connect to TFS TfsTeamProjectCollection tpc = null; if (!tfsHelper.TryConnection(this.document.ConnectUri, this.document.UserName, this.document.Password, out tpc)) { return; } // Get Fields var fields = tfsHelper.GetFields(tpc); if (fields == null || !fields.Any()) { return; } this.tfsFieldsCache.AddRange(tfsHelper.GetFields(tpc)); UpdateStateValues(this.document.PropertyMappingCollection["State"], this.tfsFieldsCache); this.CanQuery = true; }