Example #1
0
        public void ModifyItemTwiceInSameScope1()
        {
            Hashtable table1 = new Hashtable(StringComparer.OrdinalIgnoreCase);
            Lookup    lookup = LookupHelpers.CreateLookup(table1);

            // Add an item with m=m1 and n=n1
            BuildItem item1 = new BuildItem("i1", "a2");

            item1.SetMetadata("m", "m1");
            lookup.PopulateWithItem(item1);

            lookup.EnterScope();

            // Make a modification to the item to be m=m2
            Dictionary <string, string> newMetadata = new Dictionary <string, string>();

            newMetadata.Add("m", "m2");
            BuildItemGroup group = new BuildItemGroup();

            group.AddItem(item1);
            lookup.ModifyItems(item1.Name, group, newMetadata);

            // Make an unrelated modification to the item
            newMetadata = new Dictionary <string, string>();
            newMetadata.Add("n", "n1");
            lookup.ModifyItems(item1.Name, group, newMetadata);

            // It's now m=m2
            group = lookup.GetItems("i1");
            Assertion.AssertEquals(1, group.Count);
            Assertion.AssertEquals("m2", group[0].GetMetadata("m"));
        }
        public void ExecuteTaskCurrentDirNotEqualExecutionDir()
        {
            string theCurrentDirectory = Directory.GetCurrentDirectory();

            try
            {
                string                   executionDirectory = "C:\\";
                TaskExecutionMode        howToExecuteTask   = TaskExecutionMode.InferOutputsOnly;
                XmlDocument              doc            = new XmlDocument();
                XmlElement               taskNode       = doc.CreateElement("Foo");
                TaskExecutionStateHelper executionState = new TaskExecutionStateHelper(
                    howToExecuteTask,
                    LookupHelpers.CreateLookup(projectLevelProprtiesForInference, projectLevelItemsForInference),
                    LookupHelpers.CreateLookup(projectLevelPropertiesForExecution, projectLevelItemsForExecution),
                    taskNode,
                    hostObject,
                    projectFileOfTaskNode,
                    parentProjectFullFileName,
                    executionDirectory,
                    nodeProxyId);
                executionState.ParentModule              = taskExecutionModule;
                executionState.LoggingService            = loggingHelper;
                executionState.TargetInferenceSuccessful = true;
                executionState.ExecuteTask();
                Assert.IsTrue(string.Compare(Directory.GetCurrentDirectory(), "C:\\", StringComparison.OrdinalIgnoreCase) == 0, "Expected current directory to be c:\\ which should show up as an empty directory string");
            }
            finally
            {
                Directory.SetCurrentDirectory(theCurrentDirectory);
            }
        }
Example #3
0
        public void ModifyItemInProjectPreviouslyModifiedAndGottenThroughGetItem()
        {
            // Create some project state with an item with m=m1 and n=n1
            Hashtable table1 = new Hashtable(StringComparer.OrdinalIgnoreCase);
            BuildItem item1  = new BuildItem("i1", "a2");

            item1.SetMetadata("m", "m1");
            BuildItemGroup group0 = new BuildItemGroup();

            group0.AddExistingItem(item1);
            table1["i1"] = group0;

            Lookup lookup = LookupHelpers.CreateLookup(table1);

            lookup.EnterScope();

            // Make a modification to the item to be m=m2
            Dictionary <string, string> newMetadata = new Dictionary <string, string>();

            newMetadata.Add("m", "m2");
            BuildItemGroup group = new BuildItemGroup();

            group.AddItem(item1);
            lookup.ModifyItems(item1.Name, group, newMetadata);

            // Get the item (under the covers, it cloned it in order to apply the modification)
            BuildItemGroup group2 = lookup.GetItems(item1.Name);

            Assertion.AssertEquals(1, group2.Count);
            BuildItem item1b = group2[0];

            // Modify to m=m3
            Dictionary <string, string> newMetadata2 = new Dictionary <string, string>();

            newMetadata2.Add("m", "m3");
            BuildItemGroup group3 = new BuildItemGroup();

            group3.AddItem(item1b);
            lookup.ModifyItems(item1b.Name, group3, newMetadata2);

            // Modifications are visible
            BuildItemGroup group4 = lookup.GetItems(item1b.Name);

            Assertion.AssertEquals(1, group4.Count);
            Assertion.AssertEquals("m3", group4[0].GetMetadata("m"));

            // Leave scope
            lookup.LeaveScope();

            // Still visible
            BuildItemGroup group5 = lookup.GetItems(item1b.Name);

            Assertion.AssertEquals(1, group5.Count);
            Assertion.AssertEquals("m3", group5[0].GetMetadata("m"));

            // And the one in the project is changed
            Assertion.AssertEquals("m3", item1.GetMetadata("m"));
        }
