private XElement CreateFixturePropertiesElement(Type testFixtureType) { if (testFixtureType == null) { return(null); } var propertyElements = new HashSet <XElement>(); var attributes = testFixtureType.GetCustomAttributes(false) .Cast <Attribute>(); var description = ReflectionUtility.GetDescription(attributes); if (description != null) { var propertyElement = CreatePropertyElement("Description", description).Single(); propertyElements.Add(propertyElement); } var categories = ReflectionUtility.GetCategories(attributes); propertyElements.UnionWith(CreatePropertyElement("Category", categories)); return(propertyElements.Any() ? new XElement("properties", propertyElements.Distinct()) : null); }
private static XElement CreatePropertiesElement(TestResultInfo result) { var propertyElements = new HashSet <XElement>(result.Traits.Select(CreatePropertyElement)); #pragma warning disable CS0618 // Type or member is obsolete // Required since TestCase.Properties is a superset of TestCase.Traits // Unfortunately not all NUnit properties are available as traits var traitProperties = result.TestCase.Properties.Where(t => t.Attributes.HasFlag(TestPropertyAttributes.Trait)); #pragma warning restore CS0618 // Type or member is obsolete foreach (var p in traitProperties) { var propValue = result.TestCase.GetPropertyValue(p); if (p.Id == "NUnit.TestCategory") { var elements = CreatePropertyElement("Category", (string[])propValue); foreach (var element in elements) { propertyElements.Add(element); } } } // NUnit attributes not passed through in traits. var description = ReflectionUtility.GetDescription(result); if (description != null) { var propertyElement = CreatePropertyElement("Description", description).Single(); propertyElements.Add(propertyElement); } return(propertyElements.Any() ? new XElement("properties", propertyElements.Distinct()) : null); }