コード例 #1
0
ファイル: ProjectItemInstance_Tests.cs プロジェクト: 3F/IeXod
        public void InstanceItemToUtilItemIDG()
        {
            string content = @"
                    <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003' >
                        <ItemDefinitionGroup>
                            <i>
                                <m0>;x86;</m0>                                
                                <m1>%(FileName).extension</m1>
                                <m2>;%(FileName).extension;</m2>
                                <m3>v1</m3>
                                <m4>%3bx86%3b</m4> 
                            </i>
                        </ItemDefinitionGroup>
                        <ItemGroup>
                            <i Include='foo.proj'/>
                        </ItemGroup>
                    </Project>
                ";

            ProjectItemInstance item = GetOneItem(content);

            net.r_eg.IeXod.Utilities.TaskItem taskItem = new net.r_eg.IeXod.Utilities.TaskItem(item);

            Assert.Equal(";x86;", taskItem.GetMetadata("m0"));
            Assert.Equal("foo.extension", taskItem.GetMetadata("m1"));
            Assert.Equal(";foo.extension;", taskItem.GetMetadata("m2"));
            Assert.Equal("v1", taskItem.GetMetadata("m3"));
            Assert.Equal(";x86;", taskItem.GetMetadata("m4"));
        }
コード例 #2
0
ファイル: ObjectModelHelpers.cs プロジェクト: 3F/IeXod
        /// <summary>
        /// Parses the crazy string passed into AssertItemsMatch and returns a list of ITaskItems.
        /// </summary>
        /// <param name="expectedItemsString"></param>
        /// <returns></returns>
        /// <owner>RGoel</owner>
        static private List <ITaskItem> ParseExpectedItemsString(string expectedItemsString)
        {
            List <ITaskItem> expectedItems = new List <ITaskItem>();

            // First, parse this massive string that we've been given, and create an ITaskItem[] out of it,
            // so we can more easily compare it against the actual items.
            string[] expectedItemsStringSplit = expectedItemsString.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string singleExpectedItemString in expectedItemsStringSplit)
            {
                string singleExpectedItemStringTrimmed = singleExpectedItemString.Trim();
                if (singleExpectedItemStringTrimmed.Length > 0)
                {
                    int indexOfColon = singleExpectedItemStringTrimmed.IndexOf(": ");
                    if (indexOfColon == -1)
                    {
                        expectedItems.Add(new net.r_eg.IeXod.Utilities.TaskItem(singleExpectedItemStringTrimmed));
                    }
                    else
                    {
                        // We found a colon, which means there's metadata in there.

                        // The item spec is the part before the colon.
                        string itemSpec = singleExpectedItemStringTrimmed.Substring(0, indexOfColon).Trim();

                        // The metadata is the part after the colon.
                        string itemMetadataString = singleExpectedItemStringTrimmed.Substring(indexOfColon + 1);

                        ITaskItem expectedItem = new net.r_eg.IeXod.Utilities.TaskItem(itemSpec);

                        string[] itemMetadataPieces = itemMetadataString.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (string itemMetadataPiece in itemMetadataPieces)
                        {
                            string itemMetadataPieceTrimmed = itemMetadataPiece.Trim();
                            if (itemMetadataPieceTrimmed.Length > 0)
                            {
                                int indexOfEquals = itemMetadataPieceTrimmed.IndexOf('=');
                                Assertion.Assert(String.Format("Could not find <equals> in item metadata definition '{0}'", itemMetadataPieceTrimmed), indexOfEquals != -1);

                                string itemMetadataName  = itemMetadataPieceTrimmed.Substring(0, indexOfEquals).Trim();
                                string itemMetadataValue = itemMetadataPieceTrimmed.Substring(indexOfEquals + 1).Trim();

                                expectedItem.SetMetadata(itemMetadataName, itemMetadataValue);
                            }
                        }

                        expectedItems.Add(expectedItem);
                    }
                }
            }

            return(expectedItems);
        }
コード例 #3
0
ファイル: ObjectModelHelpers.cs プロジェクト: 3F/IeXod
        static private bool IsBuiltInItemMetadataName(string metadataName)
        {
            if (builtInMetadataNames == null)
            {
                builtInMetadataNames = new Hashtable();

                net.r_eg.IeXod.Utilities.TaskItem dummyTaskItem = new net.r_eg.IeXod.Utilities.TaskItem();
                foreach (string builtInMetadataName in dummyTaskItem.MetadataNames)
                {
                    builtInMetadataNames[builtInMetadataName] = String.Empty;
                }
            }

            return(builtInMetadataNames.Contains(metadataName));
        }
コード例 #4
0
ファイル: ProjectItemInstance_Tests.cs プロジェクト: 3F/IeXod
        public void ITaskItem2Operations()
        {
            Project         project         = new Project();
            ProjectInstance projectInstance = project.CreateProjectInstance();

            ProjectItemInstance item = projectInstance.AddItem("EscapedItem", "esca%20ped%3bitem");

            item.SetMetadata("m", "m1");
            item.SetMetadata("m;", "m%3b1");
            ITaskItem2 taskItem = (ITaskItem2)item;

            Assert.Equal("esca%20ped%3bitem", taskItem.EvaluatedIncludeEscaped);
            Assert.Equal("esca ped;item", taskItem.ItemSpec);

            Assert.Equal("m;1", taskItem.GetMetadata("m;"));
            Assert.Equal("m%3b1", taskItem.GetMetadataValueEscaped("m;"));
            Assert.Equal("m1", taskItem.GetMetadataValueEscaped("m"));

            Assert.Equal("esca%20ped%3bitem", taskItem.EvaluatedIncludeEscaped);
            Assert.Equal("esca ped;item", taskItem.ItemSpec);

            ITaskItem2 taskItem2 = new net.r_eg.IeXod.Utilities.TaskItem(taskItem);

            taskItem2.SetMetadataValueLiteral("m;", "m;2");

            Assert.Equal("m%3b2", taskItem2.GetMetadataValueEscaped("m;"));
            Assert.Equal("m;2", taskItem2.GetMetadata("m;"));

            IDictionary <string, string> taskItem2Metadata = (IDictionary <string, string>)taskItem2.CloneCustomMetadata();

            Assert.Equal(3, taskItem2Metadata.Count);

            foreach (KeyValuePair <string, string> pair in taskItem2Metadata)
            {
                if (pair.Key.Equals("m"))
                {
                    Assert.Equal("m1", pair.Value);
                }

                if (pair.Key.Equals("m;"))
                {
                    Assert.Equal("m;2", pair.Value);
                }

                if (pair.Key.Equals("OriginalItemSpec"))
                {
                    Assert.Equal("esca ped;item", pair.Value);
                }
            }

            IDictionary <string, string> taskItem2MetadataEscaped = (IDictionary <string, string>)taskItem2.CloneCustomMetadataEscaped();

            Assert.Equal(3, taskItem2MetadataEscaped.Count);

            foreach (KeyValuePair <string, string> pair in taskItem2MetadataEscaped)
            {
                if (pair.Key.Equals("m"))
                {
                    Assert.Equal("m1", pair.Value);
                }

                if (pair.Key.Equals("m;"))
                {
                    Assert.Equal("m%3b2", pair.Value);
                }

                if (pair.Key.Equals("OriginalItemSpec"))
                {
                    Assert.Equal("esca%20ped%3bitem", pair.Value);
                }
            }
        }