Example #4
0
        public void NonexistentProperty()
        {
            BuildPropertyGroup group  = new BuildPropertyGroup();
            Lookup             lookup = LookupHelpers.CreateLookup(group);

            Assertion.AssertEquals(null, lookup.GetProperty("p1"));

            lookup.EnterScope();

            Assertion.AssertEquals(null, lookup.GetProperty("p1"));
        }
Example #5
0
        public void ModifyItem()
        {
            Hashtable table1 = new Hashtable(StringComparer.OrdinalIgnoreCase);
            Lookup    lookup = LookupHelpers.CreateLookup(table1);

            lookup.EnterScope();

            // Add an item with m=m1
            BuildItem item1 = new BuildItem("i1", "a2");

            item1.SetMetadata("m", "m1");
            lookup.AddNewItem(item1);

            lookup.EnterScope();

            // Change the item to be m=m2
            Dictionary <string, string> newMetadata = new Dictionary <string, string>();

            newMetadata.Add("m", "m2");
            BuildItemGroup group = new BuildItemGroup();

            group.AddItem(item1);
            lookup.ModifyItems(item1.Name, group, newMetadata);

            // Now it has m=m2
            group = lookup.GetItems("i1");
            Assertion.AssertEquals(1, group.Count);
            Assertion.AssertEquals("m2", group[0].GetMetadata("m"));

            // But the original item hasn't changed yet
            Assertion.AssertEquals("m1", item1.GetMetadata("m"));

            lookup.LeaveScope();

            // It still has m=m2
            group = lookup.GetItems("i1");
            Assertion.AssertEquals(1, group.Count);
            Assertion.AssertEquals("m2", group[0].GetMetadata("m"));

            // The original item still hasn't changed
            // even though it was added in this scope
            Assertion.AssertEquals("m1", item1.GetMetadata("m"));

            lookup.LeaveScope();

            // It still has m=m2
            group = lookup.GetItems("i1");
            Assertion.AssertEquals(1, group.Count);
            Assertion.AssertEquals("m2", group[0].GetMetadata("m"));

            // But now the original item has changed
            Assertion.AssertEquals("m2", item1.GetMetadata("m"));
        }
Example #6
0
        public void Removes()
        {
            // One item in the project
            BuildItemGroup group1 = new BuildItemGroup();
            BuildItem      item1  = new BuildItem("i1", "a1");

            group1.AddItem(item1);
            Hashtable table1 = new Hashtable(StringComparer.OrdinalIgnoreCase);

            table1.Add("i1", group1);
            Lookup lookup = LookupHelpers.CreateLookup(table1);

            // Start a target
            lookup.EnterScope();

            // Start a task (eg) and add a new item
            lookup.EnterScope();
            BuildItem item2 = new BuildItem("i1", "a2");

            lookup.AddNewItem(item2);

            // Remove one item
            lookup.RemoveItem(item1);

            // We see one item
            Assertion.AssertEquals(1, lookup.GetItems("i1").Count);
            Assertion.AssertEquals("a2", lookup.GetItems("i1")[0].FinalItemSpec);

            // Remove the other item
            lookup.RemoveItem(item2);

            // We see no items
            Assertion.AssertEquals(0, lookup.GetItems("i1").Count);

            // Finish the task
            lookup.LeaveScope();

            // We still see no items
            Assertion.AssertEquals(0, lookup.GetItems("i1").Count);

            // But there's still one item in the project
            Assertion.AssertEquals("a1", group1[0].FinalItemSpec);
            Assertion.AssertEquals(1, group1.Count);

            // Finish the target
            lookup.LeaveScope();

            // We still see no items
            Assertion.AssertEquals(0, lookup.GetItems("i1").Count);

            // And now there are no items in the project either
            Assertion.AssertEquals(0, group1.Count);
        }
