5 // Marek Sieradzki (marek.sieradzki@gmail.com)
6 // Ankit Jain (jankit@novell.com)
8 // (C) 2006 Marek Sieradzki
9 // Copyright 2009 Novell, Inc (http://www.novell.com)
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:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
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.
33 using Microsoft.Build.BuildEngine;
34 using NUnit.Framework;
36 namespace MonoTests.Microsoft.Build.BuildEngine.Various {
39 private string GetItems (Project proj, string name)
41 BuildItemGroup big = proj.GetEvaluatedItemsByName (name);
42 string str = String.Empty;
46 foreach (BuildItem bi in big) {
47 if (str == String.Empty)
48 str = bi.FinalItemSpec;
50 str += ";" + bi.FinalItemSpec;
56 private void CheckItems (Project proj, string name, string prefix, params string [] values)
58 BuildItemGroup big = proj.GetEvaluatedItemsByName (name);
60 Assert.Fail ("{0}: Item corresponding '{1}' not found.", prefix, name);
64 if (values.Length != big.Count) {
65 Console.Write ("Expected> ");
66 foreach (string s in values)
67 Console.Write ("{0}|", s);
69 Console.Write ("Actual> ");
70 foreach (BuildItem item in big)
71 Console.Write ("{0}|", item.FinalItemSpec);
73 Assert.AreEqual (values.Length, big.Count, String.Format ("{0}: Number of items", prefix));
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));
81 public void TestItems1 ()
83 Engine engine = new Engine (Consts.BinPath);
84 Project proj = engine.CreateNewProject ();
86 string documentString = @"
87 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
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)' />
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");
113 public void TestItems2 ()
115 Engine engine = new Engine (Consts.BinPath);
116 Project proj = engine.CreateNewProject ();
118 string documentString = @"
119 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
121 <Item1 Include='A;B;C' />
122 <Item2 Include=""@(Item1,'-')"" />
123 <Item3 Include=""@(Item1,'xx')"" />
128 proj.LoadXml (documentString);
130 CheckItems (proj, "Item2", "A1", "A-B-C");
131 CheckItems (proj, "Item3", "A2", "AxxBxxC");
135 public void TestItems3 ()
137 Engine engine = new Engine (Consts.BinPath);
138 Project proj = engine.CreateNewProject ();
140 string documentString = @"
141 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
143 <Item1 Include='A;B;C' />
144 <Item2 Include=""@(Item1, '-')"" />
149 proj.LoadXml (documentString);
151 CheckItems (proj, "Item2", "A1", "A-B-C");
156 public void TestItems4 ()
158 Engine engine = new Engine (Consts.BinPath);
159 Project proj = engine.CreateNewProject ();
161 string documentString = @"
162 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
164 <Item1 Include='A;B;C' />
165 <Item2 Include=""A\B.txt;A\C.txt;B\B.zip;B\C.zip"" />
166 <ItemT1 Include=""@(Item1->'%(Identity)')"" />
167 <ItemT2 Include=""@(Item1->'%(Identity)%(Identity)')"" />
168 <ItemT3 Include=""@(Item1->'(-%(Identity)-)')"" />
169 <ItemT4 Include=""@(Item2->'%(Extension)')"" />
170 <ItemT5 Include=""@(Item2->'%(Filename)/%(Extension)')"" />
175 proj.LoadXml (documentString);
177 CheckItems (proj, "ItemT1", "A1", "A", "B", "C");
178 CheckItems (proj, "ItemT2", "A2", "AA", "BB", "CC");
179 CheckItems (proj, "ItemT3", "A3", "(-A-)", "(-B-)", "(-C-)");
180 CheckItems (proj, "ItemT4", "A4", ".txt", ".txt", ".zip", ".zip");
181 CheckItems (proj, "ItemT5", "A5", "B/.txt", "C/.txt", "B/.zip", "C/.zip");
185 [Category ("NotWorking")]
186 public void TestItems5 ()
188 Engine engine = new Engine (Consts.BinPath);
189 Project proj = engine.CreateNewProject ();
191 string documentString = @"
192 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
194 <Item Include=""A\B.txt;A\C.txt;B\B.zip;B\C.zip"" />
195 <ItemT Include=""@(Item->'%(RelativeDir)X/%(Filename)')"" />
200 proj.LoadXml (documentString);
202 CheckItems (proj, "ItemT", "A1", @"A\X/B", @"A\X/C", @"B\X/B", @"B\X/C");
206 [Category ("NotWorking")]
207 public void TestItems6 ()
209 Engine engine = new Engine (Consts.BinPath);
210 Project proj = engine.CreateNewProject ();
212 string documentString = @"
213 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
219 <Item1 Include='A;B;C' />
220 <Item2 Include='%(A.B)' />
221 <Item3 Include='$(Z)' />
222 <Item4 Include=""@(Item1, '$(A)')"" />
223 <Item5 Include=""@(Item1, '%(A)')"" />
224 <Item6 Include=""@(Item1, '@(A)')"" />
225 <Item7 Include=""@(Item1-> '%(Filename)')"" />
230 proj.LoadXml (documentString);
232 CheckItems (proj, "Item2", "A1", "%(A.B)");
233 CheckItems (proj, "Item3", "A2");
234 CheckItems (proj, "Item4", "A3", "AABAC");
235 CheckItems (proj, "Item5", "A4", "A%(A)B%(A)C");
236 CheckItems (proj, "Item6", "A6", "A@(A)B@(A)C");
237 CheckItems (proj, "Item7", "A6", "A", "B", "C");
240 // The expression "@(Item1, '@(A,'')')" cannot be used in this context.
241 // Item lists cannot be concatenated with other strings where an item list is expected.
242 // Use a semicolon to separate multiple item lists.
244 [ExpectedException (typeof (InvalidProjectFileException))]
245 [Category ("NotWorking")]
246 public void TestItems7 ()
248 Engine engine = new Engine (Consts.BinPath);
249 Project proj = engine.CreateNewProject ();
251 string documentString = @"
252 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
254 <Item1 Include='A;B;C' />
255 <Item7 Include=""@(Item1, '@(A,'')')"" />
260 proj.LoadXml (documentString);
263 // The expression "@(Item1, '@(A->'')')" cannot be used in this context.
264 // Item lists cannot be concatenated with other strings where an item list is expected.
265 // Use a semicolon to separate multiple item lists.
267 [ExpectedException (typeof (InvalidProjectFileException))]
268 [Category ("NotWorking")]
269 public void TestItems8 ()
271 Engine engine = new Engine (Consts.BinPath);
272 Project proj = engine.CreateNewProject ();
274 string documentString = @"
275 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
277 <Item1 Include='A;B;C' />
278 <Item8 Include=""@(Item1, '@(A->'')')"" />
283 proj.LoadXml (documentString);
286 // The expression "@(Item1, '@(A->'','')')" cannot be used in this context.
287 // Item lists cannot be concatenated with other strings where an item list is expected.
288 // Use a semicolon to separate multiple item lists.
290 [ExpectedException (typeof (InvalidProjectFileException))]
291 [Category ("NotWorking")]
292 public void TestItems9 ()
294 Engine engine = new Engine (Consts.BinPath);
295 Project proj = engine.CreateNewProject ();
297 string documentString = @"
298 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
300 <Item1 Include='A;B;C' />
301 <Item9 Include=""@(Item1, '@(A->'','')')"" />
306 proj.LoadXml (documentString);
310 public void TestItemsInTarget1 ()
312 Engine engine = new Engine (Consts.BinPath);
313 Project proj = engine.CreateNewProject ();
315 string documentString = @"
316 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
317 <UsingTask TaskName='StringTestTask' AssemblyFile='Test\resources\TestTasks.dll' />
322 <A Include='A;B;C' />
326 <StringTestTask Property='@(A)@(Z)'>
327 <Output TaskParameter='Property' PropertyName='P1' />
329 <StringTestTask Property=""@(A,'')"">
330 <Output TaskParameter='Property' PropertyName='P2' />
332 <StringTestTask Property=""@(A,'@(A)')"">
333 <Output TaskParameter='Property' PropertyName='P3' />
335 <StringTestTask Property=""@(A,'$(A)')"">
336 <Output TaskParameter='Property' PropertyName='P4' />
338 <StringTestTask Property=""@(A,'@(A,'')')"">
339 <Output TaskParameter='Property' PropertyName='P5' />
341 <StringTestTask Property=""%(A.Filename)"">
342 <Output TaskParameter='Property' ItemName='I1' />
344 <StringTestTask Property=""@(A) %(Filename)"">
345 <Output TaskParameter='Property' ItemName='I2' />
351 proj.LoadXml (documentString);
352 Assert.IsTrue (proj.Build ("1"), "A0, Build failed");
354 Assert.AreEqual ("A;B;C", proj.GetEvaluatedProperty ("P1"), "A1");
355 Assert.AreEqual ("ABC", proj.GetEvaluatedProperty ("P2"), "A2");
356 Assert.AreEqual ("A@(A)B@(A)C", proj.GetEvaluatedProperty ("P3"), "A3");
357 Assert.AreEqual ("AABAC", proj.GetEvaluatedProperty ("P4"), "A4");
358 Assert.AreEqual ("@(A,'ABC')", proj.GetEvaluatedProperty ("P5"), "A5");
359 CheckItems (proj, "I1", "A6", "A", "B", "C");
360 CheckItems (proj, "I2", "A7", "A A", "B B", "C C");
364 [Category ("NotWorking")]
365 public void TestItemsInTarget2 ()
367 Engine engine = new Engine (Consts.BinPath);
368 Project proj = engine.CreateNewProject ();
370 string documentString = @"
371 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
372 <UsingTask TaskName='StringTestTask' AssemblyFile='Test\resources\TestTasks.dll' />
374 <A Include='A;B;C' />
378 <StringTestTask Property=""%(Filename)"">
379 <Output TaskParameter='Property' ItemName='I2' />
385 proj.LoadXml (documentString);
386 Assert.IsFalse (proj.Build ("1"), "A1");
390 public void TestItemsInTarget3 ()
392 Engine engine = new Engine (Consts.BinPath);
393 Project proj = engine.CreateNewProject ();
395 string documentString = @"
396 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
397 <UsingTask TaskName='StringTestTask' AssemblyFile='Test\resources\TestTasks.dll' />
404 <A Include='A;B;C' />
407 documentString += CreateTargetFragment ("StringTestTask", "Array", "Array", "I",
419 proj.LoadXml (documentString);
420 Assert.IsTrue (proj.Build ("1"), "Build failed");
422 CheckItems (proj, "I0", "A0", "AA");
423 CheckItems (proj, "I1", "A1", "A", "BA", "B");
424 CheckItems (proj, "I2", "A2", "A");
425 CheckItems (proj, "I3", "A3", "A", "A");
426 CheckItems (proj, "I4", "A4", "A", "B", "C", "A");
427 CheckItems (proj, "I5", "A5", "A", "B", "C", "A", "B", "C");
428 CheckItems (proj, "I6", "A6", "Foo", "A", "B", "C");
429 CheckItems (proj, "I7", "A7", "A", "B", "C", "Foo");
433 //Test with ITaskItem[]
434 public void TestItemsInTarget3a ()
436 Engine engine = new Engine (Consts.BinPath);
437 Project proj = engine.CreateNewProject ();
439 string documentString = @"
440 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
441 <UsingTask TaskName='BatchingTestTask' AssemblyFile='Test\resources\TestTasks.dll' />
448 <A Include='A;B;C' />
452 documentString += CreateTargetFragment ("BatchingTestTask", "Sources", "Output", "I",
459 " $(C) Foo $(C) Bar ; $(B) ",
465 proj.LoadXml (documentString);
466 Assert.IsTrue (proj.Build ("1"), "Build failed");
468 CheckItems (proj, "I0", "A0", "AA");
469 CheckItems (proj, "I1", "A1", "A", "BA", "B");
470 CheckItems (proj, "I2", "A2", "A");
471 CheckItems (proj, "I3", "A3", "A", "A");
472 CheckItems (proj, "I4", "A4", "A", "A");
473 CheckItems (proj, "I5", "A5", "A", "Foo A", "Bar", "A", "B");
474 CheckItems (proj, "I6", "A6", "A", "B", "C", "A");
475 CheckItems (proj, "I7", "A7", "A", "B", "C", "A", "B", "C");
480 public void TestItemsInTarget3b ()
482 Engine engine = new Engine (Consts.BinPath);
483 Project proj = engine.CreateNewProject ();
485 string documentString = @"
486 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
487 <UsingTask TaskName='BatchingTestTask' AssemblyFile='Test\resources\TestTasks.dll' />
494 <A Include='A;B;;;C' />
497 documentString += CreateTargetFragment ("BatchingTestTask", "Strings", "StringsOutput", "I",
503 "$(C) $(C) $(C)Bar$(C)",
508 proj.LoadXml (documentString);
509 Assert.IsTrue (proj.Build ("1"), "Build failed");
511 CheckItems (proj, "I0", "A0", "AA");
512 CheckItems (proj, "I1", "A1", "A", "BA", "B");
513 CheckItems (proj, "I2", "A2", "A");
514 CheckItems (proj, "I3", "A3", "A", "A");
515 CheckItems (proj, "I4", "A4", "A", "A", "A", "BarA");
516 CheckItems (proj, "I5", "A5", "A", "B", "C", "A");
517 CheckItems (proj, "I6", "A6", "A", "B", "C", "A", "B", "C");
522 public void TestItemsInTarget3c ()
524 Engine engine = new Engine (Consts.BinPath);
525 Project proj = engine.CreateNewProject ();
527 string documentString = @"
528 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
529 <UsingTask TaskName='BatchingTestTask' AssemblyFile='Test\resources\TestTasks.dll' />
537 <A Include='A;B;;;C' />
540 documentString += CreateTargetFragment ("BatchingTestTask", "SingleString", "SingleStringOutput", "I",
552 proj.LoadXml (documentString);
553 Assert.IsTrue (proj.Build ("1"), "Build failed");
555 BuildProperty bp = proj.EvaluatedProperties ["D"];
556 Assert.AreEqual ("$(C);Foo", bp.Value, "B0");
557 Assert.AreEqual ("A;;;Foo", bp.FinalValue, "B1");
559 bp = proj.EvaluatedProperties ["C"];
560 Assert.AreEqual ("A;;", bp.Value, "B3");
561 Assert.AreEqual ("A;;", bp.FinalValue, "B4");
563 CheckItems (proj, "I0", "A0", "AA");
564 CheckItems (proj, "I1", "A1", "A;BA;B");
565 CheckItems (proj, "I2", "A2", "A;;");
566 CheckItems (proj, "I3", "A3", "A;;A;;");
567 CheckItems (proj, "I4", "A4", "A;; A;;");
568 CheckItems (proj, "I5", "A5", "A;B;C;A;;");
569 CheckItems (proj, "I6", "A6", "A;B;C;A;B;C");
570 CheckItems (proj, "I7", "A7", "A;B;C A;; A;B;C");
574 public void TestSingleTaskItemError1 ()
576 CheckSingleTaskItemProject ("$(B)$(B)");
580 public void TestSingleTaskItemError2 ()
582 CheckSingleTaskItemProject ("$(C)$(C)");
586 public void TestSingleTaskItemError3 ()
588 CheckSingleTaskItemProject ("$(C) $(C)");
592 public void TestSingleTaskItemError4 ()
594 CheckSingleTaskItemProject ("@(A)");
598 public void TestSingleTaskItemError5 ()
600 CheckSingleTaskItemProject ("@(A);$(C))");
604 public void TestSingleTaskItemError6 ()
606 CheckSingleTaskItemProject ("@(A);A;B;C");
610 public void TestSingleTaskItemError7 ()
612 CheckSingleTaskItemProject ("@(Item1)$(C)");
616 public void TestSingleTaskItemError8 ()
618 CheckSingleTaskItemProject ("$(B).foo");
622 public void TestSingleTaskItem1 ()
624 Project proj = BuildProjectForSingleTaskItem ("$(D)$(C)");
625 CheckItems (proj, "I0", "A0", "A");
629 public void TestSingleTaskItem2 ()
631 Project proj = BuildProjectForSingleTaskItem ("@(Item1)");
632 CheckItems (proj, "I0", "A0", "F");
636 public void TestSingleTaskItem3 ()
638 Project proj = BuildProjectForSingleTaskItem ("$(A).foo");
639 CheckItems (proj, "I0", "A0", "A.foo");
643 public void TestSingleTaskItem4 ()
645 Project proj = BuildProjectForSingleTaskItem ("$(C)");
646 CheckItems (proj, "I0", "A0", "A");
649 void CheckSingleTaskItemProject (string expression)
651 string documentString = CreateProjectForSingleTaskItem (expression);
652 Engine engine = new Engine (Consts.BinPath);
653 Project proj = engine.CreateNewProject ();
654 proj.LoadXml (documentString);
655 Assert.IsFalse (proj.Build ("1"), "Build should've failed");
658 Project BuildProjectForSingleTaskItem (string expression)
660 string documentString = CreateProjectForSingleTaskItem (expression);
661 Engine engine = new Engine (Consts.BinPath);
662 Project proj = engine.CreateNewProject ();
663 proj.LoadXml (documentString);
664 Assert.IsTrue (proj.Build ("1"), "Build failed");
669 string CreateProjectForSingleTaskItem (string expression)
672 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
673 <UsingTask TaskName='BatchingTestTask' AssemblyFile='Test\resources\TestTasks.dll' />
681 <A Include='A;B;C' />
682 <Item1 Include='F' />
686 <BatchingTestTask SingleTaskItem='" + expression + @"'>
687 <Output TaskParameter='SingleStringOutput' ItemName='I0' />
693 string CreateTargetFragment (string taskname, string task_param_in, string task_param_out, string item_prefix,
696 StringBuilder sb = new StringBuilder ();
698 sb.Append ("<Target Name='1'>");
699 for (int i = 0; i < args.Length; i ++) {
700 sb.AppendFormat ("<{0} {1}='{2}'>\n", taskname, task_param_in, args [i]);
701 sb.AppendFormat ("\t<Output TaskParameter='{0}' ItemName='{1}{2}' />\n", task_param_out, item_prefix, i);
702 sb.AppendFormat ("</{0}>\n", taskname);
704 sb.Append ("</Target>");
706 return sb.ToString ();
710 public void TestItemsInTarget4 ()
712 Engine engine = new Engine (Consts.BinPath);
713 Project proj = engine.CreateNewProject ();
715 string documentString = @"
716 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
717 <UsingTask TaskName='StringTestTask' AssemblyFile='Test\resources\TestTasks.dll' />
719 <A Include='A;B;C' />
722 <StringTestTask Array='@(A)@(A)'>
723 <Output TaskParameter='Array' ItemName='I1' />
729 proj.LoadXml (documentString);
730 Assert.IsFalse (proj.Build ("1"));
734 public void TestItemsInTarget5 ()
736 Engine engine = new Engine (Consts.BinPath);
737 Project proj = engine.CreateNewProject ();
739 string documentString = @"
740 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
741 <UsingTask TaskName='StringTestTask' AssemblyFile='Test\resources\TestTasks.dll' />
743 <A Include='A;B;C' />
746 <StringTestTask Array='@(A)AAA'>
747 <Output TaskParameter='Array' ItemName='I1' />
753 proj.LoadXml (documentString);
754 Assert.IsFalse (proj.Build ("1"));
758 public void TestItemsInTarget6 ()
760 Engine engine = new Engine (Consts.BinPath);
761 Project proj = engine.CreateNewProject ();
763 string documentString = @"
764 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
765 <UsingTask TaskName='StringTestTask' AssemblyFile='Test\resources\TestTasks.dll' />
767 <A Include='A;B;C' />
773 <StringTestTask Array='@(A)$(A)'>
774 <Output TaskParameter='Array' ItemName='I1' />
780 proj.LoadXml (documentString);
781 Assert.IsFalse (proj.Build ("1"));
785 public void TestItemsInTarget7 ()
787 Engine engine = new Engine (Consts.BinPath);
788 Project proj = engine.CreateNewProject ();
790 string documentString = @"
791 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
792 <UsingTask TaskName='BatchingTestTask' AssemblyFile='Test\resources\TestTasks.dll' />
794 <A Include='A;B;C' />
798 <BatchingTestTask SingleTaskItem='Bar%(B.Identity)@(A)' />
803 proj.LoadXml (documentString);
804 Assert.IsFalse (proj.Build ("1"));
808 public void TestItemsInTarget8 ()
810 Engine engine = new Engine (Consts.BinPath);
811 Project proj = engine.CreateNewProject ();
813 string documentString = @"
814 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
827 proj.LoadXml (documentString);
829 Assert.AreEqual (1, proj.EvaluatedItems.Count, "A1");
830 BuildItem bi = proj.EvaluatedItems [0];
831 Assert.AreEqual ("False", bi.GetMetadata ("M"), "A2");
836 public void TestItemsInTarget9 ()
838 Engine engine = new Engine (Consts.BinPath);
839 Project proj = engine.CreateNewProject ();
841 string documentString = @"
842 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
848 <M Condition="" '$(Foo)' == 'Five' "">True</M>
849 <M Condition="" '$(Foo)' != 'Five' "">False</M>
855 proj.LoadXml (documentString);
857 Assert.AreEqual (1, proj.EvaluatedItems.Count, "A1");
858 BuildItem bi = proj.EvaluatedItems [0];
859 Assert.AreEqual ("True", bi.GetMetadata ("M"), "A2");
860 Assert.AreEqual (0, bi.Condition.Length, "A3");
862 BuildItemGroup big = proj.GetEvaluatedItemsByNameIgnoringCondition ("A");
863 Assert.AreEqual (1, big.Count, "A4");
865 Assert.AreEqual ("True", bi.GetMetadata ("M"), "A5");
866 Assert.AreEqual ("True", bi.GetEvaluatedMetadata ("M"), "A6");
868 /*proj.SetProperty ("Foo", "Six");
870 bi = proj.GetEvaluatedItemsByName ("A") [0];
871 Assert.AreEqual ("False", bi.GetMetadata ("M"), "A7");
872 Assert.AreEqual ("False", bi.GetEvaluatedMetadata ("M"), "A7a");
873 Assert.AreEqual (0, bi.Condition.Length, "A8");
875 big = proj.GetEvaluatedItemsByNameIgnoringCondition ("A");
876 Assert.AreEqual (1, big.Count, "A9");
878 Assert.AreEqual ("True", bi.GetMetadata ("M"), "A10");
879 Assert.AreEqual ("True", bi.GetEvaluatedMetadata ("M"), "A11");*/