public void ExpectAnyGetModify()
        {
            XmlElement             xml   = XmlTestUtilities.CreateBasicElement("i");
            BuildItemGroupChildXml child = new BuildItemGroupChildXml(xml, ChildType.Any);

            Assertion.AssertEquals(ChildType.BuildItemModify, child.ChildType);
        }
示例#2
0
        public void PropertyInMetadataValue()
        {
            XmlElement group = XmlTestUtilities.CreateBasicElement("ItemDefinitionGroup");
            XmlElement item  = XmlTestUtilities.AddChildElement(group, "CCompile");
            XmlElement meta  = XmlTestUtilities.AddChildElementWithInnerText(item, "Defines", "$(p1)");

            ItemDefinitionLibrary library = new ItemDefinitionLibrary(new Project());

            library.Add(group);
            BuildPropertyGroup pg1 = new BuildPropertyGroup();

            pg1.SetProperty("p1", "v1");
            library.Evaluate(pg1);

            Assertion.AssertEquals("v1", library.GetDefaultMetadataValue("ccompile", "defines"));

            // Change the original property group -- should not affect the metadata value which was
            // already evaluated
            pg1.SetProperty("p1", "v1b");

            Assertion.AssertEquals("v1", library.GetDefaultMetadataValue("ccompile", "defines"));

            // Reevaluate with another property value
            BuildPropertyGroup pg2 = new BuildPropertyGroup();

            pg2.SetProperty("p1", "v2");
            library.Evaluate(pg2);

            Assertion.AssertEquals("v2", library.GetDefaultMetadataValue("ccompile", "defines"));
        }
        public void InvalidAttributeOnMetadatum()
        {
            XmlElement group = GetBasicItemDefinitionGroupWithOneDefinitionAndOneMetadatum();

            XmlTestUtilities.AddAttribute(group.ChildNodes[0].ChildNodes[0], "XXXX", "YYY");
            ItemDefinitionLibrary definitions = NewAndEvaluateItemDefinitionLibraryXml(group);
        }
        internal static XmlElement GetBasicItemDefinitionGroupWithOneDefinitionAndOneMetadatum()
        {
            XmlElement group = XmlTestUtilities.CreateBasicElement("ItemDefinitionGroup");
            XmlElement item  = XmlTestUtilities.AddChildElement(group, "CCompile");

            XmlTestUtilities.AddChildElementWithInnerText(item, "Defines", "DEBUG");
            return(group);
        }
示例#5
0
        public void GetMetadataBeforeEvaluate()
        {
            XmlElement group = XmlTestUtilities.CreateBasicElement("ItemDefinitionGroup");

            ItemDefinitionLibrary library = new ItemDefinitionLibrary(new Project());

            library.Add(group);
            library.GetDefaultMetadataValue("ccompile", "defines");
        }
        public void FalseConditionOnMetadatum()
        {
            XmlElement group = GetBasicItemDefinitionGroupWithOneDefinitionAndOneMetadatum();

            XmlTestUtilities.AddAttribute(group.ChildNodes[0].ChildNodes[0], "Condition", "'v2'=='$(p1)'");
            ItemDefinitionLibrary definitions = NewAndEvaluateItemDefinitionLibraryXml(group);

            // No exception
            Assertion.AssertEquals(0, definitions.GetDefaultedMetadataCount("arbitrary"));
        }
        public void InvalidlyNamedMetadata()
        {
            XmlElement xml    = XmlTestUtilities.CreateBasicElementWithOneAttribute("i", "Include", "i1");
            XmlElement child1 = xml.OwnerDocument.CreateElement("m", XMakeAttributes.defaultXmlNamespace);
            XmlElement child2 = xml.OwnerDocument.CreateElement("Filename", XMakeAttributes.defaultXmlNamespace);

            xml.AppendChild(child1);
            xml.AppendChild(child2);
            BuildItemGroupChildXml child = new BuildItemGroupChildXml(xml, ChildType.BuildItemAdd);
        }
        public void DuplicateMetadataLastOneWins()
        {
            XmlElement group = GetBasicItemDefinitionGroupWithOneDefinitionAndOneMetadatum();
            XmlElement meta2 = XmlTestUtilities.AddChildElement(group.ChildNodes[0], "Defines");

            meta2.InnerText = "RETAIL";
            ItemDefinitionLibrary definitions = NewAndEvaluateItemDefinitionLibraryXml(group);

            Assertion.AssertEquals(1, definitions.GetDefaultedMetadataCount("CCompile"));
            Assertion.AssertEquals("RETAIL", definitions.GetDefaultMetadataValue("CCompile", "Defines"));
        }
        public void TrueConditionOnEverything()
        {
            XmlElement group = GetBasicItemDefinitionGroupWithOneDefinitionAndOneMetadatum();

            XmlTestUtilities.AddAttribute(group.ChildNodes[0], "Condition", "'v1'=='$(p1)'");
            XmlTestUtilities.AddAttribute(group.ChildNodes[0].ChildNodes[0], "Condition", "'v1'=='$(p1)'");
            XmlTestUtilities.AddAttribute(group.ChildNodes[0].ChildNodes[0], "Condition", "'v1'=='$(p1)'");
            ItemDefinitionLibrary definitions = NewAndEvaluateItemDefinitionLibraryXml(group);

            Assertion.AssertEquals(1, definitions.GetDefaultedMetadataCount("CCompile"));
            Assertion.AssertEquals("DEBUG", definitions.GetDefaultMetadataValue("CCompile", "Defines"));
        }