Example #7
0
        public void RemoveItemPopulatedInLowerScope()
        {
            Hashtable table1 = new Hashtable(StringComparer.OrdinalIgnoreCase);
            Lookup    lookup = LookupHelpers.CreateLookup(table1);
            BuildItem item1  = new BuildItem("i1", "a2");

            // Start a target
            lookup.EnterScope();

            // There's one item in this batch
            lookup.PopulateWithItem(item1);

            // We see it
            Assertion.AssertEquals(1, lookup.GetItems("i1").Count);

            // Make a clone so we can keep an eye on that item
            Lookup lookup2 = lookup.Clone();

            // We can see the item in the clone
            Assertion.AssertEquals(1, lookup2.GetItems("i1").Count);

            // Start a task (eg)
            lookup.EnterScope();

            // We see the item below
            Assertion.AssertEquals(1, lookup.GetItems("i1").Count);

            // Remove that item
            lookup.RemoveItem(item1);

            // We see no items
            Assertion.AssertEquals(0, lookup.GetItems("i1").Count);

            // The clone is unaffected so far
            Assertion.AssertEquals(1, lookup2.GetItems("i1").Count);

            // Finish the task
            lookup.LeaveScope();

            // We still see no items
            Assertion.AssertEquals(0, lookup.GetItems("i1").Count);

            // But now the clone doesn't either
            Assertion.AssertEquals(0, lookup2.GetItems("i1").Count);

            // Finish the target
            lookup.LeaveScope();

            // We still see no items
            Assertion.AssertEquals(0, lookup.GetItems("i1").Count);
            Assertion.AssertEquals(0, lookup2.GetItems("i1").Count);
        }
Example #8
0
        public void UnmodifiedProperty()
        {
            BuildPropertyGroup group    = new BuildPropertyGroup();
            BuildProperty      property = new BuildProperty("p1", "v1");

            group.SetProperty(property);
            Lookup lookup = LookupHelpers.CreateLookup(group);

            Assertion.AssertEquals(property, lookup.GetProperty("p1"));

            lookup.EnterScope();

            Assertion.AssertEquals(property, lookup.GetProperty("p1"));
        }
Example #9
0
        public void SecondaryItemNotShadowedByPrimaryItem()
        {
            BuildItemGroup group1 = new BuildItemGroup();

            group1.AddNewItem("i1", "a1");
            Hashtable table1 = new Hashtable(StringComparer.OrdinalIgnoreCase);

            table1.Add("i1", group1);
            Lookup lookup = LookupHelpers.CreateLookup(table1);

            lookup.EnterScope();

            // Should return item from the secondary table.
            Assertion.AssertEquals("a1", lookup.GetItems("i1")[0].FinalItemSpec);
        }
Example #10
0
        public void RemoveBeforeAnAddShouldBeInvalid()
        {
            Hashtable table1 = new Hashtable(StringComparer.OrdinalIgnoreCase);
            Lookup    lookup = LookupHelpers.CreateLookup(table1);

            // Start a target
            lookup.EnterScope();

            // Start a task (eg)
            lookup.EnterScope();
            BuildItem item1 = new BuildItem("i1", "a2");

            // Remove an item then add it
            lookup.RemoveItem(item1);
            lookup.AddNewItem(item1);
        }
Example #11
0
        public void ItemizeItemVectorWithSeparatorBucketed()
        {
            Hashtable itemGroupsByType = this.GenerateTestItems();
            Lookup    lookup           = LookupHelpers.CreateLookup(itemGroupsByType);

            lookup.EnterScope();
            lookup.PopulateWithItem(new BuildItem("Compile", "c.cs"));
            lookup.PopulateWithItem(new BuildItem("Compile", "d.cs"));

            Match          disposableMatch;
            BuildItemGroup compileItems = ItemExpander.ItemizeItemVector("@(Compile, ' ')", null, new ReadOnlyLookup(lookup), out disposableMatch);

            // @(Compile, ' ') is a scalar, so we should only have one item in the resulting item group
            Assertion.AssertEquals(1, compileItems.Count);
            Assertion.Assert(compileItems[0].Include == "c.cs d.cs");
        }
