* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / class / Microsoft.Build.Engine / Test / Microsoft.Build.BuildEngine / BuildPropertyGroupCollectionTest.cs
1 //
2 // BuildPropertyGroupCollectionTest.cs
3 //
4 // Author:
5 //   Marek Sieradzki (marek.sieradzki@gmail.com)
6 //
7 // (C) 2006 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 Microsoft.Build.BuildEngine;
31 using Microsoft.Build.Framework;
32 using Microsoft.Build.Utilities;
33 using NUnit.Framework;
34
35 namespace MonoTests.Microsoft.Build.BuildEngine {
36         [TestFixture]
37         public class BuildPropertyGroupCollectionTest {
38                 
39                 string                  binPath;
40                 Engine                  engine;
41                 Project                 project;
42                 
43                 [SetUp]
44                 public void SetUp ()
45                 {
46                         binPath = "../../tools/xbuild/xbuild";
47                 }
48
49                 /*
50                 [Test]
51                 // NOTE: It's throwing nullrefexception on NET 2.0
52                 [ExpectedException (typeof (ArgumentNullException))]
53                 public void TestCopyTo1 ()
54                 {
55                         string documentString = @"
56                                 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
57                                         <PropertyGroup>
58                                                 <Name>Value</Name>
59                                         </PropertyGroup>
60                                 </Project>
61                         ";
62
63                         engine = new Engine (binPath);
64
65                         project = engine.CreateNewProject ();
66                         project.LoadXml (documentString);
67                         
68                         project.PropertyGroups.CopyTo (null, 0);
69                 }
70                 */
71
72                 [Test]
73                 [ExpectedException (typeof (IndexOutOfRangeException),
74                         "Index was outside the bounds of the array.")]
75                 public void TestCopyTo2 ()
76                 {
77                         string documentString = @"
78                                 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
79                                         <PropertyGroup>
80                                                 <Name>Value</Name>
81                                         </PropertyGroup>
82                                 </Project>
83                         ";
84
85                         engine = new Engine (binPath);
86
87                         project = engine.CreateNewProject ();
88                         project.LoadXml (documentString);
89                         
90                         project.PropertyGroups.CopyTo (new BuildPropertyGroup [1], -1);
91                 }
92
93                 /*
94                 [Test]
95                 // NOTE: that's msbuild's internal error
96                 [ExpectedException (typeof (InvalidCastException))]
97                 public void TestCopyTo3 ()
98                 {
99                         string documentString = @"
100                                 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
101                                         <PropertyGroup>
102                                                 <Name>Value</Name>
103                                         </PropertyGroup>
104                                 </Project>
105                         ";
106
107                         engine = new Engine (binPath);
108
109                         project = engine.CreateNewProject ();
110                         project.LoadXml (documentString);
111                         
112                         project.PropertyGroups.CopyTo (new BuildPropertyGroup [][] { new BuildPropertyGroup [] {
113                                 new BuildPropertyGroup ()}}, 0);
114                 }
115                 */
116
117                 [Test]
118                 [ExpectedException (typeof (IndexOutOfRangeException),
119                         "Index was outside the bounds of the array.")]
120                 public void TestCopyTo4 ()
121                 {
122                         string documentString = @"
123                                 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
124                                         <PropertyGroup>
125                                                 <Name>Value</Name>
126                                         </PropertyGroup>
127                                 </Project>
128                         ";
129
130                         engine = new Engine (binPath);
131
132                         project = engine.CreateNewProject ();
133                         project.LoadXml (documentString);
134                         
135                         project.PropertyGroups.CopyTo (new BuildPropertyGroup [1], 2);
136                 }
137
138                 [Test]
139                 [ExpectedException (typeof (IndexOutOfRangeException),
140                         "Index was outside the bounds of the array.")]
141                 public void TestCopyTo5 ()
142                 {
143                         string documentString = @"
144                                 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
145                                         <PropertyGroup>
146                                                 <Name>Value</Name>
147                                         </PropertyGroup>
148                                 </Project>
149                         ";
150
151                         engine = new Engine (binPath);
152
153                         project = engine.CreateNewProject ();
154                         project.LoadXml (documentString);
155                         
156                         project.PropertyGroups.CopyTo (new BuildPropertyGroup [1], 1);
157                 }
158
159         }
160 }