In class/Microsoft.Build.Engine/Test/various:
[mono.git] / mcs / class / Microsoft.Build.Engine / Test / various / Items.cs
1 //
2 // Items.cs
3 //
4 // Author:
5 //   Marek Sieradzki (marek.sieradzki@gmail.com)
6 //   Ankit Jain (jankit@novell.com)
7 //
8 // (C) 2006 Marek Sieradzki
9 // Copyright 2009 Novell, Inc (http://www.novell.com)
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 //
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 //
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 using System;
31 using System.Text;
32 using System.Xml;
33 using Microsoft.Build.BuildEngine;
34 using NUnit.Framework;
35
36 namespace MonoTests.Microsoft.Build.BuildEngine.Various {
37         [TestFixture]
38         public class Items {
39                 private string GetItems (Project proj, string name)
40                 {
41                         BuildItemGroup big = proj.GetEvaluatedItemsByName (name);
42                         string str = String.Empty;
43                         if (big == null)
44                                 return str;
45
46                         foreach (BuildItem bi in big) {
47                                 if (str == String.Empty)
48                                         str = bi.FinalItemSpec;
49                                 else 
50                                         str += ";" + bi.FinalItemSpec;
51                         }
52                         
53                         return str;
54                 }
55
56                 private void CheckItems (Project proj, string name, string prefix, params string [] values)
57                 {
58                         BuildItemGroup big = proj.GetEvaluatedItemsByName (name);
59                         if (big == null) {
60                                 Assert.Fail ("{0}: Item corresponding '{1}' not found.", prefix, name);
61                                 return;
62                         }
63
64                         if (values.Length != big.Count) {
65                                 Console.Write ("Expected> ");
66                                 foreach (string s in values)
67                                         Console.Write ("{0}|", s);
68                                 Console.WriteLine ();
69                                 Console.Write ("Actual> ");
70                                 foreach (BuildItem item in big)
71                                         Console.Write ("{0}|", item.FinalItemSpec);
72                                 Console.WriteLine ();
73                                 Assert.AreEqual (values.Length, big.Count, String.Format ("{0}: Number of items", prefix));
74                         }
75                         for (int i = 0; i < values.Length; i ++)
76                                 Assert.AreEqual (values [i], big [i].FinalItemSpec,
77                                         String.Format ("{0}: Item named {1}, numbered {2}", prefix, name, i));
78                 }
79
80                 [Test]
81                 public void TestItems1 ()
82                 {
83                         Engine engine = new Engine (Consts.BinPath);
84                         Project proj = engine.CreateNewProject ();
85
86                         string documentString = @"
87                                 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
88                                         <ItemGroup>
89                                                 <Item0 Include='A' />
90                                                 <Item1 Include='A;B;C' />
91                                                 <Item2 Include='@(Item1);A;D' />
92                                                 <Item3 Include='@(Item2)' Exclude='A' />
93                                                 <Item4 Include='@(Item1);Q' Exclude='@(Item2)' />
94                                                 <Item5 Include='@(Item1)' Exclude='@(Item2)' />
95                                                 <Item6 Include='@(Item2)' Exclude='@(Item1)' />
96                                                 <Item7 Include='@(item_that_doesnt_exist)' />
97                                         </ItemGroup>
98                                 </Project>
99                         ";
100
101                         proj.LoadXml (documentString);
102                         CheckItems (proj, "Item0", "A1", "A");
103                         CheckItems (proj, "Item1", "A2", "A", "B", "C");
104                         CheckItems (proj, "Item2", "A3", "A", "B", "C", "A", "D");
105                         CheckItems (proj, "Item3", "A4", "B", "C", "D");
106                         CheckItems (proj, "Item4", "A5", "Q");
107                         CheckItems (proj, "Item5", "A6");
108                         CheckItems (proj, "Item6", "A7", "D");
109                         CheckItems (proj, "Item7", "A8");
110                 }
111
112                 [Test]
113                 public void TestItems2 ()
114                 {
115                         Engine engine = new Engine (Consts.BinPath);
116                         Project proj = engine.CreateNewProject ();
117
118                         string documentString = @"
119                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
120                                         <ItemGroup>
121                                                 <Item1 Include='A;B;C' />
122                                                 <Item2 Include=""@(Item1,'-')"" />
123                                                 <Item3 Include=""@(Item1,'xx')"" />
124                                         </ItemGroup>
125                                 </Project>
126                         ";
127
128                         proj.LoadXml (documentString);
129
130                         CheckItems (proj, "Item2", "A1", "A-B-C");
131                         CheckItems (proj, "Item3", "A2", "AxxBxxC");
132                 }
133
134                 [Test]
135                 public void TestItems3 ()
136                 {
137                         Engine engine = new Engine (Consts.BinPath);
138                         Project proj = engine.CreateNewProject ();
139
140                         string documentString = @"
141                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
142                                         <ItemGroup>
143                                                 <Item1 Include='A;B;C' />
144                                                 <Item2 Include=""@(Item1, '-')"" />
145                                         </ItemGroup>
146                                 </Project>
147                         ";
148
149                         proj.LoadXml (documentString);
150
151                         CheckItems (proj, "Item2", "A1", "A-B-C");
152                 }
153         
154
155                 [Test]
156                 public void TestItems4 ()
157                 {
158                         Engine engine = new Engine (Consts.BinPath);
159                         Project proj = engine.CreateNewProject ();
160
161                         string documentString = @"
162                                 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
163                                         <PropertyGroup>
164                                                 <Prop1>@(Item0)</Prop1>
165                                         </PropertyGroup>
166                                         <ItemGroup>
167                                                 <Item0 Include=""Foo""/>
168                                                 <Item1 Include='A;B;C' />
169                                                 <Item2 Include=""A\B.txt;A\C.txt;B\B.zip;B\C.zip"" />
170                                                 <ItemT0 Include=""@(Item1)"" />
171                                                 <ItemT1 Include=""@(Item1->'%(Identity)')"" />
172                                                 <ItemT2 Include=""@(Item1->'%(Identity)%(Identity)')"" />
173                                                 <ItemT3 Include=""@(Item1->'(-%(Identity)-)')"" />
174                                                 <ItemT4 Include=""@(Item2->'%(Extension)')"" />
175                                                 <ItemT5 Include=""@(Item2->'%(Filename)/%(Extension)')"" />
176                                                 <ItemT6 Include=""@(Item2->'%(Extension)/$(Prop1)')"" />
177                                         </ItemGroup>
178                                 </Project>
179                         ";
180
181                         proj.LoadXml (documentString);
182
183                         //Assert.IsTrue (proj.Build (), "Build failed");
184
185                         Assert.AreEqual ("@(Item0)", proj.EvaluatedProperties["Prop1"].FinalValue, "A0");
186                         //Assert.AreEqual ("@(Item2->'%(Extension)/$(Prop1)')", proj.EvaluatedItems [7].FinalItemSpec, "B0");
187
188                         CheckItems (proj, "ItemT0", "A1", "A", "B", "C");
189                         CheckItems (proj, "ItemT1", "A1", "A", "B", "C");
190                         CheckItems (proj, "ItemT2", "A2", "AA", "BB", "CC");
191                         CheckItems (proj, "ItemT3", "A3", "(-A-)", "(-B-)", "(-C-)");
192                         CheckItems (proj, "ItemT4", "A4", ".txt", ".txt", ".zip", ".zip");
193                         CheckItems (proj, "ItemT5", "A5", "B/.txt", "C/.txt", "B/.zip", "C/.zip");
194                         CheckItems (proj, "ItemT6", "A6", ".txt/@(Item0)", ".txt/@(Item0)", ".zip/@(Item0)", ".zip/@(Item0)");
195                 }
196
197                 [Test]
198                 public void TestItems5 ()
199                 {
200                         Engine engine = new Engine (Consts.BinPath);
201                         Project proj = engine.CreateNewProject ();
202
203                         string documentString = @"
204                                 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
205                                         <ItemGroup>
206                                                 <Item Include=""A\B.txt;A\C.txt;B\B.zip;B\C.zip"" />
207                                                 <ItemT Include=""@(Item->'%(RelativeDir)X/%(Filename)')"" />
208                                         </ItemGroup>
209                                 </Project>
210                         ";
211
212                         proj.LoadXml (documentString);
213
214                         CheckItems (proj, "ItemT", "A1", @"A\X/B", @"A\X/C", @"B\X/B", @"B\X/C");
215                 }
216
217                 [Test]
218                 public void TestItems6 ()
219                 {
220                         Engine engine = new Engine (Consts.BinPath);
221                         Project proj = engine.CreateNewProject ();
222
223                         string documentString = @"
224                                 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
225                                         <PropertyGroup>
226                                                 <A>A</A>
227                                         </PropertyGroup>
228
229                                         <ItemGroup>
230                                                 <Item1 Include='A;B;C' />
231                                                 <Item2 Include='%(A.B)' />
232                                                 <Item3 Include='$(Z)' />
233                                                 <Item4 Include=""@(Item1, '$(A)')"" />
234                                                 <Item5 Include=""@(Item1, '%(A)')"" />
235                                                 <Item6 Include=""@(Item1, '@(A)')"" />
236                                                 <Item7 Include=""@(Item1-> '%(Filename)')"" />
237                                         </ItemGroup>
238                                 </Project>
239                         ";
240
241                         proj.LoadXml (documentString);
242
243                         CheckItems (proj, "Item2", "A1", "%(A.B)");
244                         CheckItems (proj, "Item3", "A2");
245                         CheckItems (proj, "Item4", "A3", "AABAC");
246                         CheckItems (proj, "Item5", "A4", "A%(A)B%(A)C");
247                         CheckItems (proj, "Item6", "A6", "A@(A)B@(A)C");
248                         CheckItems (proj, "Item7", "A6", "A", "B", "C");
249                 }
250
251                 // The expression "@(Item1, '@(A,'')')" cannot be used in this context. 
252                 // Item lists cannot be concatenated with other strings where an item list is expected. 
253                 // Use a semicolon to separate multiple item lists.
254                 [Test]
255                 [ExpectedException (typeof (InvalidProjectFileException))]
256                 [Category ("NotWorking")]
257                 public void TestItems7 ()
258                 {
259                         Engine engine = new Engine (Consts.BinPath);
260                         Project proj = engine.CreateNewProject ();
261
262                         string documentString = @"
263                                 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
264                                         <ItemGroup>
265                                                 <Item1 Include='A;B;C' />
266                                                 <Item7 Include=""@(Item1, '@(A,'')')"" />
267                                         </ItemGroup>
268                                 </Project>
269                         ";
270
271                         proj.LoadXml (documentString);
272                 }
273
274                 // The expression "@(Item1, '@(A->'')')" cannot be used in this context.
275                 // Item lists cannot be concatenated with other strings where an item list is expected.
276                 // Use a semicolon to separate multiple item lists.
277                 [Test]
278                 [ExpectedException (typeof (InvalidProjectFileException))]
279                 [Category ("NotWorking")]
280                 public void TestItems8 ()
281                 {
282                         Engine engine = new Engine (Consts.BinPath);
283                         Project proj = engine.CreateNewProject ();
284
285                         string documentString = @"
286                                 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
287                                         <ItemGroup>
288                                                 <Item1 Include='A;B;C' />
289                                                 <Item8 Include=""@(Item1, '@(A->'')')"" />
290                                         </ItemGroup>
291                                 </Project>
292                         ";
293
294                         proj.LoadXml (documentString);
295                 }
296
297                 // The expression "@(Item1, '@(A->'','')')" cannot be used in this context.
298                 // Item lists cannot be concatenated with other strings where an item list is expected.
299                 // Use a semicolon to separate multiple item lists.
300                 [Test]
301                 [ExpectedException (typeof (InvalidProjectFileException))]
302                 [Category ("NotWorking")]
303                 public void TestItems9 ()
304                 {
305                         Engine engine = new Engine (Consts.BinPath);
306                         Project proj = engine.CreateNewProject ();
307
308                         string documentString = @"
309                                 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
310                                         <ItemGroup>
311                                                 <Item1 Include='A;B;C' />
312                                                 <Item9 Include=""@(Item1, '@(A->'','')')"" />
313                                         </ItemGroup>
314                                 </Project>
315                         ";
316
317                         proj.LoadXml (documentString);
318                 }
319
320                 [Test]
321                 // test item metadata
322                 public void TestItems10 ()
323                 {
324                         string project_xml = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
325         <PropertyGroup>
326                 <Prop1>@(Item0)</Prop1>
327                 <Prop2>@(Ref1)</Prop2>
328         </PropertyGroup>
329         <ItemGroup>
330                 <Item0 Include=""Foo""/>
331                 <Ref1 Include=""File1"" />
332                 <IWithM Include=""A"">
333                         <Md>@(Item0)</Md>
334                         <Md2>$(Prop2)</Md2>
335                 </IWithM>
336         </ItemGroup>
337
338         <Target Name=""1"">
339                 <Message Text=""IWithM.md: %(IWithM.Md)""/>
340                 <Message Text=""IWithM.md2: %(IWithM.Md2)""/>
341
342                 <CreateItem Include=""Bar;Xyz"">
343                         <Output TaskParameter=""Include"" ItemName=""Item0""/>
344                 </CreateItem>
345                 
346                 <Message Text=""IWithM.md: %(IWithM.Md)""/>
347                 <Message Text=""IWithM.md2: %(IWithM.Md2)""/>
348         </Target>
349 </Project>
350 ";
351
352                         Engine engine = new Engine (Consts.BinPath);
353                         Project proj = engine.CreateNewProject ();
354                         MonoTests.Microsoft.Build.Tasks.TestMessageLogger logger =
355                                 new MonoTests.Microsoft.Build.Tasks.TestMessageLogger ();
356                         proj.LoadXml (project_xml);
357                         engine.RegisterLogger (logger);
358
359                         if (!proj.Build ("1")) {
360                                 logger.DumpMessages ();
361                                 Assert.Fail ("Build failed");
362                         }
363
364                         logger.CheckLoggedMessageHead ("IWithM.md: Foo", "A1");
365                         logger.CheckLoggedMessageHead ("IWithM.md2: File1", "A2");
366
367                         logger.CheckLoggedMessageHead ("IWithM.md: Foo", "A3");
368                         logger.CheckLoggedMessageHead ("IWithM.md2: File1", "A4");
369                         Assert.AreEqual (0, logger.NormalMessageCount, "unexpected messages found");
370                 }
371
372                 [Test]
373                 // Test Item/prop references in conditions
374                 public void TestItems11 () {
375                         string project_xml = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
376         <PropertyGroup>
377                 <Prop1>@(Item0)</Prop1>
378         </PropertyGroup>
379         <ItemGroup>
380                 <Item0 Include=""Foo""/>
381                 <Item1 Include=""@(Item0)""/>
382
383                 <CondItem Condition=""'@(Item1)' == '@(Item0)'"" Include=""Equal to item0""/>
384                 <CondItem Condition=""'@(Item1)' == 'Foo'"" Include=""Equal to item0's value""/>
385
386                 <CondItem1 Condition=""'$(Prop1)' == '@(Item0)'"" Include=""Equal to item0""/>
387                 <CondItem1 Condition=""'$(Prop1)' == 'Foo'"" Include=""Equal to item0's value""/>
388         </ItemGroup>
389
390         <Target Name=""1"">
391                 <Message Text = ""CondItem: %(CondItem.Identity)""/>
392                 <Message Text = ""CondItem1: %(CondItem1.Identity)""/>
393         </Target>
394 </Project>
395 ";
396
397                         Engine engine = new Engine (Consts.BinPath);
398                         Project proj = engine.CreateNewProject ();
399                         MonoTests.Microsoft.Build.Tasks.TestMessageLogger logger =
400                                 new MonoTests.Microsoft.Build.Tasks.TestMessageLogger ();
401                         proj.LoadXml (project_xml);
402                         engine.RegisterLogger (logger);
403
404                         if (!proj.Build ("1")) {
405                                 logger.DumpMessages ();
406                                 Assert.Fail ("Build failed");
407                         }
408
409                         logger.CheckLoggedMessageHead ("CondItem: Equal to item0", "A1");
410                         logger.CheckLoggedMessageHead ("CondItem: Equal to item0's value", "A2");
411                         logger.CheckLoggedMessageHead ("CondItem1: Equal to item0", "A3");
412                         logger.CheckLoggedMessageHead ("CondItem1: Equal to item0's value", "A4");
413                         Assert.AreEqual (0, logger.NormalMessageCount, "unexpected messages found");
414                 }
415
416                 [Test]
417                 // test properties and item refs, with dynamic properties/items
418                 public void TestItems12 ()
419                 {
420                         string project_xml = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
421         <PropertyGroup>
422                 <Prop2>@(Ref1)</Prop2>
423         </PropertyGroup>
424         <ItemGroup>
425                 <Ref1 Include=""File1"" />
426                 <Files Include=""@(Ref1)""/>
427         </ItemGroup>
428
429         <Target Name=""1"">
430                 <Message Text=""Prop2: $(Prop2)""/>
431                 
432                 <Message Text=""Files: @(Files)""/>
433                 <CreateItem Include=""foobar"">
434                         <Output TaskParameter=""Include"" ItemName=""Ref1""/>
435                 </CreateItem>
436                 <Message Text=""Files: @(Files)""/>
437
438                 <Message Text=""Prop2: $(Prop2)""/>
439                 <CreateProperty Value=""NewValue"">
440                         <Output TaskParameter=""Value"" PropertyName=""Prop2""/>
441                 </CreateProperty>
442                 <Message Text=""Prop2: $(Prop2)""/>
443         </Target>
444 </Project>
445 ";
446
447                         Engine engine = new Engine (Consts.BinPath);
448                         Project proj = engine.CreateNewProject ();
449                         MonoTests.Microsoft.Build.Tasks.TestMessageLogger logger =
450                                 new MonoTests.Microsoft.Build.Tasks.TestMessageLogger ();
451                         proj.LoadXml (project_xml);
452                         engine.RegisterLogger (logger);
453
454                         if (!proj.Build ("1")) {
455                                 logger.DumpMessages ();
456                                 Assert.Fail ("Build failed");
457                         }
458
459                         logger.DumpMessages ();
460                         logger.CheckLoggedMessageHead ("Prop2: File1", "A1");
461                         logger.CheckLoggedMessageHead ("Files: File1", "A1");
462                         logger.CheckLoggedMessageHead ("Files: File1", "A1");
463                         logger.CheckLoggedMessageHead ("Prop2: File1;foobar", "A1");
464                         logger.CheckLoggedMessageHead ("Prop2: NewValue", "A1");
465                         Assert.AreEqual (0, logger.NormalMessageCount, "unexpected messages found");
466                 }
467
468                 [Test]
469                 // test item refs in properties
470                 public void TestItems13 () {
471                         string project_xml = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
472         <PropertyGroup>
473                 <Prop1>@(Item0)</Prop1>
474         </PropertyGroup>
475         <ItemGroup>
476                 <Item0 Include=""Foo""/>
477                 <Item1 Include=""A\B.txt;A\C.txt;B\B.zip;B\C.zip"" />
478                 <Item2 Include=""@(Item1->'%(Extension)/$(Prop1)')"" />
479         </ItemGroup>
480
481         <Target Name='1'>
482                 <Message Text=""Item2: @(Item2)""/>
483         </Target>
484 </Project>";
485
486                         Engine engine = new Engine (Consts.BinPath);
487                         Project proj = engine.CreateNewProject ();
488                         MonoTests.Microsoft.Build.Tasks.TestMessageLogger logger =
489                                 new MonoTests.Microsoft.Build.Tasks.TestMessageLogger ();
490                         proj.LoadXml (project_xml);
491                         engine.RegisterLogger (logger);
492
493                         if (!proj.Build ("1")) {
494                                 logger.DumpMessages ();
495                                 Assert.Fail ("Build failed");
496                         }
497
498                         logger.CheckLoggedMessageHead ("Item2: .txt/@(Item0);.txt/@(Item0);.zip/@(Item0);.zip/@(Item0)", "A1");
499                         Assert.AreEqual (0, logger.NormalMessageCount, "unexpected messages found");
500                 }
501
502                 [Test]
503                 public void TestSelfRefrentialItems ()
504                 {
505                         string project_xml = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
506         <PropertyGroup>
507                 <Prop1>@(Item1);Val</Prop1>
508                 <Prop2>@(Item2)</Prop2>
509                 <Prop3>@(Item3)</Prop3>
510         </PropertyGroup>
511         <ItemGroup>
512                 <Item1 Include=""Item1OldVal""/>
513                 <Item1 Include=""@(Item1);$(Prop1)""/>
514
515                 <Item2 Include=""Item2OldVal""/>
516                 <Item2 Include=""@(Item2->'%(Identity)');$(Prop2)""/>
517
518                 <Item3 Include=""Item3OldVal""/>
519                 <Item3 Include=""@(Item3, '_');$(Prop3)""/>
520
521                 <Item4 Include=""@(Item4)""/>
522         </ItemGroup>
523
524         <Target Name=""1"">
525                 <Message Text=""Item1: %(Item1.Identity)""/>
526                 <Message Text=""Item2: %(Item2.Identity)""/>
527                 <Message Text=""Item3: %(Item3.Identity)""/>
528                 <Message Text=""%(Item4.Identity)""/>
529                 <Message Text=""Item4: %(Item4.Identity)""/>
530         </Target>
531 </Project>
532 ";
533
534                         Engine engine = new Engine (Consts.BinPath);
535                         Project proj = engine.CreateNewProject ();
536                         MonoTests.Microsoft.Build.Tasks.TestMessageLogger logger =
537                                 new MonoTests.Microsoft.Build.Tasks.TestMessageLogger ();
538                         proj.LoadXml (project_xml);
539                         engine.RegisterLogger (logger);
540
541                         if (!proj.Build ("1")) {
542                                 logger.DumpMessages ();
543                                 Assert.Fail ("Build failed");
544                         }
545
546                         logger.DumpMessages ();
547                         logger.CheckLoggedMessageHead ("Item1: Item1OldVal", "A1");
548                         logger.CheckLoggedMessageHead ("Item1: Val", "A2");
549                         logger.CheckLoggedMessageHead ("Item2: Item2OldVal", "A3");
550                         logger.CheckLoggedMessageHead ("Item3: Item3OldVal", "A4");
551                         logger.CheckLoggedMessageHead ("Item4: ", "A5");
552                         Assert.AreEqual (0, logger.NormalMessageCount, "unexpected messages found");
553                 }
554
555                 [Test]
556                 public void TestEmptyItemsWithBatching ()
557                 {
558                         string project_xml = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
559                         <UsingTask TaskName='StringTestTask' AssemblyFile='Test\resources\TestTasks.dll' />
560                         <UsingTask TaskName='TestTask_TaskItem' AssemblyFile='Test\resources\TestTasks.dll' />
561                         <UsingTask TaskName='TestTask_TaskItems' AssemblyFile='Test\resources\TestTasks.dll' />
562         <Target Name=""1"">
563                 <StringTestTask Property=""%(Item4.Identity)"">
564                         <Output TaskParameter=""OutputString"" PropertyName=""OutputString""/>
565                 </StringTestTask>
566                 <Message Text='output1: $(OutputString)'/>
567
568                 <StringTestTask Property=""  %(Item4.Identity)"">
569                         <Output TaskParameter=""OutputString"" PropertyName=""OutputString""/>
570                 </StringTestTask>
571                 <Message Text='output2: $(OutputString)'/>
572
573                 <StringTestTask Array=""%(Item4.Identity)"">
574                         <Output TaskParameter=""OutputString"" PropertyName=""OutputString""/>
575                 </StringTestTask>
576                 <Message Text='output3: $(OutputString)'/>
577
578                 <StringTestTask Array=""  %(Item4.Identity)"">
579                         <Output TaskParameter=""OutputString"" PropertyName=""OutputString""/>
580                 </StringTestTask>
581                 <Message Text='output4: $(OutputString)'/>
582
583
584                 <TestTask_TaskItem Property=""%(Item4.Identity)"">
585                         <Output TaskParameter=""Output"" PropertyName=""OutputString""/>
586                 </TestTask_TaskItem>
587                 <Message Text='output5: $(OutputString)'/>
588
589                 <TestTask_TaskItem Property=""  %(Item4.Identity)"">
590                         <Output TaskParameter=""Output"" PropertyName=""OutputString""/>
591                 </TestTask_TaskItem>
592                 <Message Text='output6: $(OutputString)'/>
593
594
595                 <TestTask_TaskItems Property=""  %(Item4.Identity)"">
596                         <Output TaskParameter=""Output"" PropertyName=""OutputString""/>
597                 </TestTask_TaskItems>
598                 <Message Text='output7: $(OutputString)'/>
599         
600
601                 <!-- no space in property -->
602                 <TestTask_TaskItems Property=""%(Item4.Identity)"">
603                         <Output TaskParameter=""Output"" PropertyName=""OutputString""/>
604                 </TestTask_TaskItems>
605                 <Message Text='output8: $(OutputString)'/>
606
607         </Target>
608 </Project>
609 ";
610
611                         Engine engine = new Engine (Consts.BinPath);
612                         Project proj = engine.CreateNewProject ();
613                         MonoTests.Microsoft.Build.Tasks.TestMessageLogger logger =
614                                 new MonoTests.Microsoft.Build.Tasks.TestMessageLogger ();
615                         proj.LoadXml (project_xml);
616                         engine.RegisterLogger (logger);
617
618                         if (!proj.Build ("1")) {
619                                 logger.DumpMessages ();
620                                 Assert.Fail ("Build failed");
621                         }
622
623                         logger.DumpMessages ();
624                         logger.CheckLoggedMessageHead ("output1: property: null ## array: null", "A1");
625                         logger.CheckLoggedMessageHead ("output2: property:    ## array: null", "A2");
626                         logger.CheckLoggedMessageHead ("output3: property: null ## array: null", "A3");
627                         logger.CheckLoggedMessageHead ("output4: property: null ## array: null", "A4");
628
629                         logger.CheckLoggedMessageHead ("output5: null", "A5");
630                         logger.CheckLoggedMessageHead ("output6: null", "A6");
631                         logger.CheckLoggedMessageHead ("output7: null", "A7");
632                         logger.CheckLoggedMessageHead ("output8: null", "A8");
633
634                         Assert.AreEqual (0, logger.NormalMessageCount, "unexpected messages found");
635                 }
636
637                 [Test]
638                 public void TestItemsInTarget1 ()
639                 {
640                         Engine engine = new Engine (Consts.BinPath);
641                         Project proj = engine.CreateNewProject ();
642
643                         string documentString = @"
644                                 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
645                                         <UsingTask TaskName='StringTestTask' AssemblyFile='Test\resources\TestTasks.dll' />
646                                         <PropertyGroup>
647                                                 <A>A</A>
648                                                 <B>@(A)g</B>
649                                         </PropertyGroup>
650                                         <ItemGroup>
651                                                 <A Include='A;B;C' />
652                                         </ItemGroup>
653
654                                         <Target Name='1'>
655                                                 <StringTestTask Property='@(A)@(Z)'>
656                                                         <Output TaskParameter='Property' PropertyName='P1' />
657                                                 </StringTestTask>
658                                                 <StringTestTask Property=""@(A,'')"">
659                                                         <Output TaskParameter='Property' PropertyName='P2' />
660                                                 </StringTestTask>
661                                                 <StringTestTask Property=""@(A,'@(A)')"">
662                                                         <Output TaskParameter='Property' PropertyName='P3' />
663                                                 </StringTestTask>
664                                                 <StringTestTask Property=""@(A,'$(A)')"">
665                                                         <Output TaskParameter='Property' PropertyName='P4' />
666                                                 </StringTestTask>
667                                                 <StringTestTask Property=""@(A,'@(A,'')')"">
668                                                         <Output TaskParameter='Property' PropertyName='P5' />
669                                                 </StringTestTask>
670                                                 <StringTestTask Property=""@(A,'$(B)')"">
671                                                         <Output TaskParameter='Property' PropertyName='P6' />
672                                                 </StringTestTask>
673                                                 <StringTestTask Property=""%(A.Filename)"">
674                                                         <Output TaskParameter='Property' ItemName='I1' />
675                                                 </StringTestTask>
676                                                 <StringTestTask Property=""@(A) %(Filename)"">
677                                                         <Output TaskParameter='Property' ItemName='I2' />
678                                                 </StringTestTask>
679                                         </Target>
680                                 </Project>
681                         ";
682
683                         MonoTests.Microsoft.Build.Tasks.TestMessageLogger logger = new MonoTests.Microsoft.Build.Tasks.TestMessageLogger ();
684                         engine.RegisterLogger (logger);
685                         proj.LoadXml (documentString);
686                         if (!proj.Build ("1")) {
687                                 logger.DumpMessages ();
688                                 Assert.Fail ("build failed");
689                         }
690
691                         Assert.AreEqual ("A;B;C", proj.GetEvaluatedProperty ("P1"), "A1");
692                         Assert.AreEqual ("ABC", proj.GetEvaluatedProperty ("P2"), "A2");
693                         Assert.AreEqual ("A@(A)B@(A)C", proj.GetEvaluatedProperty ("P3"), "A3");
694                         Assert.AreEqual ("AABAC", proj.GetEvaluatedProperty ("P4"), "A4");
695                         Assert.AreEqual ("@(A,'ABC')", proj.GetEvaluatedProperty ("P5"), "A5");
696                         Assert.AreEqual ("A@(A)gB@(A)gC", proj.GetEvaluatedProperty ("P6"), "A6");
697                         CheckItems (proj, "I1", "A6", "A", "B", "C");
698                         CheckItems (proj, "I2", "A7", "A A", "B B", "C C");
699                 }
700
701                 [Test]
702                 [Category ("NotWorking")]
703                 public void TestItemsInTarget2 ()
704                 {
705                         Engine engine = new Engine (Consts.BinPath);
706                         Project proj = engine.CreateNewProject ();
707
708                         string documentString = @"
709                                 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
710                                         <UsingTask TaskName='StringTestTask' AssemblyFile='Test\resources\TestTasks.dll' />
711                                         <ItemGroup>
712                                                 <A Include='A;B;C' />
713                                         </ItemGroup>
714
715                                         <Target Name='1'>
716                                                 <StringTestTask Property=""%(Filename)"">
717                                                         <Output TaskParameter='Property' ItemName='I2' />
718                                                 </StringTestTask>
719                                         </Target>
720                                 </Project>
721                         ";
722
723                         proj.LoadXml (documentString);
724                         Assert.IsFalse (proj.Build ("1"), "A1");
725                 }
726
727                 [Test]
728                 public void TestItemsInTarget3 ()
729                 {
730                         Engine engine = new Engine (Consts.BinPath);
731                         Project proj = engine.CreateNewProject ();
732
733                         string documentString = @"
734                                 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
735                                         <UsingTask TaskName='StringTestTask' AssemblyFile='Test\resources\TestTasks.dll' />
736                                         <PropertyGroup>
737                                                 <A>A</A>
738                                                 <B>A;B</B>
739                                                 <C>A;;</C>
740                                         </PropertyGroup>
741                                         <ItemGroup>
742                                                 <A Include='A;B;C' />
743                                         </ItemGroup>";
744
745                         documentString += CreateTargetFragment ("StringTestTask", "Array", "Array", "I",
746                                         new string [] {
747                                                 "$(A)$(A)",
748                                                 "$(B)$(B)",
749                                                 "$(C)",
750                                                 "$(C)$(C)",
751                                                 "@(A);$(C)",
752                                                 "@(A);A;B;C",
753                                                 "Foo;@(A)",
754                                                 "@(A);Foo"
755                                         }) + "</Project>";
756
757                         proj.LoadXml (documentString);
758                         Assert.IsTrue (proj.Build ("1"), "Build failed");
759
760                         CheckItems (proj, "I0", "A0", "AA");
761                         CheckItems (proj, "I1", "A1", "A", "BA", "B");
762                         CheckItems (proj, "I2", "A2", "A");
763                         CheckItems (proj, "I3", "A3", "A", "A");
764                         CheckItems (proj, "I4", "A4", "A", "B", "C", "A");
765                         CheckItems (proj, "I5", "A5", "A", "B", "C", "A", "B", "C");
766                         CheckItems (proj, "I6", "A6", "Foo", "A", "B", "C");
767                         CheckItems (proj, "I7", "A7", "A", "B", "C", "Foo");
768                 }
769
770                 [Test]
771                 //Test with ITaskItem[]
772                 public void TestItemsInTarget3a ()
773                 {
774                         Engine engine = new Engine (Consts.BinPath);
775                         Project proj = engine.CreateNewProject ();
776
777                         string documentString = @"
778                                 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
779                                         <UsingTask TaskName='BatchingTestTask' AssemblyFile='Test\resources\TestTasks.dll' />
780                                         <PropertyGroup>
781                                                 <A>A</A>
782                                                 <B>A;B</B>
783                                                 <C>A;;</C>
784                                         </PropertyGroup>
785                                         <ItemGroup>
786                                                 <A Include='A;B;C' />
787                                                 <B Include='Foo;' />
788                                         </ItemGroup>";
789
790                         documentString += CreateTargetFragment ("BatchingTestTask", "Sources", "Output", "I",
791                                         new string [] {
792                                                 "$(A)$(A)",
793                                                 "$(B)$(B)",
794                                                 "$(C)",
795                                                 "$(C)$(C)",
796                                                 "$(C)   $(C)",
797                                                 "  $(C)   Foo    $(C)  Bar ; $(B)   ",
798                                                 "@(A);$(C)",
799                                                 "@(A);A;B;C",
800                                                 "  abc;  @(A)  ;  $(C)  ;foo",
801                                         }) + "</Project>";
802
803
804                         proj.LoadXml (documentString);
805                         Assert.IsTrue (proj.Build ("1"), "Build failed");
806
807                         CheckItems (proj, "I0", "A0", "AA");
808                         CheckItems (proj, "I1", "A1", "A", "BA", "B");
809                         CheckItems (proj, "I2", "A2", "A");
810                         CheckItems (proj, "I3", "A3", "A", "A");
811                         CheckItems (proj, "I4", "A4", "A", "A");
812                         CheckItems (proj, "I5", "A5", "A", "Foo    A", "Bar", "A", "B");
813                         CheckItems (proj, "I6", "A6", "A", "B", "C", "A");
814                         CheckItems (proj, "I7", "A7", "A", "B", "C", "A", "B", "C");
815                         CheckItems(proj, "I8", "A8", "abc", "A", "B", "C", "A", "foo");
816                 }
817
818                 [Test]
819                 //Test with string[]
820                 public void TestItemsInTarget3b ()
821                 {
822                         Engine engine = new Engine (Consts.BinPath);
823                         Project proj = engine.CreateNewProject ();
824
825                         string documentString = @"
826                                 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
827                                         <UsingTask TaskName='BatchingTestTask' AssemblyFile='Test\resources\TestTasks.dll' />
828                                         <PropertyGroup>
829                                                 <A>A</A>
830                                                 <B>A;B</B>
831                                                 <C>A;;</C>
832                                         </PropertyGroup>
833                                         <ItemGroup>
834                                                 <A Include='A;B;;;C' />
835                                         </ItemGroup>";
836
837                         documentString += CreateTargetFragment ("BatchingTestTask", "Strings", "StringsOutput", "I",
838                                         new string [] {
839                                                 "$(A)$(A)",
840                                                 "$(B)$(B)",
841                                                 "$(C)",
842                                                 "$(C)$(C)",
843                                                 "$(C) $(C) $(C)Bar$(C)",
844                                                 "@(A);$(C)",
845                                                 "@(A);A;B;C"
846                                         }) + "</Project>";
847
848                         proj.LoadXml (documentString);
849                         Assert.IsTrue (proj.Build ("1"), "Build failed");
850
851                         CheckItems (proj, "I0", "A0", "AA");
852                         CheckItems (proj, "I1", "A1", "A", "BA", "B");
853                         CheckItems (proj, "I2", "A2", "A");
854                         CheckItems (proj, "I3", "A3", "A", "A");
855                         CheckItems (proj, "I4", "A4", "A", "A", "A", "BarA");
856                         CheckItems (proj, "I5", "A5", "A", "B", "C", "A");
857                         CheckItems (proj, "I6", "A6", "A", "B", "C", "A", "B", "C");
858                 }
859
860                 [Test]
861                 //Test with string
862                 public void TestItemsInTarget3c ()
863                 {
864                         Engine engine = new Engine (Consts.BinPath);
865                         Project proj = engine.CreateNewProject ();
866                         MonoTests.Microsoft.Build.Tasks.TestMessageLogger logger =
867                                 new MonoTests.Microsoft.Build.Tasks.TestMessageLogger();
868                         engine.RegisterLogger(logger);
869
870                         string documentString = @"
871                                 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
872                                         <UsingTask TaskName='BatchingTestTask' AssemblyFile='Test\resources\TestTasks.dll' />
873                                         <PropertyGroup>
874                                                 <A>A</A>
875                                                 <B>A;B</B>
876                                                 <C>A;;</C>
877                                                 <D>$(C);Foo</D>
878                                         </PropertyGroup>
879                                         <ItemGroup>
880                                                 <A Include='A;B;;;C' />
881                                         </ItemGroup>";
882
883                         documentString += CreateTargetFragment ("BatchingTestTask", "SingleString", "SingleStringOutput", "I",
884                                         new string [] {
885                                                 "$(A)$(A)",
886                                                 "$(B)$(B)",
887                                                 "$(C)",
888                                                 "$(C)$(C)",
889                                                 "$(C) $(C)",
890                                                 "@(A);$(C)",
891                                                 "@(A);A;B;C",
892                                                 "@(A) $(C) @(A)",
893                                         }) + "</Project>";
894
895                         proj.LoadXml (documentString);
896                         if (!proj.Build("1")) {
897                                 logger.DumpMessages();
898                                 Assert.Fail("Build failed");
899                         }
900
901                         BuildProperty bp = proj.EvaluatedProperties ["D"];
902                         Assert.AreEqual ("$(C);Foo", bp.Value, "B0");
903                         Assert.AreEqual ("A;;;Foo", bp.FinalValue, "B1");
904
905                         bp = proj.EvaluatedProperties ["C"];
906                         Assert.AreEqual ("A;;", bp.Value, "B3");
907                         Assert.AreEqual ("A;;", bp.FinalValue, "B4");
908
909                         CheckItems (proj, "I0", "A0", "AA");
910                         CheckItems (proj, "I1", "A1", "A;BA;B");
911                         CheckItems (proj, "I2", "A2", "A;;");
912                         CheckItems (proj, "I3", "A3", "A;;A;;");
913                         CheckItems (proj, "I4", "A4", "A;; A;;");
914                         CheckItems (proj, "I5", "A5", "A;B;C;A;;");
915                         CheckItems (proj, "I6", "A6", "A;B;C;A;B;C");
916                         CheckItems (proj, "I7", "A7", "A;B;C A;; A;B;C");
917                 }
918
919                 [Test]
920                 public void TestSingleTaskItemError1 ()
921                 {
922                         CheckSingleTaskItemProject ("$(B)$(B)");
923                 }
924
925                 [Test]
926                 public void TestSingleTaskItemError2 ()
927                 {
928                         CheckSingleTaskItemProject ("$(C)$(C)");
929                 }
930
931                 [Test]
932                 public void TestSingleTaskItemError3 ()
933                 {
934                         CheckSingleTaskItemProject ("$(C) $(C)");
935                 }
936
937                 [Test]
938                 public void TestSingleTaskItemError4 ()
939                 {
940                         CheckSingleTaskItemProject ("@(A)");
941                 }
942
943                 [Test]
944                 public void TestSingleTaskItemError5 ()
945                 {
946                         CheckSingleTaskItemProject ("@(A);$(C))");
947                 }
948
949                 [Test]
950                 public void TestSingleTaskItemError6 ()
951                 {
952                         CheckSingleTaskItemProject ("@(A);A;B;C");
953                 }
954
955                 [Test]
956                 public void TestSingleTaskItemError7 ()
957                 {
958                         CheckSingleTaskItemProject ("@(Item1)$(C)");
959                 }
960
961                 [Test]
962                 public void TestSingleTaskItemError8 ()
963                 {
964                         CheckSingleTaskItemProject ("$(B).foo");
965                 }
966
967                 [Test]
968                 public void TestSingleTaskItem1 ()
969                 {
970                         Project proj = BuildProjectForSingleTaskItem ("$(D)$(C)");
971                         CheckItems (proj, "I0", "A0", "A");
972                 }
973
974                 [Test]
975                 public void TestSingleTaskItem2 ()
976                 {
977                         Project proj = BuildProjectForSingleTaskItem ("@(Item1)");
978                         CheckItems (proj, "I0", "A0", "F");
979                 }
980
981                 [Test]
982                 public void TestSingleTaskItem3 ()
983                 {
984                         Project proj = BuildProjectForSingleTaskItem ("$(A).foo");
985                         CheckItems (proj, "I0", "A0", "A.foo");
986                 }
987
988                 [Test]
989                 public void TestSingleTaskItem4 ()
990                 {
991                         Project proj = BuildProjectForSingleTaskItem ("$(C)");
992                         CheckItems (proj, "I0", "A0", "A");
993                 }
994
995                 void CheckSingleTaskItemProject (string expression)
996                 {
997                         string documentString = CreateProjectForSingleTaskItem (expression);
998                         Engine engine = new Engine (Consts.BinPath);
999                         Project proj = engine.CreateNewProject ();
1000                         proj.LoadXml (documentString);
1001                         Assert.IsFalse (proj.Build ("1"), "Build should've failed");
1002                 }
1003
1004                 Project BuildProjectForSingleTaskItem (string expression)
1005                 {
1006                         string documentString = CreateProjectForSingleTaskItem (expression);
1007                         Engine engine = new Engine (Consts.BinPath);
1008                         Project proj = engine.CreateNewProject ();
1009                         proj.LoadXml (documentString);
1010                         Assert.IsTrue (proj.Build ("1"), "Build failed");
1011
1012                         return proj;
1013                 }
1014
1015                 string CreateProjectForSingleTaskItem (string expression)
1016                 {
1017                         return @"
1018                                 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
1019                                         <UsingTask TaskName='BatchingTestTask' AssemblyFile='Test\resources\TestTasks.dll' />
1020                                         <PropertyGroup>
1021                                                 <A>A</A>
1022                                                 <B>A;B</B>
1023                                                 <C>A;;</C>
1024                                                 <D></D>
1025                                         </PropertyGroup>
1026                                         <ItemGroup>
1027                                                 <A Include='A;B;C' />
1028                                                 <Item1 Include='F' />
1029                                         </ItemGroup>
1030
1031                                         <Target Name='1'>
1032                                                 <BatchingTestTask SingleTaskItem='" + expression + @"'>
1033                                                         <Output TaskParameter='SingleStringOutput' ItemName='I0' />
1034                                                 </BatchingTestTask>
1035                                         </Target>
1036                                 </Project>";
1037                 }
1038
1039                 string CreateTargetFragment (string taskname, string task_param_in, string task_param_out, string item_prefix,
1040                                 string [] args)
1041                 {
1042                         StringBuilder sb = new StringBuilder ();
1043
1044                         sb.Append ("<Target Name='1'>");
1045                         for (int i = 0; i < args.Length; i ++) {
1046                                 sb.AppendFormat ("<{0} {1}='{2}'>\n", taskname, task_param_in, args [i]);
1047                                 sb.AppendFormat ("\t<Output TaskParameter='{0}' ItemName='{1}{2}' />\n", task_param_out, item_prefix, i);
1048                                 sb.AppendFormat ("</{0}>\n", taskname);
1049                         }
1050                         sb.Append ("</Target>");
1051
1052                         return sb.ToString ();
1053                 }
1054
1055                 [Test]
1056                 public void TestItemsInTarget4 ()
1057                 {
1058                         Engine engine = new Engine (Consts.BinPath);
1059                         Project proj = engine.CreateNewProject ();
1060
1061                         string documentString = @"
1062                                 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
1063                                         <UsingTask TaskName='StringTestTask' AssemblyFile='Test\resources\TestTasks.dll' />
1064                                         <ItemGroup>
1065                                                 <A Include='A;B;C' />
1066                                         </ItemGroup>
1067                                         <Target Name='1'>
1068                                                 <StringTestTask Array='@(A)@(A)'>
1069                                                         <Output TaskParameter='Array' ItemName='I1' />
1070                                                 </StringTestTask>
1071                                         </Target>
1072                                 </Project>
1073                         ";
1074
1075                         proj.LoadXml (documentString);
1076                         Assert.IsFalse (proj.Build ("1"));
1077                 }
1078
1079                 [Test]
1080                 public void TestItemsInTarget5 ()
1081                 {
1082                         Engine engine = new Engine (Consts.BinPath);
1083                         Project proj = engine.CreateNewProject ();
1084
1085                         string documentString = @"
1086                                 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
1087                                         <UsingTask TaskName='StringTestTask' AssemblyFile='Test\resources\TestTasks.dll' />
1088                                         <ItemGroup>
1089                                                 <A Include='A;B;C' />
1090                                         </ItemGroup>
1091                                         <Target Name='1'>
1092                                                 <StringTestTask Array='@(A)AAA'>
1093                                                         <Output TaskParameter='Array' ItemName='I1' />
1094                                                 </StringTestTask>
1095                                         </Target>
1096                                 </Project>
1097                         ";
1098
1099                         proj.LoadXml (documentString);
1100                         Assert.IsFalse (proj.Build ("1"));
1101                 }
1102
1103                 [Test]
1104                 public void TestItemsInTarget6 ()
1105                 {
1106                         Engine engine = new Engine (Consts.BinPath);
1107                         Project proj = engine.CreateNewProject ();
1108
1109                         string documentString = @"
1110                                 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
1111                                         <UsingTask TaskName='StringTestTask' AssemblyFile='Test\resources\TestTasks.dll' />
1112                                         <ItemGroup>
1113                                                 <A Include='A;B;C' />
1114                                         </ItemGroup>
1115                                         <PropertyGroup>
1116                                                 <A>A</A>
1117                                         </PropertyGroup>
1118                                         <Target Name='1'>
1119                                                 <StringTestTask Array='@(A)$(A)'>
1120                                                         <Output TaskParameter='Array' ItemName='I1' />
1121                                                 </StringTestTask>
1122                                         </Target>
1123                                 </Project>
1124                         ";
1125
1126                         proj.LoadXml (documentString);
1127                         Assert.IsFalse (proj.Build ("1"));
1128                 }
1129
1130                 [Test]
1131                 public void TestItemsInTarget7 ()
1132                 {
1133                         Engine engine = new Engine (Consts.BinPath);
1134                         Project proj = engine.CreateNewProject ();
1135
1136                         string documentString = @"
1137                                 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
1138                                         <UsingTask TaskName='BatchingTestTask' AssemblyFile='Test\resources\TestTasks.dll' />
1139                                         <ItemGroup>
1140                                                 <A Include='A;B;C' />
1141                                                 <B Include='Foo;' />
1142                                         </ItemGroup>
1143                                         <Target Name='1'>
1144                                                 <BatchingTestTask SingleTaskItem='Bar%(B.Identity)@(A)' />
1145                                         </Target>
1146                                 </Project>
1147                         ";
1148
1149                         proj.LoadXml (documentString);
1150                         Assert.IsFalse (proj.Build ("1"));
1151                 }
1152
1153                 [Test]
1154                 public void TestItemsInTarget8 ()
1155                 {
1156                         Engine engine = new Engine (Consts.BinPath);
1157                         Project proj = engine.CreateNewProject ();
1158
1159                         string documentString = @"
1160                                 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
1161                                         <PropertyGroup>
1162                                                 <Foo>Five</Foo>
1163                                         </PropertyGroup>
1164                                         <ItemGroup>
1165                                                 <A Include='A'>
1166                                                         <M>True</M>
1167                                                         <M>False</M>
1168                                                 </A>
1169                                         </ItemGroup>
1170                                 </Project>
1171                         ";
1172
1173                         proj.LoadXml (documentString);
1174
1175                         Assert.AreEqual (1, proj.EvaluatedItems.Count, "A1");
1176                         BuildItem bi = proj.EvaluatedItems [0];
1177                         Assert.AreEqual ("False", bi.GetMetadata ("M"), "A2");
1178                 }
1179
1180
1181                 [Test]
1182                 public void TestItemsInTarget9 ()
1183                 {
1184                         Engine engine = new Engine (Consts.BinPath);
1185                         Project proj = engine.CreateNewProject ();
1186
1187                         string documentString = @"
1188                                 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
1189                                         <PropertyGroup>
1190                                                 <Foo>Five</Foo>
1191                                         </PropertyGroup>
1192                                         <ItemGroup>
1193                                                 <A Include='A'>
1194                                                         <M Condition="" '$(Foo)' == 'Five' "">True</M>
1195                                                         <M Condition="" '$(Foo)' != 'Five' "">False</M>
1196                                                 </A>
1197                                         </ItemGroup>
1198                                 </Project>
1199                         ";
1200
1201                         proj.LoadXml (documentString);
1202
1203                         Assert.AreEqual (1, proj.EvaluatedItems.Count, "A1");
1204                         BuildItem bi = proj.EvaluatedItems [0];
1205                         Assert.AreEqual ("True", bi.GetMetadata ("M"), "A2");
1206                         Assert.AreEqual (0, bi.Condition.Length, "A3");
1207
1208                         BuildItemGroup big = proj.GetEvaluatedItemsByNameIgnoringCondition ("A");
1209                         Assert.AreEqual (1, big.Count, "A4");
1210                         bi = big [0];
1211                         Assert.AreEqual ("True", bi.GetMetadata ("M"), "A5");
1212                         Assert.AreEqual ("True", bi.GetEvaluatedMetadata ("M"), "A6");
1213
1214                         /*proj.SetProperty ("Foo", "Six");
1215                         proj.Build ();
1216                         bi = proj.GetEvaluatedItemsByName ("A") [0];
1217                         Assert.AreEqual ("False", bi.GetMetadata ("M"), "A7");
1218                         Assert.AreEqual ("False", bi.GetEvaluatedMetadata ("M"), "A7a");
1219                         Assert.AreEqual (0, bi.Condition.Length, "A8");
1220
1221                         big = proj.GetEvaluatedItemsByNameIgnoringCondition ("A");
1222                         Assert.AreEqual (1, big.Count, "A9");
1223                         bi = big [0];
1224                         Assert.AreEqual ("True", bi.GetMetadata ("M"), "A10");
1225                         Assert.AreEqual ("True", bi.GetEvaluatedMetadata ("M"), "A11");*/
1226                 }
1227         }
1228 }