Example #12
0
        public void ModifiedProperty()
        {
            BuildPropertyGroup group = new BuildPropertyGroup();

            group.SetProperty(new BuildProperty("p1", "v1"));
            Lookup lookup = LookupHelpers.CreateLookup(group);

            // Enter scope so that property sets are allowed on it
            lookup.EnterScope();

            // Change the property value
            lookup.SetProperty(new BuildProperty("p1", "v2", PropertyType.OutputProperty));

            // Lookup is updated, but not original item group
            Assertion.AssertEquals("v2", lookup.GetProperty("p1").FinalValue);
            Assertion.AssertEquals("v1", group["p1"].FinalValue);

            lookup.EnterScope();

            // Change the value again in the new scope
            lookup.SetProperty(new BuildProperty("p1", "v3", PropertyType.OutputProperty));

            // Lookup is updated, but not the original item group
            Assertion.AssertEquals("v3", lookup.GetProperty("p1").FinalValue);
            Assertion.AssertEquals("v1", group["p1"].FinalValue);

            lookup.EnterScope();

            // Change the value again in the new scope
            lookup.SetProperty(new BuildProperty("p1", "v4", PropertyType.OutputProperty));

            Assertion.AssertEquals("v4", lookup.GetProperty("p1").FinalValue);

            lookup.LeaveScope();

            Assertion.AssertEquals("v4", lookup.GetProperty("p1").FinalValue);

            // Leave to the outer scope
            lookup.LeaveScope();
            lookup.LeaveScope();

            // Now the lookup and original group are updated
            Assertion.AssertEquals("v4", lookup.GetProperty("p1").FinalValue);
            Assertion.AssertEquals("v4", group["p1"].FinalValue);
        }
Example #13
0
        public void RemoveItemFromProjectPreviouslyModifiedAndGottenThroughGetItem()
        {
            // Create some project state with an item with m=m1 and n=n1
            Hashtable table1 = new Hashtable(StringComparer.OrdinalIgnoreCase);
            BuildItem item1  = new BuildItem("i1", "a2");

            item1.SetMetadata("m", "m1");
            BuildItemGroup group0 = new BuildItemGroup();

            group0.AddExistingItem(item1);
            table1["i1"] = group0;

            Lookup lookup = LookupHelpers.CreateLookup(table1);

            lookup.EnterScope();

            // Make a modification to the item to be m=m2
            Dictionary <string, string> newMetadata = new Dictionary <string, string>();

            newMetadata.Add("m", "m2");
            BuildItemGroup group = new BuildItemGroup();

            group.AddItem(item1);
            lookup.ModifyItems(item1.Name, group, newMetadata);

            // Get the item (under the covers, it cloned it in order to apply the modification)
            BuildItemGroup group2 = lookup.GetItems(item1.Name);

            Assertion.AssertEquals(1, group2.Count);
            BuildItem item1b = group2[0];

            // Remove the item
            lookup.RemoveItem(item1b);

            // There's now no items at all
            BuildItemGroup group3 = lookup.GetItems(item1.Name);

            Assertion.AssertEquals(0, group3.Count);

            // Leave scope
            lookup.LeaveScope();

            // And now none left in the project either
            Assertion.AssertEquals(0, ((BuildItemGroup)table1["i1"]).Count);
        }
        public void TaskExecutionStateTestProperties()
        {
            TaskExecutionMode        howToExecuteTask = TaskExecutionMode.ExecuteTaskAndGatherOutputs;
            XmlDocument              doc            = new XmlDocument();
            XmlElement               taskNode       = doc.CreateElement("Foo");
            TaskExecutionStateHelper executionState = new TaskExecutionStateHelper(
                howToExecuteTask,
                LookupHelpers.CreateLookup(projectLevelProprtiesForInference, projectLevelItemsForInference),
                LookupHelpers.CreateLookup(projectLevelPropertiesForExecution, projectLevelItemsForExecution),
                taskNode,
                hostObject,
                projectFileOfTaskNode,
                parentProjectFullFileName,
                executionDirectory,
                nodeProxyId);

            executionState.HandleId = 1;
            Assert.AreEqual(1, executionState.HandleId, "Expected NodeProxyId to be equal to 1");

            executionState.LoggingService = loggingHelper;
            Assert.AreEqual(loggingHelper, executionState.LoggingService, "Expected LoggingService to be equal to the loggingService set in the LoggingService property setter");
        }
