public void GivenCommentAttributeWithId_WhenSearchingById_ShouldBeSameAsTheAddedOne() { NewElement element = AttributesMapperSettersTests.InitializeEmptyNewElement(); int id = 5; var att = new CommentAttribute() { Id = id }; element.CommentAttributes.Add(att); var foundAttribute = AttributesMapper.GetAttributeById <CommentAttribute>(element, id); foundAttribute.Should().Be(att); }
public void GivenCommentAttributeWithName_WhenSearchingByName_ShouldBeSameAsTheAddedOne() { NewElement element = AttributesMapperSettersTests.InitializeEmptyNewElement(); string fieldName = "WFD_Comment1"; var att = new CommentAttribute() { FieldName = fieldName }; element.CommentAttributes.Add(att); var foundAttribute = AttributesMapper.GetAttributeByName <CommentAttribute>(element, fieldName); foundAttribute.Should().Be(att); }
public void GivenCommentAttributeWithId_WhenSearchingById_ShouldNotThrow() { NewElement element = AttributesMapperSettersTests.InitializeEmptyNewElement(); int id = 5; var att = new CommentAttribute() { Id = id }; element.CommentAttributes.Add(att); Action a = () => AttributesMapper.GetAttributeById <CommentAttribute>(element, id); a.Should().NotThrow <FieldNotFoundException>(); }
public void GivenCommentAttributeWithName_WhenSearchingByName_ShouldNotThrow() { NewElement element = AttributesMapperSettersTests.InitializeEmptyNewElement(); string fieldName = "WFD_Comment1"; var att = new CommentAttribute() { FieldName = fieldName }; element.CommentAttributes.Add(att); Action a = () => AttributesMapper.GetAttributeByName <CommentAttribute>(element, fieldName); a.Should().NotThrow <FieldNotFoundException>(); }
public List <String> mapToEcr(String ecmProperty, WorkItem workItem) { List <String> mappedValues = new List <String>(); List <Property> properties = AttributesMapper.getInstance().getInverseProperties(ecmProperty); if (properties == null) { // Property has no inverse entry in mapping - inconsistent state HandlerSettings.LogMessage( String.Format("Property: {0} has no inverse entry in mapping file", ecmProperty), HandlerSettings.LoggingLevel.WARN); return(mappedValues); } foreach (Property property in properties) { // Get the TFS fieldName mapped to the ecmProperty String fieldName = property.getValue(); // Get the TFS fieldValue for the fieldName String fieldValue = getFieldValue(workItem, fieldName); // Handle "use" case String useMapping = property.getUseMapping(); if (useMapping != null && useMapping.Equals("ProductMapping")) { PRIMProduct primProduct = ProductMapper.getInstance().GetProduct(fieldValue); if (primProduct == null) { // No product found for release, so this is not a maintenance Bug. // Should likely have been caught before this, but return empty. return(mappedValues); } String useKey = property.getUseKey(); if (useKey != null) { if (useKey.Equals("primProdNo")) { mappedValues.Add(primProduct.getPrimProdNo()); } else if (useKey.Equals("primRState")) { mappedValues.Add(primProduct.getPrimRState()); } } return(mappedValues); } // Get or adjust the TFS value in case of complex mapping fieldValue = getTFSFieldValue(workItem, fieldName, fieldValue); // Lookup value in the property value map table. If mapped value is found, // this is added. Else if defaultValue is defined, this is used. Else the // fieldValue itself is returned. List <String> values = property.getInverse(fieldValue, workItem); if (values != null) { foreach (String mappedValue in values) { String adjustedValue = adjustTFSFieldValue(workItem, fieldName, mappedValue); mappedValues.Add(adjustedValue); } } } return(mappedValues); }