private bool CompareAggregatedFields(AggregatedFields newAggregatedFields, AggregatedFields currAggregatedFields)
        {
            foreach (FieldsAggregationGroup newGroup in newAggregatedFields.FieldsAggregationGroup)
            {
                var query = currAggregatedFields.FieldsAggregationGroup.Where(g =>
                                                                              g.Format == newGroup.Format && g.MapFromSide == newGroup.MapFromSide &&
                                                                              g.SourceField.Count == newGroup.SourceField.Count &&
                                                                              g.TargetFieldName == newGroup.TargetFieldName);

                if (query.Count() == 0)
                {
                    return(false);
                }

                Debug.Assert(query.Count() == 1, "query.Count() != 1");
                FieldsAggregationGroup currGroup = query.First();
                foreach (var sourceField in newGroup.SourceField)
                {
                    var sourceFldQuery = currGroup.SourceField.Where(f =>
                                                                     f.Index == sourceField.Index &&
                                                                     f.SourceFieldName == sourceField.SourceFieldName &&
                                                                     f.valueMap == sourceField.valueMap);
                    if (sourceFldQuery.Count() == 0)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Example #2
0
        public void SetAggregatedFieldMap(MigrationTestEnvironment env, Configuration config)
        {
            // Aggregated fields
            AggregatedFields       aggregatedFields = new AggregatedFields();
            FieldsAggregationGroup group            = new FieldsAggregationGroup();

            group.MapFromSide     = env.GetSourceSideTypeEnum();
            group.TargetFieldName = FIELD_DESCRIPTION;
            group.Format          = AggregationFormat;

            SourceField f0 = new SourceField();

            f0.Index           = 0;
            f0.SourceFieldName = FIELD_TITLE;

            SourceField f1 = new SourceField();

            f1.Index           = 1;
            f1.SourceFieldName = "System.Rev";

            group.SourceField.Add(f0);
            group.SourceField.Add(f1);

            aggregatedFields.FieldsAggregationGroup.Add(group);

            // construct FieldMap
            // Map all fields explictly using wildcard
            MappedField defaultField = env.NewMappedField("*", "*");

            FieldMap fieldMap = new FieldMap();

            fieldMap.name = "BugToBugFieldMap";
            fieldMap.MappedFields.MappedField.Add(defaultField);

            // TODO: Create another test case for aggreated fields feature
            // Construct configurations with conflicting field maps
            //MappedField mField1 = env.NewMappedField(FIELD_TITLE,FIELD_DESCRIPTION);

            //MappedField mField2 = env.NewMappedField(FIELD_DESCRIPTION,FIELD_TITLE);

            //fieldMap.MappedFields.MappedField.Add(mField1);
            //fieldMap.MappedFields.MappedField.Add(mField2);

            fieldMap.AggregatedFields = aggregatedFields;

            WorkItemTypeMappingElement typeMapping = new WorkItemTypeMappingElement();

            typeMapping.LeftWorkItemTypeName  = "Bug";
            typeMapping.RightWorkItemTypeName = "Bug";
            typeMapping.fieldMap = fieldMap.name;

            WITSessionCustomSetting customSetting = new WITSessionCustomSetting();

            customSetting.WorkItemTypes.WorkItemType.Add(typeMapping);
            customSetting.FieldMaps.FieldMap.Add(fieldMap);

            SetWitSessionCustomSetting(config, customSetting);
        }
Example #3
0
        void TestEnvironment_InsertWronglyIndexedAggrSrcField(Configuration config)
        {
            // Aggregated fields
            AggregatedFields       aggregatedFields = new AggregatedFields();
            FieldsAggregationGroup group            = new FieldsAggregationGroup();

            group.MapFromSide     = SourceSideTypeEnum.Left;
            group.TargetFieldName = FIELD_DESCRIPTION;
            group.Format          = AggregationFormat;

            // NOTE: both source fields are assigned with indice 10
            SourceField f0 = new SourceField();

            f0.Index           = 10;
            f0.SourceFieldName = FIELD_TITLE;

            SourceField f1 = new SourceField();

            f1.Index           = 10;
            f1.SourceFieldName = FIELD_DESCRIPTION;

            group.SourceField.Add(f0);
            group.SourceField.Add(f1);

            aggregatedFields.FieldsAggregationGroup.Add(group);

            // construct FieldMap
            // Map all fields explictly using wildcard
            MappedField defaultField = new MappedField();

            defaultField.LeftName    = "*";
            defaultField.RightName   = "*";
            defaultField.MapFromSide = SourceSideTypeEnum.Left;

            FieldMap fieldMap = new FieldMap();

            fieldMap.name = "BugToBugFieldMap";
            fieldMap.MappedFields.MappedField.Add(defaultField);

            fieldMap.AggregatedFields = aggregatedFields;

            WorkItemTypeMappingElement typeMapping = new WorkItemTypeMappingElement();

            typeMapping.LeftWorkItemTypeName  = "Bug";
            typeMapping.RightWorkItemTypeName = "Bug";
            typeMapping.fieldMap = fieldMap.name;

            WITSessionCustomSetting customSetting = new WITSessionCustomSetting();

            customSetting.WorkItemTypes.WorkItemType.Add(typeMapping);
            customSetting.FieldMaps.FieldMap.Add(fieldMap);

            SetWitSessionCustomSetting(config, customSetting);
        }