Example #15
0
        public void RemoveBeforeModifyShouldBeInvalid()
        {
            Hashtable table1 = new Hashtable(StringComparer.OrdinalIgnoreCase);
            Lookup    lookup = LookupHelpers.CreateLookup(table1);

            // Start a target
            lookup.EnterScope();

            // Start a task (eg)
            lookup.EnterScope();
            BuildItem      item1 = new BuildItem("i1", "a2");
            BuildItemGroup group = new BuildItemGroup();

            group.AddItem(item1);

            // Remove an item then modify it
            lookup.RemoveItem(item1);

            Dictionary <string, string> metadataChanges = new Dictionary <string, string>();

            metadataChanges.Add("x", "y");
            lookup.ModifyItems("i1", group, metadataChanges);
        }
Example #16
0
        public void RemoveItemAddedInLowerScope()
        {
            Hashtable table1 = new Hashtable(StringComparer.OrdinalIgnoreCase);
            Lookup    lookup = LookupHelpers.CreateLookup(table1);

            // Start a target
            lookup.EnterScope();

            // Add an item
            BuildItem item1 = new BuildItem("i1", "a2");

            lookup.AddNewItem(item1);

            // Start a task (eg)
            lookup.EnterScope();

            // We see the item below
            Assertion.AssertEquals(1, lookup.GetItems("i1").Count);

            // Remove that item
            lookup.RemoveItem(item1);

            // We see no items
            Assertion.AssertEquals(0, lookup.GetItems("i1").Count);

            // Finish the task
            lookup.LeaveScope();

            // We still see no items
            Assertion.AssertEquals(0, lookup.GetItems("i1").Count);

            // Finish the target
            lookup.LeaveScope();

            // We still see no items
            Assertion.AssertEquals(0, lookup.GetItems("i1").Count);
        }
Example #17
0
        public void ItemListTests()
        {
            Parser    p = new Parser();
            Hashtable conditionedProperties = null;

            BuildItemGroup myCompileItemGroup = new BuildItemGroup();

            myCompileItemGroup.AddItem(new BuildItem("Compile", "foo.cs"));
            myCompileItemGroup.AddItem(new BuildItem("Compile", "bar.cs"));
            myCompileItemGroup.AddItem(new BuildItem("Compile", "baz.cs"));

            BuildItemGroup myBooleanItemGroup = new BuildItemGroup();

            myBooleanItemGroup.AddItem(new BuildItem("Boolean", "true"));

            Hashtable itemsByType = new Hashtable(StringComparer.OrdinalIgnoreCase);

            itemsByType["Compile"] = myCompileItemGroup;
            itemsByType["Boolean"] = myBooleanItemGroup;

            Expander expander = new Expander(LookupHelpers.CreateLookup(itemsByType).ReadOnlyLookup);
            ConditionEvaluationState state = new ConditionEvaluationState(DummyAttribute, expander, conditionedProperties, string.Empty);

            AssertParseEvaluate(p, "@(Compile) == 'foo.cs;bar.cs;baz.cs'", state, true);
            AssertParseEvaluate(p, "@(Compile,' ') == 'foo.cs bar.cs baz.cs'", state, true);
            AssertParseEvaluate(p, "@(Compile,'') == 'foo.csbar.csbaz.cs'", state, true);
            AssertParseEvaluate(p, "@(Compile->'%(Filename)') == 'foo;bar;baz'", state, true);
            AssertParseEvaluate(p, "@(Compile -> 'temp\\%(Filename).xml', ' ') == 'temp\\foo.xml temp\\bar.xml temp\\baz.xml'", state, true);
            AssertParseEvaluate(p, "@(Compile->'', '') == ''", state, true);
            AssertParseEvaluate(p, "@(Compile->'') == ';;'", state, true);
            AssertParseEvaluate(p, "@(Compile->'%(Nonexistent)', '') == ''", state, true);
            AssertParseEvaluate(p, "@(Compile->'%(Nonexistent)') == ';;'", state, true);
            AssertParseEvaluate(p, "@(Boolean)", state, true);
            AssertParseEvaluate(p, "@(Boolean) == true", state, true);
            AssertParseEvaluate(p, "'@(Empty, ';')' == ''", state, true);
        }
