Author: msierad
Date: 2007-01-14 16:18:43 -0500 (Sun, 14 Jan 2007)
New Revision: 70993
Modified:
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/BuildItemGroupTest.cs
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ChangeLog
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ProjectTest.cs
Log:
2007-01-14 Marek Sieradzki <[EMAIL PROTECTED]>
* BuildItemGroupTest.cs, ProjectTest.cs: Added more tests.
Modified:
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/BuildItemGroupTest.cs
===================================================================
---
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/BuildItemGroupTest.cs
2007-01-14 17:46:15 UTC (rev 70992)
+++
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/BuildItemGroupTest.cs
2007-01-14 21:18:43 UTC (rev 70993)
@@ -522,6 +522,39 @@
}
[Test]
+ public void TestRemoveItem3 ()
+ {
+ Engine engine;
+ Project project;
+ XmlDocument xd;
+ XmlNode node;
+
+ string documentString = @"
+ <Project
xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
+ <ItemGroup>
+ <A Include='B'/>
+ </ItemGroup>
+ </Project>
+ ";
+
+ engine = new Engine (Consts.BinPath);
+ project = engine.CreateNewProject ();
+ project.LoadXml (documentString);
+
+ BuildItemGroup [] groups = new BuildItemGroup [1];
+ project.ItemGroups.CopyTo (groups, 0);
+
+ groups [0].RemoveItem (groups [0] [0]);
+ Assert.AreEqual (0, groups [0].Count, "A1");
+ Assert.AreEqual (1, project.ItemGroups.Count, "A2");
+
+ xd = new XmlDocument ();
+ xd.LoadXml (project.Xml);
+ node = xd.SelectSingleNode
("tns:Project/tns:ItemGroup/tns:A", TestNamespaceManager.NamespaceManager);
+ Assert.IsNull (node, "A3");
+ }
+
+ [Test]
public void TestRemoveItemAt1 ()
{
BuildItemGroup big = new BuildItemGroup ();
@@ -565,6 +598,42 @@
}
[Test]
+ public void TestRemoveItemAt4 ()
+ {
+ Engine engine;
+ Project project;
+ XmlDocument xd;
+ XmlNode node;
+
+ string documentString = @"
+ <Project
xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
+ <ItemGroup>
+ <A Include='D'/>
+ <B Include='D'/>
+ <C Include='D'/>
+ </ItemGroup>
+ </Project>
+ ";
+
+ engine = new Engine (Consts.BinPath);
+ project = engine.CreateNewProject ();
+ project.LoadXml (documentString);
+
+ BuildItemGroup [] groups = new BuildItemGroup [1];
+ project.ItemGroups.CopyTo (groups, 0);
+
+ groups [0].RemoveItemAt (1);
+ Assert.AreEqual (2, groups [0].Count, "A1");
+ Assert.AreEqual (1, project.ItemGroups.Count, "A2");
+
+ xd = new XmlDocument ();
+ xd.LoadXml (project.Xml);
+ node = xd.SelectSingleNode
("tns:Project/tns:ItemGroup/tns:B", TestNamespaceManager.NamespaceManager);
+ Assert.IsNull (node, "A3");
+ Assert.IsTrue (project.IsDirty, "A4");
+ }
+
+ [Test]
public void TestToArray1 ()
{
BuildItemGroup big = new BuildItemGroup ();
Modified:
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ChangeLog
===================================================================
---
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ChangeLog
2007-01-14 17:46:15 UTC (rev 70992)
+++
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ChangeLog
2007-01-14 21:18:43 UTC (rev 70993)
@@ -1,3 +1,7 @@
+2007-01-14 Marek Sieradzki <[EMAIL PROTECTED]>
+
+ * BuildItemGroupTest.cs, ProjectTest.cs: Added more tests.
+
2007-01-12 Marek Sieradzki <[EMAIL PROTECTED]>
* ProjectTest.cs, BuildPropertyGroupTest.cs: Enable more tests.
Modified:
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ProjectTest.cs
===================================================================
---
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ProjectTest.cs
2007-01-14 17:46:15 UTC (rev 70992)
+++
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ProjectTest.cs
2007-01-14 21:18:43 UTC (rev 70993)
@@ -776,7 +776,131 @@
}
[Test]
+ [Ignore ("NullRefException on MS .NET 2.0")]
+ public void TestRemoveItemGroup1 ()
+ {
+ Engine engine;
+ Project p1;
+
+ engine = new Engine (Consts.BinPath);
+ p1 = engine.CreateNewProject ();
+
+ p1.RemoveItemGroup (null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (InvalidOperationException),
+ "The \"BuildItemGroup\" object
specified does not belong to the correct \"Project\" object.")]
[Category ("NotWorking")]
+ public void TestRemoveItemGroup2 ()
+ {
+ Engine engine;
+ Project p1;
+ Project p2;
+ BuildItemGroup [] groups = new BuildItemGroup [1];
+
+ engine = new Engine (Consts.BinPath);
+ p1 = engine.CreateNewProject ();
+ p2 = engine.CreateNewProject ();
+
+ p1.AddNewItem ("A", "B");
+ p1.ItemGroups.CopyTo (groups, 0);
+
+ p2.RemoveItemGroup (groups [0]);
+ }
+
+ [Test]
+ [Ignore ("NullRefException on MS .NET 2.0")]
+ public void TestRemoveItem1 ()
+ {
+ Engine engine;
+ Project project;
+
+ engine = new Engine (Consts.BinPath);
+ project = engine.CreateNewProject ();
+
+ project.RemoveItem (null);
+ }
+
+ [Test]
+ [ExpectedException (typeof (InvalidOperationException),
+ "The object passed in is not part of the project.")]
+ public void TestRemoveItem2 ()
+ {
+ Engine engine;
+ Project project;
+
+ engine = new Engine (Consts.BinPath);
+ project = engine.CreateNewProject ();
+
+ project.RemoveItem (new BuildItem ("name", "include"));
+ }
+
+ [Test]
+ [ExpectedException (typeof (InvalidOperationException),
+ "The \"BuildItemGroup\" object
specified does not belong to the correct \"Project\" object.")]
+ [Category ("NotWorking")]
+ public void TestRemoveItem3 ()
+ {
+ Engine engine;
+ Project p1;
+ Project p2;
+
+ engine = new Engine (Consts.BinPath);
+ p1 = engine.CreateNewProject ();
+ p2 = engine.CreateNewProject ();
+
+ p1.AddNewItem ("A", "B");
+
+ p2.RemoveItem (p1.EvaluatedItems [0]);
+ }
+
+ [Test]
+ [Ignore ("Should throw an exception")]
+ public void TestRemoveItem4 ()
+ {
+ Engine engine;
+ Project p1;
+ Project p2;
+
+ engine = new Engine (Consts.BinPath);
+ p1 = engine.CreateNewProject ();
+ p2 = engine.CreateNewProject ();
+
+ p1.AddNewItem ("A", "B");
+ p1.AddNewItem ("A", "C");
+
+ p2.RemoveItem (p1.EvaluatedItems [0]);
+ }
+
+ [Test]
+ public void TestRemoveItem5 ()
+ {
+ Engine engine;
+ Project project;
+ BuildItemGroup [] groups = new BuildItemGroup [1];
+
+ string documentString = @"
+ <Project
xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
+ <ItemGroup>
+ <A Include='a'/>
+ </ItemGroup>
+ </Project>
+ ";
+
+ engine = new Engine (Consts.BinPath);
+ project = engine.CreateNewProject ();
+ project.LoadXml (documentString);
+
+ project.RemoveItem (project.EvaluatedItems [0]);
+ Assert.AreEqual (0, project.EvaluatedItems.Count, "A1");
+ project.ItemGroups.CopyTo (groups, 0);
+ Assert.IsNull (groups [0], "A2");
+ Assert.AreEqual (0, project.ItemGroups.Count, "A3");
+ }
+
+ [Test]
+ [Category ("NotWorking")]
public void TestResetBuildStatus ()
{
Engine engine;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches