Ejemplo n.º 1
0
        protected WorkItemLinkTypeEnd CalculateWorkItemLinkTypeEnd(WorkItemStore workItemStore)
        {
            WorkItemLinkTypeEnd linkTypeEnd = null;

            if (WorkItemRelationType == null)
            {
                return(null);
            }

            if (WorkItemRelationType is string)
            {
                string linkTypeEndName = WorkItemRelationType as string;

                WorkItemLinkTypeEndCollection linkTypeCollection = workItemStore.WorkItemLinkTypes.LinkTypeEnds;
                if (!linkTypeCollection.Contains(linkTypeEndName))
                {
                    throw new InvalidOperationException(string.Format("Work item link type \"{0}\" doesn't exist, cannot create links to connect to parent work item.", linkTypeEndName));
                }

                linkTypeEnd = workItemStore.WorkItemLinkTypes.LinkTypeEnds[linkTypeEndName];
            }
            else if (WorkItemRelationType is WorkItemLinkTypeEnd)
            {
                linkTypeEnd = WorkItemRelationType as WorkItemLinkTypeEnd;
            }
            else
            {
                throw new PSArgumentException("Work item link type only must be a string or WorkItemLinkTypeEnd object.");
            }

            return(linkTypeEnd);
        }
Ejemplo n.º 2
0
        private WorkItemLinkTypeEnd EnsureWorkItemLinkTypeEnd(WorkItemStore workItemStore)
        {
            WorkItemLinkTypeEnd linkTypeEnd = null;

            if (WorkItemRelationType == null)
            {
                throw new ArgumentException("Work item link type must be specified!");
            }
            else if (WorkItemRelationType is string)
            {
                string linkTypeEndName = WorkItemRelationType as string;

                WorkItemLinkTypeEndCollection linkTypeCollection = workItemStore.WorkItemLinkTypes.LinkTypeEnds;
                if (!linkTypeCollection.Contains(linkTypeEndName))
                {
                    throw new InvalidOperationException(string.Format("Work item link type \"{0}\" doesn't exist, cannot create links to connect to parent work item.", linkTypeEndName));
                }

                linkTypeEnd = workItemStore.WorkItemLinkTypes.LinkTypeEnds[linkTypeEndName];
            }
            else if (WorkItemRelationType is WorkItemLinkTypeEnd)
            {
                linkTypeEnd = WorkItemRelationType as WorkItemLinkTypeEnd;
            }

            return(linkTypeEnd);
        }
Ejemplo n.º 3
0
        public WorkItemGenerator(string serverName, string projectName)
        {
            if (string.IsNullOrEmpty(serverName))
            {
                throw new ArgumentNullException("serverName", "servername is null");
            }
            if (string.IsNullOrEmpty(projectName))
            {
                throw new ArgumentNullException("projectName", "projectName is null");
            }

            TeamProjectCollection = new TfsTeamProjectCollection(new Uri(serverName), new Services.Common.VssCredentials());

            // Get the Test Management Service
            ITestManagementService service = (ITestManagementService)TeamProjectCollection.GetService(typeof(ITestManagementService));

            // Initialize the TestManagement Team Project
            m_teamProject = (ITestManagementTeamProject)service.GetTeamProject(projectName);

            ILocationService locationService = TeamProjectCollection.GetService <ILocationService>();

            IsTFS2012 = !String.IsNullOrEmpty(locationService.LocationForCurrentConnection("IdentityManagementService2",
                                                                                           new Guid("A4CE4577-B38E-49C8-BDB4-B9C53615E0DA")));

            // Set the Properties
            Server  = serverName;
            Project = projectName;

            SourceNameToFieldMapping = new Dictionary <string, IWorkItemField>();

            m_suiteCreater = new TestPlanAndSuiteCreator(m_teamProject);
            m_areaAndIterationPathCreator = new AreaAndIterationPathCreator(m_teamProject.WitProject);
            WorkItemCategoryToDefaultType = new Dictionary <string, string>();

            LinkTypeNames = new List <string>();
            m_workItemLinkTypeEndCollection = m_teamProject.WitProject.Store.WorkItemLinkTypes.LinkTypeEnds;
            foreach (WorkItemLinkTypeEnd linkTypeEnd in m_teamProject.WitProject.Store.WorkItemLinkTypes.LinkTypeEnds)
            {
                string linkTypeName = linkTypeEnd.Name;

                LinkTypeNames.Add(linkTypeName);
            }

            WorkItemTypeToCategoryMapping = new Dictionary <string, string>();
            WorkItemTypeNames             = new List <string>();

            PopulateWorkItemTypeDetailsFromCategory(m_teamProject.WitProject.Categories, BugCategory);
            PopulateWorkItemTypeDetailsFromCategory(m_teamProject.WitProject.Categories, RequirementCategory);

            Category testCaseCategory = m_teamProject.WitProject.Categories[TestCaseCategory];

            if (testCaseCategory != null)
            {
                DefaultWorkItemTypeName = testCaseCategory.DefaultWorkItemType.Name;
                PopulateWorkItemTypeDetailsFromCategory(m_teamProject.WitProject.Categories, TestCaseCategory);
            }

            CreateAreaIterationPath = true;
        }
        internal static WorkItemLinkTypeEndCollectionWrapper GetInstance()
        {
            WorkItemLinkTypeEndCollection real = default(WorkItemLinkTypeEndCollection);

            RealInstanceFactory(ref real);
            var instance = (WorkItemLinkTypeEndCollectionWrapper)WorkItemLinkTypeEndCollectionWrapper.GetWrapper(real);

            InstanceFactory(ref instance);
            if (instance == null)
            {
                Assert.Inconclusive("Could not Create Test Instance");
            }
            return(instance);
        }
Ejemplo n.º 5
0
        public static IEnumerable <WorkItemLinkTypeEnd> MatchWorkItemLinkTypeEnds(this WorkItemStore workItemStore, string linkTypeNamePattern)
        {
            WildcardPattern parsedNamePattern = new WildcardPattern(linkTypeNamePattern, WildcardOptions.Compiled | WildcardOptions.CultureInvariant | WildcardOptions.IgnoreCase);

            WorkItemLinkTypeEndCollection linkTypeCollection = workItemStore.WorkItemLinkTypes.LinkTypeEnds;

            foreach (WorkItemLinkTypeEnd workItemLinkTypeEnd in linkTypeCollection)
            {
                if (parsedNamePattern.IsMatch(workItemLinkTypeEnd.Name))
                {
                    yield return(workItemLinkTypeEnd);
                }
            }
        }
Ejemplo n.º 6
0
Archivo: Query.cs Proyecto: xul8tr/Qwiq
        public IWorkItemLinkTypeEndCollection GetLinkTypes()
        {
            if (_linkTypes != null)
            {
                return(_linkTypes);
            }

            var lt  = _query.GetLinkTypes();
            var lte = new List <IWorkItemLinkTypeEnd>(lt.Length);

            foreach (var l in lt)
            {
                var item = new WorkItemLinkTypeEnd(l);
                lte.Add(item);
            }

            var retval = new WorkItemLinkTypeEndCollection(lte);

            _linkTypes = retval;

            return(_linkTypes);
        }
 static partial void RealInstanceFactory(ref WorkItemLinkTypeEndCollection real, [CallerMemberName] string callerName = "");
Ejemplo n.º 8
0
        protected override void ProcessRecordInEH()
        {
            Project project = EnsureProject();

            WorkItemType workItemType = EnsureWorkItemType(project);

            WorkItem workItem = workItemType.NewWorkItem();

            workItem.Title = Title;

            Field  assignedToField    = workItem.Fields[WIQLSystemFieldNames.AssignedTo];
            string assignedToUserPart = TfsWorkCmdletArgumentParser.ParseUserDisplayPartForWorkItemIdentityField("Assigned To", project.GetCollection(), assignedToField, AssignedTo);

            if (assignedToUserPart != null)
            {
                assignedToField.Value = assignedToUserPart;
            }

            if (Priority >= 0)
            {
                var priorityField = workItem.Fields[WIQLSystemFieldNames.Priority];
                if (priorityField == null)
                {
                    throw new PSArgumentException("This project doesn't support the default priority field.");
                }
                priorityField.Value = Priority;
            }

            if (!string.IsNullOrEmpty(Tags))
            {
                workItem.Tags = Tags;
            }

            if (!string.IsNullOrEmpty(AreaPath))
            {
                workItem.AreaPath = AreaPath;
            }

            if (!string.IsNullOrEmpty(IterationPath))
            {
                workItem.IterationPath = IterationPath;
            }

            if (Parent > 0)
            {
                WorkItemLinkTypeEndCollection linkTypeCollection = project.Store.WorkItemLinkTypes.LinkTypeEnds;
                if (!linkTypeCollection.Contains(TfsWorkItemSystemLinkTypeNames.SystemLinkTypesHiearachyReverse))
                {
                    throw new InvalidOperationException("Parent work item link type doesn't exist, cannot create links to connect to parent work item.");
                }

                WorkItemLinkTypeEnd linkTypeEnd = project.Store.WorkItemLinkTypes.LinkTypeEnds[TfsWorkItemSystemLinkTypeNames.SystemLinkTypesHiearachyReverse];
                workItem.Links.Add(new RelatedLink(linkTypeEnd, Parent));
            }

            if (Properties != null)
            {
                foreach (DictionaryEntry property in Properties)
                {
                    string propertyKey = property.Key as string;

                    Field propertyValue = workItem.Fields[propertyKey];
                    if (propertyValue == null)
                    {
                        throw new PSArgumentException(string.Format("Unexpected property: {0}.", propertyKey));
                    }

                    propertyValue.Value = property.Value;
                }
            }

            ArrayList validateResults = workItem.Validate();

            if (validateResults.Count > 0)
            {
                StringBuilder validateResultMessage = new StringBuilder();
                validateResultMessage.AppendLine("Work item validation failed!");
                validateResultMessage.AppendLine("Invaild fields are listed below:");

                foreach (Field field in validateResults)
                {
                    validateResultMessage.AppendFormat("- Field \"{0}\": {1}.", field.Name, field.Status.ToString());
                }

                throw new InvalidOperationException(validateResultMessage.ToString());
            }

            workItem.Save();

            WriteObject(workItem);
        }