Example #18
0
        public void RemoveItemPreviouslyModifiedAndGottenThroughGetItem()
        {
            Hashtable table1 = new Hashtable(StringComparer.OrdinalIgnoreCase);
            Lookup    lookup = LookupHelpers.CreateLookup(table1);

            // Add an item with m=m1 and n=n1
            BuildItem item1 = new BuildItem("i1", "a2");

            item1.SetMetadata("m", "m1");
            lookup.PopulateWithItem(item1);

            lookup.EnterScope();

            // Make a modification to the item to be m=m2
            Dictionary <string, string> newMetadata = new Dictionary <string, string>();

            newMetadata.Add("m", "m2");
            BuildItemGroup group = new BuildItemGroup();

            group.AddItem(item1);
            lookup.ModifyItems(item1.Name, group, newMetadata);

            // Get the item (under the covers, it cloned it in order to apply the modification)
            BuildItemGroup group2 = lookup.GetItems(item1.Name);

            Assertion.AssertEquals(1, group2.Count);
            BuildItem item1b = group2[0];

            // Remove the item
            lookup.RemoveItem(item1b);

            // There's now no items at all
            BuildItemGroup group3 = lookup.GetItems(item1.Name);

            Assertion.AssertEquals(0, group3.Count);
        }
Example #19
0
        public void InitiallyNoItemsInBucketOfTypesInItemNames()
        {
            // This bucket is for items of type "i"
            string[] itemNames = new string[] { "i" };

            // There are items of type "i" and "j" available in the project, though
            BuildItemGroup group1 = new BuildItemGroup();
            BuildItemGroup group2 = new BuildItemGroup();

            group1.AddNewItem("i", "i1");
            group2.AddNewItem("j", "j1");
            Hashtable items = new Hashtable(StringComparer.OrdinalIgnoreCase);

            items.Add("i", group1);
            items.Add("j", group2);
            Lookup lookup = LookupHelpers.CreateLookup(items);

            ItemBucket bucket = new ItemBucket(itemNames, new Dictionary <string, string>(), lookup, 0);

            // No items of type i
            Assertion.AssertEquals(0, bucket.Lookup.GetItems("i1").Count);
            // Items of type j, however, are visible
            Assertion.AssertEquals(1, bucket.Lookup.GetItems("j").Count);
        }
Example #20
0
        public void ItemizeItemVectorsWithInvalidNames()
        {
            Hashtable itemGroupsByType = this.GenerateTestItems();

            // First, verify that a valid but simply non-existent item list returns an empty BuildItemGroup,
            // not just null.
            BuildItemGroup control = ItemExpander.ItemizeItemVector("@(nonexistent)", null, LookupHelpers.CreateLookup(itemGroupsByType).ReadOnlyLookup);

            Assertion.AssertEquals(0, control.Count);

            foreach (string candidate in invalidItemVectors)
            {
                Assertion.AssertNull(candidate, ItemExpander.ItemizeItemVector(candidate, null, LookupHelpers.CreateLookup(itemGroupsByType).ReadOnlyLookup));
            }
        }
Example #21
0
        public void AddsAreCombinedWithPopulates()
        {
            // One item in the project
            BuildItemGroup group1 = new BuildItemGroup();

            group1.AddNewItem("i1", "a1");
            Hashtable table1 = new Hashtable(StringComparer.OrdinalIgnoreCase);

            table1.Add("i1", group1);
            Lookup lookup = LookupHelpers.CreateLookup(table1);

            // We see the one item
            Assertion.AssertEquals("a1", lookup.GetItems("i1")[0].FinalItemSpec);

            // One item in the project
            Assertion.AssertEquals("a1", group1[0].FinalItemSpec);
            Assertion.AssertEquals(1, group1.Count);

            // Start a target
            lookup.EnterScope();

            // We see the one item
            Assertion.AssertEquals("a1", lookup.GetItems("i1")[0].FinalItemSpec);

            // One item in the project
            Assertion.AssertEquals("a1", group1[0].FinalItemSpec);
            Assertion.AssertEquals(1, group1.Count);

            // Start a task (eg) and add a new item
            lookup.EnterScope();
            lookup.AddNewItem(new BuildItem("i1", "a2"));

            // Now we see two items
            Assertion.AssertEquals("a1", lookup.GetItems("i1")[0].FinalItemSpec);
            Assertion.AssertEquals("a2", lookup.GetItems("i1")[1].FinalItemSpec);

            // But there's still one item in the project
            Assertion.AssertEquals("a1", group1[0].FinalItemSpec);
            Assertion.AssertEquals(1, group1.Count);

            // Finish the task
            lookup.LeaveScope();

            // We still see two items
            Assertion.AssertEquals("a1", lookup.GetItems("i1")[0].FinalItemSpec);
            Assertion.AssertEquals("a2", lookup.GetItems("i1")[1].FinalItemSpec);

            // But there's still one item in the project
            Assertion.AssertEquals("a1", group1[0].FinalItemSpec);
            Assertion.AssertEquals(1, group1.Count);

            // Finish the target
            lookup.LeaveScope();

            // We still see two items
            Assertion.AssertEquals("a1", lookup.GetItems("i1")[0].FinalItemSpec);
            Assertion.AssertEquals("a2", lookup.GetItems("i1")[1].FinalItemSpec);

            // And now the items have gotten put into the global group
            Assertion.AssertEquals("a1", group1[0].FinalItemSpec);
            Assertion.AssertEquals("a2", group1[1].FinalItemSpec);
            Assertion.AssertEquals(2, group1.Count);
        }
