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")); }
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); } } }