Author: msierad
Date: 2007-01-12 04:56:48 -0500 (Fri, 12 Jan 2007)
New Revision: 70907

Modified:
   
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/BuildItemTest.cs
   
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/BuildPropertyGroupTest.cs
   
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ChangeLog
   
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ProjectTest.cs
   
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/TargetCollectionTest.cs
   
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/TargetTest.cs
Log:
2007-01-12  Marek Sieradzki  <[EMAIL PROTECTED]>

        * BuildItemTest.cs, BuildPropertyGroupTest.cs, TargetTest.cs,
        TargetCollectionTest.cs, ProjectTest.cs: More tests.



Modified: 
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/BuildItemTest.cs
===================================================================
--- 
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/BuildItemTest.cs
    2007-01-12 09:55:43 UTC (rev 70906)
+++ 
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/BuildItemTest.cs
    2007-01-12 09:56:48 UTC (rev 70907)
@@ -603,6 +603,7 @@
                }
 
                [Test]
+               [Category ("NotWorking")]
                public void TestRemoveMetadata6 ()
                {
                        Engine engine;
@@ -679,6 +680,7 @@
                }
 
                [Test]
+               [Category ("NotWorking")]
                public void TestSetMetadata5 ()
                {
                        Engine engine;

Modified: 
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/BuildPropertyGroupTest.cs
===================================================================
--- 
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/BuildPropertyGroupTest.cs
   2007-01-12 09:55:43 UTC (rev 70906)
+++ 
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/BuildPropertyGroupTest.cs
   2007-01-12 09:56:48 UTC (rev 70907)
@@ -27,6 +27,7 @@
 
 using System;
 using System.Collections;
+using System.Collections.Generic;
 using System.Xml;
 using Microsoft.Build.BuildEngine;
 using Microsoft.Build.Framework;
@@ -40,6 +41,14 @@
                BuildPropertyGroup      bpg;
                Engine                  engine;
                Project                 project;
+
+               BuildProperty [] GetProperties (BuildPropertyGroup bpg)
+               {
+                       List<BuildProperty> list = new List<BuildProperty> ();
+                       foreach (BuildProperty bp in bpg)
+                               list.Add (bp);
+                       return list.ToArray ();
+               }
                
                [Test]
                public void TestAssignment ()
@@ -78,11 +87,12 @@
                }
 
                [Test]
+               [Category ("NotWorking")]
                public void TestAddNewProperty3 ()
                {
                        Engine engine;
                        Project project;
-                       BuildPropertyGroup [] groups = new BuildPropertyGroup 
[1];
+                       BuildPropertyGroup [] groups = new BuildPropertyGroup 
[2];
                        XmlDocument xd;
                        XmlNode node;
 
@@ -90,6 +100,9 @@
                                <Project 
xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
                                        <PropertyGroup>
                                        </PropertyGroup>
+                                       <PropertyGroup>
+                                               <B>$(A)</B>
+                                       </PropertyGroup>
                                </Project>
                        ";
 
@@ -98,17 +111,20 @@
                        project.LoadXml (documentString);
 
                        project.PropertyGroups.CopyTo (groups, 0);
-                       groups [0].AddNewProperty ("a", "b");
+                       Assert.AreEqual ("", project.EvaluatedProperties 
["B"].FinalValue, "A0");
+                       groups [0].AddNewProperty ("A", "A");
 
                        Assert.AreEqual (1, groups [0].Count, "A1");
-                       Assert.AreEqual ("b", project.EvaluatedProperties 
["a"].FinalValue, "A2");
+                       Assert.AreEqual ("A", project.EvaluatedProperties 
["A"].FinalValue, "A2");
+                       Assert.AreEqual ("A", project.EvaluatedProperties 
["B"].FinalValue, "A3");
 
                        xd = new XmlDocument ();
                        xd.LoadXml (project.Xml);
-                       node = xd.SelectSingleNode 
("/tns:Project/tns:PropertyGroup/tns:a", TestNamespaceManager.NamespaceManager);
-                       Assert.IsNotNull (node, "A3");
+                       node = xd.SelectSingleNode 
("/tns:Project/tns:PropertyGroup/tns:A", TestNamespaceManager.NamespaceManager);
+                       Assert.IsNotNull (node, "A4");
                }
 