Example #22
0
        public void ExpandEmbeddedItemVectorsSeparator()
        {
            Hashtable itemGroupsByType = this.GenerateTestItems();

            XmlNode foo             = new XmlDocument().CreateElement("Foo");
            string  evaluatedString = ItemExpander.ExpandEmbeddedItemVectors("@(Compile, '#')", foo, LookupHelpers.CreateLookup(itemGroupsByType).ReadOnlyLookup);

            Assertion.AssertEquals("a.cs#b.cs", evaluatedString);
        }
Example #23
0
        public void ItemizeItemVectorWithNoItemLists()
        {
            Hashtable itemGroupsByType = this.GenerateTestItems();

            BuildItemGroup compileItems = ItemExpander.ItemizeItemVector("foobar", null, LookupHelpers.CreateLookup(itemGroupsByType).ReadOnlyLookup);

            // If the specified expression does not contain any item lists, then we expect ItemizeItemVector
            // to give us back null, but not throw an exception.
            Assertion.AssertNull(compileItems);
        }
Example #24
0
        public void ModifyItemInOutsideScope()
        {
            Lookup lookup = LookupHelpers.CreateLookup(new Hashtable());

            lookup.AddNewItem(new BuildItem("x", "y"));
        }
Example #25
0
        public void ExpandEmbeddedItemVectorsMultiple()
        {
            Hashtable itemGroupsByType = this.GenerateTestItems();

            XmlNode foo             = new XmlDocument().CreateElement("Foo");
            string  evaluatedString = ItemExpander.ExpandEmbeddedItemVectors("...@(Compile)...@(Resource)...", foo, LookupHelpers.CreateLookup(itemGroupsByType).ReadOnlyLookup);

            Assertion.AssertEquals("...a.cs;b.cs...c.resx...", evaluatedString);
        }
