Пример #1
0
        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 InvalidAttributeOnMetadatum()
        {
            XmlElement group = GetBasicItemDefinitionGroupWithOneDefinitionAndOneMetadatum();

            XmlTestUtilities.AddAttribute(group.ChildNodes[0].ChildNodes[0], "XXXX", "YYY");
            ItemDefinitionLibrary definitions = NewAndEvaluateItemDefinitionLibraryXml(group);
        }
Пример #3
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"));
        }
Пример #4
0
        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");
        }
Пример #6
0
        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"));
        }
Пример #7
0
        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);
        }
Пример #8
0
        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"));
        }
Пример #9
0
        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);
        }
Пример #13
0
 public void InvalidExcludeWithoutInclude()
 {
     XmlElement             xml   = XmlTestUtilities.CreateBasicElementWithOneAttribute("i", "Exclude", "i1");
     BuildItemGroupChildXml child = new BuildItemGroupChildXml(xml, ChildType.BuildItemAdd);
 }
Пример #14
0
 public void ExpectModifyGetRemove()
 {
     XmlElement             xml   = XmlTestUtilities.CreateBasicElementWithOneAttribute("i", "Remove", "i1");;
     BuildItemGroupChildXml child = new BuildItemGroupChildXml(xml, ChildType.BuildItemModify);
 }
Пример #15
0
 public void ExpectRemoveGetAdd()
 {
     XmlElement             xml   = XmlTestUtilities.CreateBasicElementWithOneAttribute("i", "Include", "i1");;
     BuildItemGroupChildXml child = new BuildItemGroupChildXml(xml, ChildType.BuildItemRemove);
 }
Пример #16
0
 private static XmlElement CreateBasicRemoveElement()
 {
     return(XmlTestUtilities.CreateBasicElementWithOneAttribute("i", "Remove", "i1"));
 }