+               // FIXME: what was that supposed to test?
                [Test]
                [ExpectedException (typeof (InvalidOperationException),
                        "Properties in persisted property groups cannot be 
accessed by name.")]
@@ -187,6 +203,26 @@
                }
 
                [Test]
+               public void TestCondition3 ()
+               {
+                       string documentString = @"
+                                <Project 
xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"";>
+                                       <PropertyGroup>
+                                       </PropertyGroup>
+                                </Project>
+                        ";
+
+                       engine = new Engine (Consts.BinPath);
+                       project = engine.CreateNewProject ();
+                       project.LoadXml (documentString);
+                       BuildPropertyGroup [] array = new BuildPropertyGroup 
[1];
+                       project.PropertyGroups.CopyTo (array, 0);
+
+                       array [0].Condition = "true";
+                       Assert.AreEqual ("true", array [0].Condition, "A1");
+               }
+
+               [Test]
                public void TestGetEnumerator1 ()
                {
                        BuildPropertyGroup bpg = new BuildPropertyGroup ();
@@ -247,6 +283,8 @@
                        Assert.AreEqual ("a", bpg ["a"].Name, "A1");
                        Assert.AreEqual ("b", bpg ["b"].Name, "A2");
                        Assert.IsNull (bpg ["something_that_doesnt_exist"], 
"A3");
+                       bpg ["a"].Value = "3";
+                       Assert.AreEqual ("3", bpg ["a"].Value, "A4");
                }
 
                [Test]
@@ -273,6 +311,29 @@
                }
 
                [Test]