Example #26
0
        public void ModifyItemTwiceInSameScope2()
        {
            Hashtable table1 = new Hashtable(StringComparer.OrdinalIgnoreCase);
            Lookup    lookup = LookupHelpers.CreateLookup(table1);

            // Add an item with m=m1 and n=n1 and o=o1
            BuildItem item1 = new BuildItem("i1", "a2");

            item1.SetMetadata("m", "m1");
            item1.SetMetadata("n", "n1");
            item1.SetMetadata("o", "o1");
            lookup.PopulateWithItem(item1);

            lookup.EnterScope();

            // It's still m=m1, n=n1, o=o1
            BuildItemGroup group = lookup.GetItems("i1");

            Assertion.AssertEquals(1, group.Count);
            Assertion.AssertEquals("m1", group[0].GetMetadata("m"));
            Assertion.AssertEquals("n1", group[0].GetMetadata("n"));
            Assertion.AssertEquals("o1", group[0].GetMetadata("o"));

            // Make a modification to the item to be m=m2 and n=n2
            Dictionary <string, string> newMetadata = new Dictionary <string, string>();

            newMetadata.Add("m", "m2");
            newMetadata.Add("n", "n2");
            group = new BuildItemGroup();
            group.AddItem(item1);
            lookup.ModifyItems("i1", group, newMetadata);

            // It's now m=m2, n=n2, o=o1
            BuildItemGroup foundGroup = lookup.GetItems("i1");

            Assertion.AssertEquals(1, foundGroup.Count);
            Assertion.AssertEquals("m2", foundGroup[0].GetMetadata("m"));
            Assertion.AssertEquals("n2", foundGroup[0].GetMetadata("n"));
            Assertion.AssertEquals("o1", foundGroup[0].GetMetadata("o"));

            // Make a modification to the item to be n=n3
            newMetadata = new Dictionary <string, string>();
            newMetadata.Add("n", "n3");
            lookup.ModifyItems("i1", group, newMetadata);

            // It's now m=m2, n=n3, o=o1
            foundGroup = lookup.GetItems("i1");
            Assertion.AssertEquals(1, foundGroup.Count);
            Assertion.AssertEquals("m2", foundGroup[0].GetMetadata("m"));
            Assertion.AssertEquals("n3", foundGroup[0].GetMetadata("n"));
            Assertion.AssertEquals("o1", foundGroup[0].GetMetadata("o"));

            // But the original item hasn't changed yet
            Assertion.AssertEquals("m1", item1.GetMetadata("m"));
            Assertion.AssertEquals("n1", item1.GetMetadata("n"));
            Assertion.AssertEquals("o1", item1.GetMetadata("o"));

            lookup.LeaveScope();

            // It's still m=m2, n=n3, o=o1
            foundGroup = lookup.GetItems("i1");
            Assertion.AssertEquals(1, foundGroup.Count);
            Assertion.AssertEquals("m2", foundGroup[0].GetMetadata("m"));
            Assertion.AssertEquals("n3", foundGroup[0].GetMetadata("n"));
            Assertion.AssertEquals("o1", foundGroup[0].GetMetadata("o"));

            // And the original item has changed
            Assertion.AssertEquals("m2", item1.GetMetadata("m"));
            Assertion.AssertEquals("n3", item1.GetMetadata("n"));
            Assertion.AssertEquals("o1", item1.GetMetadata("o"));
        }
Example #27
0
        public void ItemizeItemVectorsWithLeadingAndTrailingSpaces()
        {
            Hashtable itemGroupsByType = this.GenerateTestItems();

            // Spaces around are fine, but it's ignored for the item name
            BuildItemGroup items = ItemExpander.ItemizeItemVector("@(  Compile    )", null, LookupHelpers.CreateLookup(itemGroupsByType).ReadOnlyLookup);

            Assertion.AssertEquals("Resulting item group should have 2 items", 2, items.Count);
        }
Example #28
0
        public void ItemizeItemVectorWithSeparatorWithZeroItems1()
        {
            Hashtable itemGroupsByType = this.GenerateTestItems();

            Match          disposableMatch;
            BuildItemGroup zeroItems = ItemExpander.ItemizeItemVector("@(ItemThatDoesNotExist, ' ')", null, LookupHelpers.CreateLookup(itemGroupsByType).ReadOnlyLookup, out disposableMatch);

            Assertion.AssertEquals(0, zeroItems.Count);
        }
Example #29
0
        public void ItemizeItemVectorWithSeparator()
        {
            Hashtable itemGroupsByType = this.GenerateTestItems();

            Match          disposableMatch;
            BuildItemGroup compileItems = ItemExpander.ItemizeItemVector("@(Compile, ' ')", null, LookupHelpers.CreateLookup(itemGroupsByType).ReadOnlyLookup, out disposableMatch);

            // @(Compile, ' ') is a scalar, so we should only have one item in the resulting item group
            Assertion.AssertEquals(1, compileItems.Count);
            Assertion.Assert(compileItems[0].Include == "a.cs b.cs");
        }
Example #30
0
        public void ItemizeItemVectorsWithValidNames()
        {
            Hashtable itemGroupsByType = this.GenerateTestItems();

            foreach (string candidate in validItemVectors)
            {
                Assertion.AssertNotNull(candidate, ItemExpander.ItemizeItemVector(candidate, null, LookupHelpers.CreateLookup(itemGroupsByType).ReadOnlyLookup));
            }
            foreach (string candidate in validItemVectorsWithTransforms)
            {
                Assertion.AssertNotNull(candidate, ItemExpander.ItemizeItemVector(candidate, null, LookupHelpers.CreateLookup(itemGroupsByType).ReadOnlyLookup));
            }
        }