merged Sys.Web.Services 2.0 support in my branch:
[mono.git] / mcs / class / Microsoft.Build.Engine / Test / Microsoft.Build.BuildEngine / ProjectTest.cs
1 //
2 // ProjectTest.cs:
3 //
4 // Author:
5 //   Marek Sieradzki (marek.sieradzki@gmail.com)
6 //
7 // (C) 2005 Marek Sieradzki
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
28 using System;
29 using System.Collections;
30 using System.Xml;
31 using Microsoft.Build.BuildEngine;
32 using Microsoft.Build.Framework;
33 using Microsoft.Build.Utilities;
34 using NUnit.Framework;
35
36 namespace MonoTests.Microsoft.Build.BuildEngine {
37
38         class TestLogger : Logger {
39                 int target_started_events = 0;
40                 int target_finished_events = 0;
41
42                 public override void Initialize (IEventSource eventSource)
43                 {
44                         eventSource.TargetStarted += new TargetStartedEventHandler(TargetStarted);
45                         eventSource.TargetFinished += new TargetFinishedEventHandler(TargetFinished);
46                         eventSource.MessageRaised += new BuildMessageEventHandler(Message);
47                         eventSource.WarningRaised += new BuildWarningEventHandler(Warning);
48                 }
49
50                 void TargetStarted (object sender, TargetStartedEventArgs args)
51                 {
52                         target_started_events++;
53                 }
54
55                 void TargetFinished (object sender, TargetFinishedEventArgs args)
56                 {
57                         target_finished_events++;
58                 }
59
60                 void Message (object sender, BuildMessageEventArgs args)
61                 {
62                 }
63                 
64                 void Warning (object sender, BuildWarningEventArgs args)
65                 {
66                 }
67
68                 public int TargetStartedEvents { get { return target_started_events; } }
69
70                 public int TargetFinishedEvents { get { return target_finished_events; } }
71         }
72
73         [TestFixture]
74         public class ProjectTest {
75
76                 [Test]
77                 [ExpectedException (typeof (InvalidProjectFileException),
78                 @"The default XML namespace of the project must be the MSBuild XML namespace." + 
79                 " If the project is authored in the MSBuild 2003 format, please add " +
80                 "xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\" to the <Project> element. " +
81                 "If the project has been authored in the old 1.0 or 1.2 format, please convert it to MSBuild 2003 format.  ")]
82                 public void TestAssignment1 ()
83                 {
84                         Engine engine;
85                         Project project;
86                         string documentString =
87                                 "<Project></Project>";
88                         
89                         engine = new Engine (Consts.BinPath);
90                         DateTime time = DateTime.Now;
91                         project = engine.CreateNewProject ();
92                         project.LoadXml (documentString);
93
94                         Assert.AreEqual (true, project.BuildEnabled, "A1");
95                         Assert.AreEqual (String.Empty, project.DefaultTargets, "A2");
96                         Assert.AreEqual (String.Empty, project.FullFileName, "A3");
97                         Assert.AreEqual (false, project.IsDirty, "A4");
98                         Assert.AreEqual (false, project.IsValidated, "A5");
99                         Assert.AreEqual (engine, project.ParentEngine, "A6");
100                         Assert.IsTrue (time <= project.TimeOfLastDirty, "A7");
101                         Assert.IsTrue (String.Empty != project.Xml, "A8");
102                 }
103
104                 [Test]
105                 public void TestAssignment2 ()
106                 {
107                         Engine engine;
108                         Project project;
109                         string documentString =
110                                 "<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\"></Project>";
111                         
112                         engine = new Engine (Consts.BinPath);
113                         DateTime time = DateTime.Now;
114                         project = engine.CreateNewProject ();
115                         project.LoadXml (documentString);
116
117                         Assert.AreEqual (true, project.BuildEnabled, "A1");
118                         Assert.AreEqual (String.Empty, project.DefaultTargets, "A2");
119                         Assert.AreEqual (String.Empty, project.FullFileName, "A3");
120                         Assert.AreEqual (true, project.IsDirty, "A4");
121                         Assert.AreEqual (false, project.IsValidated, "A5");
122                         Assert.AreEqual (engine, project.ParentEngine, "A6");
123                         Assert.IsTrue (time <= project.TimeOfLastDirty, "A7");
124                         Assert.IsTrue (String.Empty != project.Xml, "A8");
125                 }
126
127                 [Test]
128                 [Category ("NotWorking")]
129                 public void TestAddNewItemGroup ()
130                 {
131                         Engine engine;
132                         Project project;
133
134                         string documentString = @"
135                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
136                                 </Project>
137                         ";
138
139                         engine = new Engine (Consts.BinPath);
140                         project = engine.CreateNewProject ();
141                         project.LoadXml (documentString);
142
143                         BuildItemGroup big = project.AddNewItemGroup ();
144                         Assert.IsNotNull (big, "A1");
145                         Assert.AreEqual (String.Empty, big.Condition, "A2");
146                         Assert.AreEqual (0, big.Count, "A3");
147                         Assert.AreEqual (false, big.IsImported, "A4");
148                         Assert.IsTrue (project.IsDirty, "A5");
149                 }
150
151                 [Test]
152                 [Category ("NotWorking")]
153                 public void TestAddNewPropertyGroup ()
154                 {
155                         Engine engine;
156                         Project project;
157
158                         string documentString = @"
159                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
160                                 </Project>
161                         ";
162
163                         engine = new Engine (Consts.BinPath);
164                         project = engine.CreateNewProject ();
165                         project.LoadXml (documentString);
166
167                         BuildPropertyGroup bpg = project.AddNewPropertyGroup (false);
168                         Assert.IsNotNull (bpg, "A1");
169                         Assert.AreEqual (String.Empty, bpg.Condition, "A2");
170                         Assert.AreEqual (0, bpg.Count, "A3");
171                         Assert.AreEqual (false, bpg.IsImported, "A4");
172                         Assert.IsTrue (project.IsDirty, "A5");
173                 }
174
175                 [Test]
176                 [Category ("NotWorking")]
177                 public void TestBuild1 ()
178                 {
179                         Engine engine;
180                         Project project;
181                         IDictionary hashtable = new Hashtable ();
182                         
183                         string documentString = @"
184                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
185                                         <Target Name='Main'>
186                                                 <Microsoft.Build.Tasks.Message Text='Text' />
187                                         </Target>
188                                 </Project>
189                         ";
190                         
191                         engine = new Engine (Consts.BinPath);
192                         project = engine.CreateNewProject ();
193                         project.LoadXml (documentString);
194
195                         Assert.AreEqual (true, project.Build (new string[] { "Main" }, hashtable), "A1");
196                         Assert.AreEqual (1, hashtable.Count, "A2");
197                 }
198
199                 [Test]
200                 public void TestBuild2 ()
201                 {
202                         Engine engine;
203                         Project project;
204
205                         string documentString = @"
206                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
207                                         <Target Name='T' Inputs='Test\resources\TestTasks.cs' Outputs='Test\resources\TestTasks.dll'>
208                                                 <Message Text='text' />
209                                         </Target>
210                                 </Project>
211                         ";
212
213                         engine = new Engine (Consts.BinPath);
214                         TestLogger tl = new TestLogger ();
215                         engine.RegisterLogger (tl);
216                         project = engine.CreateNewProject ();
217                         project.LoadXml (documentString);
218
219                         project.Build ("T");
220                         project.Build ("T");
221
222                         Assert.AreEqual (2, tl.TargetStartedEvents, "A1");
223                         Assert.AreEqual (2, tl.TargetFinishedEvents, "A2");
224                 }
225
226                 [Test]
227                 public void TestBuild3 ()
228                 {
229                         Engine engine;
230                         Project project;
231
232                         string documentString = @"
233                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
234                                         <Target Name='T' Inputs='Test\resources\TestTasks.cs' Outputs='Test\resources\TestTasks.dll'>
235                                                 <Message Text='text' />
236                                         </Target>
237                                 </Project>
238                         ";
239
240                         engine = new Engine (Consts.BinPath);
241                         TestLogger tl = new TestLogger ();
242                         engine.RegisterLogger (tl);
243                         project = engine.CreateNewProject ();
244                         project.LoadXml (documentString);
245
246                         project.Build (new string [1] { "T" }, null, BuildSettings.None);
247                         project.Build (new string [1] { "T" }, null, BuildSettings.None);
248
249                         Assert.AreEqual (2, tl.TargetStartedEvents, "A1");
250                         Assert.AreEqual (2, tl.TargetFinishedEvents, "A2");
251                 }
252
253                 [Test]
254                 [Category ("NotWorking")]
255                 public void TestBuild4 ()
256                 {
257                         Engine engine;
258                         Project project;
259
260                         string documentString = @"
261                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
262                                         <Target Name='T' Inputs='Test\resources\TestTasks.cs' Outputs='Test\resources\TestTasks.dll'>
263                                                 <Message Text='text' />
264                                         </Target>
265                                 </Project>
266                         ";
267
268                         engine = new Engine (Consts.BinPath);
269                         TestLogger tl = new TestLogger ();
270                         engine.RegisterLogger (tl);
271                         project = engine.CreateNewProject ();
272                         project.LoadXml (documentString);
273
274                         project.Build (new string [1] { "T" }, null, BuildSettings.DoNotResetPreviouslyBuiltTargets);
275                         project.Build (new string [1] { "T" }, null, BuildSettings.DoNotResetPreviouslyBuiltTargets);
276
277                         Assert.AreEqual (1, tl.TargetStartedEvents, "A1");
278                         Assert.AreEqual (1, tl.TargetFinishedEvents, "A2");
279                 }
280
281                 [Test]
282                 public void TestBuild5 ()
283                 {
284                         Engine engine;
285                         Project project;
286
287                         string documentString = @"
288                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
289                                 </Project>
290                         ";
291
292                         engine = new Engine (Consts.BinPath);
293                         project = engine.CreateNewProject ();
294                         project.LoadXml (documentString);
295
296                         Assert.IsFalse (project.Build ("target_that_doesnt_exist"));
297                 }
298
299                 [Test]
300                 public void TestEvaluatedItems1 ()
301                 {
302                         Engine engine;
303                         Project project;
304
305                         string documentString = @"
306                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
307                                         <ItemGroup>
308                                                 <A Include='a' />
309                                                 <B Include='b' Condition='false' />
310                                         </ItemGroup>
311                                 </Project>
312                         ";
313
314                         engine = new Engine (Consts.BinPath);
315                         project = engine.CreateNewProject ();
316                         project.LoadXml (documentString);
317
318                         Assert.AreEqual (1, project.EvaluatedItems.Count, "A1");
319
320                         BuildItem bi = project.EvaluatedItems [0];
321
322                         bi.Name = "C";
323                         bi.Include = "c";
324
325                         BuildItemGroup [] big = new BuildItemGroup [1];
326                         project.ItemGroups.CopyTo (big, 0);
327                         Assert.AreEqual ("C", big [0] [0].Name, "A2");
328                         Assert.AreEqual ("c", big [0] [0].Include, "A3");
329                 }
330
331                 [Test]
332                 public void TestEvaluatedItems2 ()
333                 {
334                         Engine engine;
335                         Project project;
336
337                         string documentString = @"
338                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
339                                         <ItemGroup>
340                                                 <A Include='a;b;c' />
341                                         </ItemGroup>
342                                 </Project>
343                         ";
344
345                         engine = new Engine (Consts.BinPath);
346                         project = engine.CreateNewProject ();
347                         project.LoadXml (documentString);
348
349                         BuildItemGroup [] big = new BuildItemGroup [1];
350                         project.ItemGroups.CopyTo (big, 0);
351
352                         Assert.AreEqual (3, project.EvaluatedItems.Count, "A1");
353                         Assert.AreEqual ("a;b;c", big [0] [0].Include, "A2");
354                         Assert.AreEqual (1, big [0].Count, "A3");
355
356                         BuildItem bi = project.EvaluatedItems [0];
357
358                         bi.Include = "d";
359
360                         Assert.AreEqual (3, big [0].Count, "A4");
361                         Assert.AreEqual ("d", big [0] [0].Include, "A5");
362                         Assert.AreEqual ("b", big [0] [1].Include, "A6");
363                         Assert.AreEqual ("c", big [0] [2].Include, "A7");
364                 }
365
366                 [Test]
367                 [Category ("NotWorking")]
368                 public void TestGetConditionedPropertyValues ()
369                 {
370                         Engine engine;
371                         Project project;
372
373                         string documentString = @"
374                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
375                                         <PropertyGroup Condition='true'>
376                                                 <A>A</A>
377                                                 <B Condition='true'>A</B>
378                                         </PropertyGroup>
379                                         <PropertyGroup>
380                                                 <C Condition='true'>A</C>
381                                                 <C Condition='false'>B</C>
382                                                 <C Condition='!false'>C</C>
383                                                 <D>A</D>
384                                                 <E Condition="" '$(C)' == 'A' "">E</E>
385                                         </PropertyGroup>
386                                 </Project>
387                         ";
388
389                         engine = new Engine (Consts.BinPath);
390                         project = engine.CreateNewProject ();
391                         project.LoadXml (documentString);
392
393                         Assert.AreEqual (0, project.GetConditionedPropertyValues ("A").Length, "A1");
394                         Assert.AreEqual (0, project.GetConditionedPropertyValues ("B").Length, "A2");
395                         Assert.AreEqual (1, project.GetConditionedPropertyValues ("C").Length, "A3");
396                         Assert.AreEqual (0, project.GetConditionedPropertyValues ("D").Length, "A4");
397                         Assert.AreEqual (0, project.GetConditionedPropertyValues ("E").Length, "A5");
398                         Assert.AreEqual ("A", project.GetConditionedPropertyValues ("C") [0], "A6");
399                 }
400
401                 [Test]
402                 [ExpectedException (typeof (ArgumentNullException))]
403                 public void TestGetEvaluatedItemsByName1 ()
404                 {
405                         Engine engine;
406                         Project project;
407
408                         string documentString = @"
409                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
410                                 </Project>
411                         ";
412
413                         engine = new Engine (Consts.BinPath);
414                         project = engine.CreateNewProject ();
415                         project.LoadXml (documentString);
416
417                         project.GetEvaluatedItemsByName (null);
418                 }
419
420                 [Test]
421                 public void TestGetEvaluatedItemsByName2 ()
422                 {
423                         Engine engine;
424                         Project project;
425
426                         string documentString = @"
427                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
428                                         <ItemGroup>
429                                                 <A Include='1' />
430                                                 <B Include='2' Condition='true' />
431                                                 <C Include='3' Condition='false' />
432                                         </ItemGroup>
433                                 </Project>
434                         ";
435
436                         engine = new Engine (Consts.BinPath);
437                         project = engine.CreateNewProject ();
438                         project.LoadXml (documentString);
439
440                         BuildItemGroup big;
441
442                         big = project.GetEvaluatedItemsByName (String.Empty);
443
444                         Assert.AreEqual (0, big.Count, "A1");
445
446                         big = project.GetEvaluatedItemsByName ("A");
447
448                         Assert.AreEqual (1, big.Count, "A2");
449                         Assert.AreEqual ("1", big [0].FinalItemSpec, "A3");
450
451                         big = project.GetEvaluatedItemsByName ("B");
452
453                         Assert.AreEqual (1, big.Count, "A4");
454                         Assert.AreEqual ("2", big [0].FinalItemSpec, "A5");
455
456                         big = project.GetEvaluatedItemsByName ("C");
457
458                         Assert.AreEqual (0, big.Count, "A6");
459                 }
460
461                 [Test]
462                 [ExpectedException (typeof (ArgumentNullException))]
463                 public void TestGetEvaluatedItemsByNameIgnoringCondition1 ()
464                 {
465                         Engine engine;
466                         Project project;
467
468                         string documentString = @"
469                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
470                                 </Project>
471                         ";
472
473                         engine = new Engine (Consts.BinPath);
474                         project = engine.CreateNewProject ();
475                         project.LoadXml (documentString);
476
477                         project.GetEvaluatedItemsByNameIgnoringCondition (null);
478                 }
479
480                 [Test]
481                 public void TestGetEvaluatedItemsByNameIgnoringCondition2 ()
482                 {
483                         Engine engine;
484                         Project project;
485
486                         string documentString = @"
487                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
488                                         <ItemGroup>
489                                                 <A Include='1' />
490                                                 <B Include='2' Condition='true' />
491                                                 <C Include='3' Condition='false' />
492                                         </ItemGroup>
493                                 </Project>
494                         ";
495
496                         engine = new Engine (Consts.BinPath);
497                         project = engine.CreateNewProject ();
498                         project.LoadXml (documentString);
499
500                         BuildItemGroup big;
501
502                         big = project.GetEvaluatedItemsByNameIgnoringCondition (String.Empty);
503
504                         Assert.AreEqual (0, big.Count, "A1");
505
506                         big = project.GetEvaluatedItemsByNameIgnoringCondition ("A");
507
508                         Assert.AreEqual (1, big.Count, "A2");
509                         Assert.AreEqual ("1", big [0].FinalItemSpec, "A3");
510
511                         big = project.GetEvaluatedItemsByNameIgnoringCondition ("B");
512
513                         Assert.AreEqual (1, big.Count, "A4");
514                         Assert.AreEqual ("2", big [0].FinalItemSpec, "A5");
515
516                         big = project.GetEvaluatedItemsByNameIgnoringCondition ("C");
517
518                         Assert.AreEqual (1, big.Count, "A6");
519                         Assert.AreEqual ("3", big [0].FinalItemSpec, "A7");
520                 }
521
522                 [Test]
523                 [ExpectedException (typeof (ArgumentNullException))]
524                 public void TestGetEvaluatedProperty1 ()
525                 {
526                         Engine engine;
527                         Project project;
528
529                         string documentString = @"
530                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
531                                 </Project>
532                         ";
533
534                         engine = new Engine (Consts.BinPath);
535                         project = engine.CreateNewProject ();
536                         project.LoadXml (documentString);
537
538                         project.GetEvaluatedProperty (null);
539                 }
540                 [Test]
541                 public void TestGetEvaluatedProperty2 ()
542                 {
543                         Engine engine;
544                         Project project;
545
546                         string documentString = @"
547                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
548                                         <PropertyGroup>
549                                                 <A>1</A>
550                                                 <B Condition='true'>2</B>
551                                                 <C Condition='false'>3</C>
552                                         </PropertyGroup>
553                                 </Project>
554                         ";
555
556                         engine = new Engine (Consts.BinPath);
557                         project = engine.CreateNewProject ();
558                         project.LoadXml (documentString);
559
560                         Assert.AreEqual ("1", project.GetEvaluatedProperty ("A"), "A1");
561                         Assert.AreEqual ("2", project.GetEvaluatedProperty ("B"), "A2");
562                         Assert.IsNull (project.GetEvaluatedProperty ("C"), "A3");
563                 }
564
565                 [Test]
566                 public void TestGetProjectExtensions ()
567                 {
568                         Engine engine;
569                         Project project;
570
571                         string documentString = @"
572                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
573                                         <ProjectExtensions>
574                                                 <Node>Text</Node>
575                                         </ProjectExtensions>
576                                 </Project>
577                         ";
578
579                         engine = new Engine (Consts.BinPath);
580                         project = engine.CreateNewProject ();
581                         project.LoadXml (documentString);
582
583                         Assert.AreEqual (String.Empty, project.GetProjectExtensions (null), "A1");
584                         Assert.AreEqual (String.Empty, project.GetProjectExtensions (String.Empty), "A2");
585                         Assert.AreEqual (String.Empty, project.GetProjectExtensions ("something"), "A3");
586                         Assert.AreEqual ("Text", project.GetProjectExtensions ("Node"), "A4");
587                 }
588
589                 [Test]
590                 public void TestGlobalProperties1 ()
591                 {
592                         Engine engine;
593                         Project project;
594                         
595                         string documentString = @"
596                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
597                                 </Project>
598                         ";
599                         
600                         engine = new Engine (Consts.BinPath);
601                         project = engine.CreateNewProject ();
602                         project.LoadXml (documentString);
603
604                         Assert.AreEqual (0, project.GlobalProperties.Count, "A1");
605                 }
606
607                 [Test]
608                 public void TestGlobalProperties2 ()
609                 {
610                         Engine engine;
611                         Project project;
612                         
613                         string documentString = @"
614                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
615                                 </Project>
616                         ";
617                         
618                         engine = new Engine (Consts.BinPath);
619                         engine.GlobalProperties.SetProperty ("Property", "Value");
620                         
621                         project = engine.CreateNewProject ();
622                         project.LoadXml (documentString);
623
624                         Assert.AreEqual (1, project.GlobalProperties.Count, "A1");
625                         Assert.AreEqual ("Property", project.GlobalProperties ["Property"].Name, "A2");
626                         Assert.AreEqual ("Value", project.GlobalProperties ["Property"].Value, "A3");
627                         Assert.AreEqual ("Value", project.GlobalProperties ["Property"].FinalValue, "A4");
628                         Assert.AreEqual ("Property", project.EvaluatedProperties ["Property"].Name, "A2");
629                         Assert.AreEqual ("Value", project.EvaluatedProperties ["Property"].Value, "A3");
630                         Assert.AreEqual ("Value", project.EvaluatedProperties ["Property"].FinalValue, "A4");
631                 }
632
633                 [Test]
634                 [Ignore ("NullRefException under MS .NET 2.0")]
635                 public void TestGlobalProperties3 ()
636                 {
637                         Engine engine;
638                         Project project;
639                         
640                         string documentString = @"
641                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
642                                 </Project>
643                         ";
644                         
645                         engine = new Engine (Consts.BinPath);
646                         project = engine.CreateNewProject ();
647                         project.LoadXml (documentString);
648
649                         project.GlobalProperties = null;
650                 }
651
652                 [Test]
653                 [Ignore ("NullRefException under MS .NET 2.0")]
654                 public void TestGlobalProperties4 ()
655                 {
656                         Engine engine;
657                         Project project;
658                         
659                         string documentString = @"
660                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
661                                         <PropertyGroup>
662                                                 <Property>a</Property>
663                                         </PropertyGroup>
664                                 </Project>
665                         ";
666                         
667                         engine = new Engine (Consts.BinPath);
668                         project = engine.CreateNewProject ();
669                         project.LoadXml (documentString);
670
671                         BuildPropertyGroup[] groups = new BuildPropertyGroup [1];
672                         project.PropertyGroups.CopyTo (groups, 0);
673
674                         project.GlobalProperties = groups [0];
675                         project.GlobalProperties = project.EvaluatedProperties;
676                 }
677
678                 [Test]
679                 [Category ("NotWorking")]
680                 public void TestGlobalProperties5 ()
681                 {
682                         Engine engine;
683                         Project project;
684                         
685                         string documentString = @"
686                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
687                                         <PropertyGroup>
688                                                 <Property>a</Property>
689                                         </PropertyGroup>
690                                 </Project>
691                         ";
692                         
693                         engine = new Engine (Consts.BinPath);
694                         project = engine.CreateNewProject ();
695                         project.LoadXml (documentString);
696
697                         BuildPropertyGroup[] groups = new BuildPropertyGroup [1];
698                         project.PropertyGroups.CopyTo (groups, 0);
699                         project.GlobalProperties = groups [0];
700                 }
701
702                 [Test]
703                 [ExpectedException (typeof (InvalidProjectFileException))]
704                 public void TestLoad1 ()
705                 {
706                         Engine engine;
707                         Project project;
708
709                         string documentString = @"
710                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
711                                         <PropertyGroup>
712                                 </Project>
713                         ";
714
715                         engine = new Engine (Consts.BinPath);
716                         project = engine.CreateNewProject ();
717                         project.LoadXml (documentString);
718                 }
719
720                 [Test]
721                 [ExpectedException (typeof (InvalidProjectFileException))]
722                 public void TestLoad2 ()
723                 {
724                         Engine engine;
725                         Project project;
726
727                         engine = new Engine (Consts.BinPath);
728                         project = engine.CreateNewProject ();
729                         project.LoadXml ("project_file_that_doesnt_exist");
730                 }
731
732                 [Test]
733                 public void TestParentEngine ()
734                 {
735                         Engine engine;
736                         Project project;
737                         
738                         engine = new Engine (Consts.BinPath);
739                         project = engine.CreateNewProject ();
740
741                         Assert.AreEqual (engine, project.ParentEngine, "A1");
742                 }
743
744                 [Test]
745                 [Category ("NotWorking")]
746                 public void TestResetBuildStatus ()
747                 {
748                         Engine engine;
749                         Project project;
750
751                         string documentString = @"
752                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
753                                         <Target Name='T' Inputs='Test\resources\TestTasks.cs' Outputs='Test\resources\TestTasks.dll'>
754                                                 <Message Text='text' />
755                                         </Target>
756                                 </Project>
757                         ";
758
759                         engine = new Engine (Consts.BinPath);
760                         TestLogger tl = new TestLogger ();
761                         engine.RegisterLogger (tl);
762                         project = engine.CreateNewProject ();
763                         project.LoadXml (documentString);
764
765                         project.Build ("T");
766                         project.ResetBuildStatus ();
767                         project.Build (new string [1] { "T" }, null, BuildSettings.DoNotResetPreviouslyBuiltTargets);
768
769                         Assert.AreEqual (2, tl.TargetStartedEvents, "A1");
770                         Assert.AreEqual (2, tl.TargetFinishedEvents, "A1");
771                 }
772                 
773                 [Test]
774                 public void TestSchemaFile ()
775                 {
776                         Engine engine;
777                         Project project;
778                         
779                         string documentString = @"
780                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
781                                 </Project>
782                         ";
783                         
784                         engine = new Engine (Consts.BinPath);
785                         project = engine.CreateNewProject ();
786                         project.LoadXml (documentString);
787
788                         Assert.IsNull (project.SchemaFile, "A1");
789                 }
790                 [Test]
791                 [Ignore ("NRE on .NET 2.0")]
792                 public void TestSetProjectExtensions1 ()
793                 {
794                         Engine engine;
795                         Project project;
796
797                         string documentString = @"
798                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
799                                 </Project>
800                         ";
801
802                         engine = new Engine (Consts.BinPath);
803                         project = engine.CreateNewProject ();
804                         project.LoadXml (documentString);
805
806                         project.SetProjectExtensions (null, null);
807                 }
808
809                 [Test]
810                 public void TestSetProjectExtensions2 ()
811                 {
812                         Engine engine;
813                         Project project;
814
815                         string documentString = @"
816                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
817                                 </Project>
818                         ";
819
820                         engine = new Engine (Consts.BinPath);
821                         project = engine.CreateNewProject ();
822                         project.LoadXml (documentString);
823
824                         project.SetProjectExtensions ("name", "1");
825                         Assert.AreEqual ("1", project.GetProjectExtensions ("name"), "A1");
826                         project.SetProjectExtensions ("name", "2");
827                         Assert.AreEqual ("2", project.GetProjectExtensions ("name"), "A2");
828                         Assert.IsTrue (project.IsDirty, "A3");
829                 }
830
831                 [Test]
832                 public void TestSetProjectExtensions3 ()
833                 {
834                         Engine engine;
835                         Project project;
836
837                         string documentString = @"
838                                 <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
839                                         <ProjectExtensions>
840                                         </ProjectExtensions>
841                                 </Project>
842                         ";
843
844                         engine = new Engine (Consts.BinPath);
845                         project = engine.CreateNewProject ();
846                         project.LoadXml (documentString);
847
848                         project.SetProjectExtensions ("name", "1");
849                         Assert.AreEqual ("1", project.GetProjectExtensions ("name"), "A1");
850                         Assert.IsTrue (project.IsDirty, "A2");
851                 }
852         }
853 }