+               [ExpectedException (typeof (InvalidOperationException),
+                       "Properties in persisted property groups cannot be 
accessed by name.")]
+               public void TestIndexer3 ()
+               {
+                       string documentString = @"
+                                <Project 
xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"";>
+                                       <PropertyGroup>
+                                               <a>1</a>
+                                               <b>2</b>
+                                       </PropertyGroup>
+                                </Project>
+                        ";
+
+                       engine = new Engine (Consts.BinPath);
+                       project = engine.CreateNewProject ();
+                       project.LoadXml (documentString);
+                       BuildPropertyGroup [] array = new BuildPropertyGroup 
[1];
+                       project.PropertyGroups.CopyTo (array, 0);
+
+                       array [0] ["a"].Value = "3";
+               }
+
+               [Test]
                [Ignore ("NullRefException on MS .NET 2.0")]
                public void TestRemoveProperty1 ()
                {
@@ -299,19 +360,132 @@
                        bpg.SetProperty ("c", "d");
 
                        bpg.RemoveProperty ("value_not_in_group");
+                       bpg.RemoveProperty (new BuildProperty ("name", 
"value"));
+
+                       BuildProperty bp = bpg ["a"];
+
+                       bpg.RemoveProperty (bp);
                }
 
                [Test]
                public void TestRemoveProperty4 ()
                {
-                       BuildPropertyGroup bpg = new BuildPropertyGroup ();
-                       bpg.SetProperty ("a", "b");
-                       bpg.SetProperty ("c", "d");
+                       Engine engine;
+                       Project project;
+                       BuildPropertyGroup [] bpg = new BuildPropertyGroup [1];
+                       XmlDocument xd;
+                       XmlNode node;
 
-                       bpg.RemoveProperty (new BuildProperty ("name", 
"value"));
+                       string documentString = @"
+                               <Project 
xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
+                                       <PropertyGroup>
+                                               <A>A</A>
+                                       </PropertyGroup>
+                               </Project>
+                       ";
+
+                       engine = new Engine (Consts.BinPath);
+                       project = engine.CreateNewProject ();
+                       project.LoadXml (documentString);
+                       project.PropertyGroups.CopyTo (bpg, 0);
+
+                       bpg [0].RemoveProperty ("A");
+                       Assert.AreEqual (0, bpg [0].Count, "A1");
+                       xd = new XmlDocument ();
+                       xd.LoadXml (project.Xml);
+                       node = xd.SelectSingleNode 
("/tns:Project/tns:PropertyGroup/tns:A", TestNamespaceManager.NamespaceManager);
+                       Assert.IsNull (node, "A3");
+
+                       bpg [0].RemoveProperty ("B");
                }
 
                [Test]
+               public void TestRemoveProperty5 ()
+               {
+                       Engine engine;
+                       Project project;
+                       BuildPropertyGroup [] bpg = new BuildPropertyGroup [1];
+                       XmlDocument xd;
+                       XmlNode node;
+                       BuildProperty [] properties;
+
+                       string documentString = @"
+                               <Project 
xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
+                                       <PropertyGroup>
+                                               <A>A</A>
+                                       </PropertyGroup>
+                               </Project>
+                       ";
+
+                       engine = new Engine (Consts.BinPath);
+                       project = engine.CreateNewProject ();
+                       project.LoadXml (documentString);
+                       project.PropertyGroups.CopyTo (bpg, 0);
+
+                       properties = GetProperties (bpg [0]);
+
+                       bpg [0].RemoveProperty (properties [0]);
+                       Assert.AreEqual (0, bpg [0].Count, "A1");
+                       xd = new XmlDocument ();
+                       xd.LoadXml (project.Xml);
+                       node = xd.SelectSingleNode 
("/tns:Project/tns:PropertyGroup/tns:A", TestNamespaceManager.NamespaceManager);
+                       Assert.IsNull (node, "A3");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException),
+                       "The specified property does not belong to the current 
property group.")]
+               public void TestRemoveProperty6 ()
+               {
+                       Engine engine;
+                       Project project;
+                       BuildPropertyGroup [] bpg = new BuildPropertyGroup [1];
+
+                       string documentString = @"
+                               <Project 
xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
+                                       <PropertyGroup>
+                                       </PropertyGroup>
+                               </Project>
+                       ";
+
+                       engine = new Engine (Consts.BinPath);
+                       project = engine.CreateNewProject ();
+                       project.LoadXml (documentString);
+                       project.PropertyGroups.CopyTo (bpg, 0);
+
+                       bpg [0].RemoveProperty (new BuildProperty ("A", "b"));
+               }
+
+               [Test]
+               [Ignore ("It doesn't throw an exception on MS .NET 2.0")]
+               public void TestRemoveProperty7 ()
+               {
+                       Engine engine;
+                       Project project;
+                       BuildPropertyGroup [] bpg = new BuildPropertyGroup [2];
+                       BuildProperty [] properties;
+
+                       string documentString = @"
+                               <Project 
xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
+                                       <PropertyGroup>
+                                               <A></A>
+                                       </PropertyGroup>
+                                       <PropertyGroup>
+                                       </PropertyGroup>
+                               </Project>
+                       ";
+
+                       engine = new Engine (Consts.BinPath);
+                       project = engine.CreateNewProject ();
+                       project.LoadXml (documentString);
+                       project.PropertyGroups.CopyTo (bpg, 0);
+
+                       properties = GetProperties (bpg [0]);
+                       bpg [1].RemoveProperty (properties [0]);
+                       Assert.AreEqual (1, bpg [0].Count, "A1");
+               }
+
+               [Test]
                [ExpectedException (typeof (ArgumentNullException))]
                public void TestSetProperty1 ()
                {

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-12 09:55:43 UTC (rev 70906)
+++ 
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ChangeLog
   2007-01-12 09:56:48 UTC (rev 70907)
@@ -1,3 +1,8 @@
+2007-01-12  Marek Sieradzki  <[EMAIL PROTECTED]>
+
+       * BuildItemTest.cs, BuildPropertyGroupTest.cs, TargetTest.cs,
+       TargetCollectionTest.cs, ProjectTest.cs: More tests.
+
 2007-01-10  Marek Sieradzki  <[EMAIL PROTECTED]>
 
        * BuildPropertyGroupTest.cs, BuildItemGroupTest.cs: Check if XML has

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-12 09:55:43 UTC (rev 70906)
+++ 
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ProjectTest.cs
      2007-01-12 09:56:48 UTC (rev 70907)
@@ -27,6 +27,7 @@
 
 using System;
 using System.Collections;
+using System.Collections.Generic;
 using System.Xml;
 using Microsoft.Build.BuildEngine;
 using Microsoft.Build.Framework;
@@ -73,6 +74,16 @@
        [TestFixture]
        public class ProjectTest {
 
+               /*
+               Import [] GetImports (ImportCollection ic)
+               {
+                       List<Import> list = new List<Import> ();
+                       foreach (Import i in ic)
+                               list.Add (i);
+                       return list.ToArray ();
+               }
+               */
+
                [Test]
                [ExpectedException (typeof (InvalidProjectFileException),
                @"The default XML namespace of the project must be the MSBuild 
XML namespace." + 
@@ -126,6 +137,31 @@
 
                [Test]
                [Category ("NotWorking")]
+               public void TestAddNewImport1 ()
+               {
+                       Engine engine;
+                       Project project;
+
+                       string documentString = @"
+                               <Project 
xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
+                                       <PropertyGroup />
+                                       <ItemGroup />
+                                       <Target Name='a' />
+                                       <Import 
Project='Test/resources/Import.csproj' />
+                               </Project>
+                       ";
+
+                       engine = new Engine (Consts.BinPath);
+                       project = engine.CreateNewProject ();
+                       project.LoadXml (documentString);
+
+                       project.AddNewImport ("a", "true");
+                       // reevaluation wasn't caused by anything so it has 
only old import
+                       Assert.AreEqual (1, project.Imports.Count, "A1");
+               }
+
+               [Test]
+               [Category ("NotWorking")]
                public void TestAddNewItemGroup ()
                {
                        Engine engine;

Modified: 
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/TargetCollectionTest.cs
===================================================================
--- 
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/TargetCollectionTest.cs
     2007-01-12 09:55:43 UTC (rev 70906)
+++ 
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/TargetCollectionTest.cs
     2007-01-12 09:56:48 UTC (rev 70907)
@@ -97,6 +97,35 @@
                }
 
                [Test]
+               public void TestAddNewTarget3 ()
+               {
+                       engine = new Engine (Consts.BinPath);
+
+                       project = engine.CreateNewProject ();
+
+                       project.Targets.AddNewTarget ("Name");
+                       project.Targets.AddNewTarget ("Name");
+                       Assert.AreEqual (1, project.Targets.Count, "A1");
+               }
+
+               [Test]
+               public void TestAddNewTarget4 ()
+               {
+                       string documentString = @"
+                                <Project 
xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"";>
+                                       <Target Name='A' />
+                                       <Target Name='A' />
+                                </Project>
+                        ";
+
+                       engine = new Engine (Consts.BinPath);
+
+                       project = engine.CreateNewProject ();
+                       project.LoadXml (documentString);
+                       Assert.AreEqual (1, project.Targets.Count, "A1");
+               }
+
+               [Test]
                [ExpectedException (typeof (ArgumentNullException))]
                public void TestCopyTo1 ()
                {

Modified: 
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/TargetTest.cs
===================================================================
--- 
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/TargetTest.cs
       2007-01-12 09:55:43 UTC (rev 70906)
+++ 
trunk/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/TargetTest.cs
       2007-01-12 09:56:48 UTC (rev 70907)
@@ -165,6 +165,27 @@
                }
 
                [Test]
+               [ExpectedException (typeof (InvalidProjectFileException))]
+               public void TestOnError1 ()
+               {
+                       Engine engine;
+                       Project project;
+
+                       string documentString = @"
+                               <Project 
xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
+                                       <Target Name='A'>
+                                               <OnError ExecuteTargets='B' />
+                                               <Error Text='text' />
+                                       </Target>
+                               </Project>
+                       ";
+
+                       engine = new Engine (Consts.BinPath);
+                       project = engine.CreateNewProject ();
+                       project.LoadXml (documentString);
+               }
+
+               [Test]
                public void TestRemoveTask1 ()
                {
                         string documentString = @"

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to