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"]);
        }
Example #2
0
        public void AfterCloseSettingDialogCancelTest()
        {
            if (order++ != 12)
            {
                throw new NotSupportedException("This unit test must run as order.");
            }

            proxy.AfterCloseSettingDialog(true);
            Assert.IsTrue(File.Exists(SettingDocumentType.FilePath));
            var view = proxy.InitializeSettingDialog();

            viewModel = (view as ITFSSettingView).GetViewModel <TFSSettingViewModel>();

            var idMapping      = viewModel.PropertyMappingCollection["ID"];
            var bugFilterField = viewModel.BugFilterField;
            var bugFilterValue = viewModel.BugFilterValue;

            viewModel.PropertyMappingCollection["ID"] = string.Empty;
            viewModel.BugFilterField = string.Empty;
            viewModel.BugFilterValue = string.Empty;
            Assert.AreEqual(SettingDialogValidateionResult.UnValid, proxy.ValidateBeforeCloseSettingDialog());

            proxy.AfterCloseSettingDialog(false);

            var doc = SettingDocumentType.Open();

            Assert.AreEqual(idMapping, doc.PropertyMappingCollection["ID"]);
            Assert.AreEqual(bugFilterField, doc.BugFilterField);
            Assert.AreEqual(bugFilterValue, doc.BugFilterValue);

            Assert.IsTrue(proxy.CanQuery);
        }
Example #3
0
        public void AfterCloseSettingDialogSubmitTest()
        {
            if (order++ != 9)
            {
                throw new NotSupportedException("This unit test must run as order.");
            }

            Assert.IsFalse(File.Exists(SettingDocumentType.FilePath));
            proxy.AfterCloseSettingDialog(true);
            Assert.IsTrue(File.Exists(SettingDocumentType.FilePath));

            var doc = SettingDocumentType.Open();

            Assert.AreEqual(viewModel.ConnectUri.AbsoluteUri, doc.ConnectUri.AbsoluteUri);
            Assert.AreEqual(viewModel.UserName, doc.UserName);
            Assert.AreEqual(viewModel.Password, doc.Password);

            Assert.AreEqual(viewModel.PropertyMappingCollection["ID"], doc.PropertyMappingCollection["ID"]);
            Assert.AreEqual(viewModel.PropertyMappingCollection["Title"], doc.PropertyMappingCollection["Title"]);
            Assert.AreEqual(viewModel.PropertyMappingCollection["Description"], doc.PropertyMappingCollection["Description"]);
            Assert.AreEqual(viewModel.PropertyMappingCollection["AssignedTo"], doc.PropertyMappingCollection["AssignedTo"]);
            Assert.AreEqual(viewModel.PropertyMappingCollection["State"], doc.PropertyMappingCollection["State"]);
            Assert.AreEqual(viewModel.PropertyMappingCollection["ChangedDate"], doc.PropertyMappingCollection["ChangedDate"]);
            Assert.AreEqual(viewModel.PropertyMappingCollection["CreatedBy"], doc.PropertyMappingCollection["CreatedBy"]);
            Assert.AreEqual(viewModel.PropertyMappingCollection["Priority"], doc.PropertyMappingCollection["Priority"]);

            Assert.AreEqual(viewModel.BugFilterField, doc.BugFilterField);
            Assert.AreEqual(viewModel.BugFilterValue, doc.BugFilterValue);
            Assert.AreEqual(viewModel.PriorityRed, doc.PriorityRed);

            Assert.IsTrue(proxy.CanQuery);
        }
Example #4
0
        /// <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;
        }