示例#10
0
        public void Basic()
        {
            XmlElement group = XmlTestUtilities.CreateBasicElement("ItemDefinitionGroup");
            XmlElement item  = XmlTestUtilities.AddChildElement(group, "CCompile");
            XmlElement meta  = XmlTestUtilities.AddChildElementWithInnerText(item, "Defines", "DEBUG");

            ItemDefinitionLibrary library = new ItemDefinitionLibrary(new Project());

            library.Add(group);
            library.Evaluate(null);

            Assertion.AssertEquals("DEBUG", library.GetDefaultMetadataValue("ccompile", "defines"));
        }
示例#11
0
        public void SameGroupTwoChildrenSameItemTypeDifferentMetadata()
        {
            XmlElement group = XmlTestUtilities.CreateBasicElement("ItemDefinitionGroup");
            XmlElement item1 = XmlTestUtilities.AddChildElement(group, "CCompile");
            XmlElement meta1 = XmlTestUtilities.AddChildElementWithInnerText(item1, "Defines", "DEBUG");
            XmlElement item2 = XmlTestUtilities.AddChildElement(group, "CCompile");
            XmlElement meta2 = XmlTestUtilities.AddChildElementWithInnerText(item1, "WarningLevel", "W4");

            ItemDefinitionLibrary library = new ItemDefinitionLibrary(new Project());

            library.Add(group);
            library.Evaluate(null);

            Assertion.AssertEquals("DEBUG", library.GetDefaultMetadataValue("ccompile", "defines"));
            Assertion.AssertEquals("W4", library.GetDefaultMetadataValue("ccompile", "warninglevel"));
        }
示例#12
0
        internal static BuildItem GetXmlBackedItemWithDefinitionLibrary()
        {
            string      content = @"<i  xmlns='http://schemas.microsoft.com/developer/msbuild/2003' Include='i1'/>";
            XmlDocument doc     = new XmlDocument();

            doc.LoadXml(content);

            XmlElement groupElement = XmlTestUtilities.CreateBasicElement("ItemDefinitionGroup");
            XmlElement itemElement  = XmlTestUtilities.AddChildElement(groupElement, "i");
            XmlElement metaElement  = XmlTestUtilities.AddChildElementWithInnerText(itemElement, "m", "m1");
            XmlElement metaElement2 = XmlTestUtilities.AddChildElementWithInnerText(itemElement, "o", "o1");

            ItemDefinitionLibrary library = new ItemDefinitionLibrary(new Project());

            library.Add(groupElement);
            library.Evaluate(null);

            BuildItem item = new BuildItem((XmlElement)doc.FirstChild, false, library);

            item.SetMetadata("n", "n1");
            return(item);
        }
 public void InvalidExcludeWithoutInclude()
 {
     XmlElement             xml   = XmlTestUtilities.CreateBasicElementWithOneAttribute("i", "Exclude", "i1");
     BuildItemGroupChildXml child = new BuildItemGroupChildXml(xml, ChildType.BuildItemAdd);
 }
 public void ExpectModifyGetRemove()
 {
     XmlElement             xml   = XmlTestUtilities.CreateBasicElementWithOneAttribute("i", "Remove", "i1");;
     BuildItemGroupChildXml child = new BuildItemGroupChildXml(xml, ChildType.BuildItemModify);
 }
 public void ExpectRemoveGetAdd()
 {
     XmlElement             xml   = XmlTestUtilities.CreateBasicElementWithOneAttribute("i", "Include", "i1");;
     BuildItemGroupChildXml child = new BuildItemGroupChildXml(xml, ChildType.BuildItemRemove);
 }
 private static XmlElement CreateBasicRemoveElement()
 {
     return(XmlTestUtilities.CreateBasicElementWithOneAttribute("i", "Remove", "i1"));
 }