/// <summary> /// Create a test case using the given element name + value /// </summary> /// <param name="elementName">element name to add to PropertyGroup</param> /// <param name="value">value to set</param> /// <returns></returns> private static Project CreateTestProject(string elementName, string value) { // parse empty template var xmlDocument = XDocument.Parse(template); if (!string.IsNullOrWhiteSpace(value)) { var propertyGroup = xmlDocument.Descendants(Project.XmlLegacyNamespace + "PropertyGroup").First(); propertyGroup.Add(new XElement(Project.XmlLegacyNamespace + elementName, value)); } var testProject = new Project { ProjectDocument = xmlDocument }; ProjectPropertiesReader.ReadPropertyGroups(testProject); return(testProject); }
public void GeneratesResultForXamarinAndroid() { var project = new Project { ProjectDocument = new XDocument( new XElement("Project", new XElement(Project.XmlLegacyNamespace + "PropertyGroup", new XElement( XName.Get("ProjectTypeGuids", Project.XmlLegacyNamespace.NamespaceName), "{EFBA0AD7-5A72-4C68-AF49-83D382785DCF}")))) }; ProjectPropertiesReader.ReadPropertyGroups(project); var results = new W001IllegalProjectTypeDiagnostic().Analyze(project); Assert.AreEqual(1, results.Count); }
public void DoesNotGenerateResultForValidType() { var project = new Project { ProjectDocument = new XDocument( new XElement("Project", new XElement(Project.XmlLegacyNamespace + "PropertyGroup", new XElement( XName.Get("ProjectTypeGuids", Project.XmlLegacyNamespace.NamespaceName), "{318C4C53-4319-472D-A480-6540F3D375FD}")))) }; ProjectPropertiesReader.ReadPropertyGroups(project); var results = new W001IllegalProjectTypeDiagnostic().Analyze(project); Assert.IsNotNull(results); Assert.AreEqual(0, results.Count); }