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"]);
        }
        public void NewTest()
        {
            SettingDocument document = SettingDocumentType.New();

            Assert.IsNotNull(document);
            Assert.IsFalse(File.Exists(SettingDocumentType.FilePath));
        }
示例#3
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);
        }
示例#4
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);
        }
示例#5
0
文件: TFSProxy.cs 项目: alibad/Bugger
        /// <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;
        }
示例#6
0
文件: TFSProxy.cs 项目: alibad/Bugger
        /// <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);
        }