Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,464 @@
//
// BuildChoose.cs
//
// Author:
// Jonathan Chambers (joncham@gmail.com)
//
// (C) 2009 Jonathan Chambers
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Collections;
using Microsoft.Build.BuildEngine;
using NUnit.Framework;
namespace MonoTests.Microsoft.Build.BuildEngine {
[TestFixture]
public class BuildChooseTest {
[Test]
public void TestEmptyWhen () {
Engine engine;
Project project;
BuildItemGroup[] groups = new BuildItemGroup[1];
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Choose>
<When Condition=""'$(Configuration)' == ''"">
<ItemGroup>
<A Include='a' />
</ItemGroup>
</When>
</Choose>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
//Assert.AreEqual (1, project.ItemGroups.Count, "A1");
Assert.AreEqual (0, project.PropertyGroups.Count, "A2");
Assert.AreEqual (1, project.EvaluatedItems.Count, "A3");
Assert.AreEqual (1, project.EvaluatedItemsIgnoringCondition.Count, "A4");
}
[Test]
public void TestFalseWhen () {
Engine engine;
Project project;
BuildItemGroup[] groups = new BuildItemGroup[1];
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Choose>
<When Condition=""'$(Configuration)' == 'False'"">
<ItemGroup>
<A Include='a' />
</ItemGroup>
</When>
</Choose>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
//Assert.AreEqual (1, project.ItemGroups.Count, "A1");
Assert.AreEqual (0, project.PropertyGroups.Count, "A2");
Assert.AreEqual (0, project.EvaluatedItems.Count, "A3");
Assert.AreEqual (0, project.EvaluatedItemsIgnoringCondition.Count, "A4");
}
[Test]
public void TestMultipleTrueWhen () {
Engine engine;
Project project;
BuildItemGroup[] groups = new BuildItemGroup[1];
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Choose>
<When Condition=""'$(Configuration)' == ''"">
<ItemGroup>
<A Include='a' />
</ItemGroup>
</When>
<When Condition=""'$(Configuration)' == ''"">
<ItemGroup>
<B Include='a' />
</ItemGroup>
</When>
</Choose>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
//Assert.AreEqual (2, project.ItemGroups.Count, "A1");
Assert.AreEqual (0, project.PropertyGroups.Count, "A2");
Assert.AreEqual (1, project.EvaluatedItems.Count, "A3");
Assert.AreEqual ("A", project.EvaluatedItems[0].Name, "A4");
Assert.AreEqual (1, project.EvaluatedItemsIgnoringCondition.Count, "A5");
}
[Test]
public void TestMultipleFalseWhen () {
Engine engine;
Project project;
BuildItemGroup[] groups = new BuildItemGroup[1];
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Choose>
<When Condition=""'$(Configuration)' == 'False'"">
<ItemGroup>
<A Include='a' />
</ItemGroup>
</When>
<When Condition=""'$(Configuration)' == 'False'"">
<ItemGroup>
<B Include='a' />
</ItemGroup>
</When>
</Choose>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
//Assert.AreEqual (2, project.ItemGroups.Count, "A1");
Assert.AreEqual (0, project.PropertyGroups.Count, "A2");
Assert.AreEqual (0, project.EvaluatedItems.Count, "A3");
Assert.AreEqual (0, project.EvaluatedItemsIgnoringCondition.Count, "A4");
}
[Test]
[ExpectedException (typeof (InvalidProjectFileException))]
public void TestMissingWhen () {
Engine engine;
Project project;
BuildItemGroup[] groups = new BuildItemGroup[1];
// a <Choose> requires at least one <When>
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Choose>
<Otherwise>
<ItemGroup>
<A Include='a' />
</ItemGroup>
</Otherwise>
</Choose>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
}
[Test]
[ExpectedException (typeof (InvalidProjectFileException))]
public void TestMissingConditionWhen () {
Engine engine;
Project project;
BuildItemGroup[] groups = new BuildItemGroup[1];
// a <When> requires a Condition
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Choose>
<When>
<ItemGroup>
<A Include='a' />
</ItemGroup>
</When>
</Choose>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
}
[Test]
public void TestWhenOtherwise1 () {
Engine engine;
Project project;
BuildItemGroup[] groups = new BuildItemGroup[1];
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Choose>
<When Condition=""'$(Configuration)' == ''"">
<ItemGroup>
<A Include='a' />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<B Include='a' />
</ItemGroup>
</Otherwise>
</Choose>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
//Assert.AreEqual (2, project.ItemGroups.Count, "A1");
Assert.AreEqual (0, project.PropertyGroups.Count, "A2");
Assert.AreEqual (1, project.EvaluatedItems.Count, "A3");
Assert.AreEqual ("A", project.EvaluatedItems[0].Name, "A4");
Assert.AreEqual (1, project.EvaluatedItemsIgnoringCondition.Count, "A5");
}
[Test]
public void TestWhenOtherwise2 () {
Engine engine;
Project project;
BuildItemGroup[] groups = new BuildItemGroup[1];
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Choose>
<When Condition=""'$(Configuration)' == 'False'"">
<ItemGroup>
<A Include='a' />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<B Include='a' />
</ItemGroup>
</Otherwise>
</Choose>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
//Assert.AreEqual (2, project.ItemGroups.Count, "A1");
Assert.AreEqual (0, project.PropertyGroups.Count, "A2");
Assert.AreEqual (1, project.EvaluatedItems.Count, "A3");
Assert.AreEqual ("B", project.EvaluatedItems[0].Name, "A4");
Assert.AreEqual (1, project.EvaluatedItemsIgnoringCondition.Count, "A5");
}
[Test]
public void ChooseWhenPropertyGroup () {
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Choose>
<When Condition=""'$(Configuration)' == ''"">
<PropertyGroup>
<Foo>Bar</Foo>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<Foo>Baz</Foo>
</PropertyGroup>
</Otherwise>
</Choose>
</Project>
";
Engine engine = new Engine (Consts.BinPath);
Project project = engine.CreateNewProject ();
project.LoadXml (documentString);
Assert.AreEqual ("Bar", project.GetEvaluatedProperty ("Foo"), "A1");
}
[Test]
public void ChooseOtherwisePropertyGroup () {
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Choose>
<When Condition=""'$(Configuration)' == 'dummy'"">
<PropertyGroup>
<Foo>Bar</Foo>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<Foo>Baz</Foo>
</PropertyGroup>
</Otherwise>
</Choose>
</Project>
";
Engine engine = new Engine (Consts.BinPath);
Project project = engine.CreateNewProject ();
project.LoadXml (documentString);
Assert.AreEqual ("Baz", project.GetEvaluatedProperty ("Foo"), "A1");
}
[Test]
public void NestedChooseInOtherwise () {
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Choose>
<When Condition=""'$(Configuration)' == 'dummy'"">
<PropertyGroup>
<Foo>Bar</Foo>
</PropertyGroup>
</When>
<Otherwise>
<Choose>
<When Condition="" 'foo' == 'bar' "">
<PropertyGroup>
<Foo>Baz</Foo>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<Foo>Baz</Foo>
</PropertyGroup>
</Otherwise>
</Choose>
</Otherwise>
</Choose>
</Project>
";
Engine engine = new Engine (Consts.BinPath);
Project project = engine.CreateNewProject ();
project.LoadXml (documentString);
Assert.AreEqual ("Baz", project.GetEvaluatedProperty ("Foo"), "A1");
}
[Test]
public void UndefinedPropertyInExistsCondition()
{
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<PropertyGroup>
<Foo>Bar</Foo>
</PropertyGroup>
<Choose>
<When Condition = "" '$(teamcity_dotnet_nunitlauncher_msbuild_task)' == '' "" >
<Choose>
<When Condition=""Exists('$(UndefinedProperty)\Foo\Bar')"">
<PropertyGroup>
<Exists>yes</Exists>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<Exists>no</Exists>
</PropertyGroup>
</Otherwise>
</Choose>
</When>
</Choose>
</Project>
";
Engine engine = new Engine (Consts.BinPath);
Project project = engine.CreateNewProject ();
project.LoadXml (documentString);
Assert.AreEqual ("no", project.GetEvaluatedProperty ("Exists"), "A1");
}
[Test]
public void EmptyExistsCondition()
{
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Choose>
<When Condition=""Exists('$(UndefinedProperty)')"">
<PropertyGroup>
<Exists>yes</Exists>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<Exists>no</Exists>
</PropertyGroup>
</Otherwise>
</Choose>
</Project>
";
Engine engine = new Engine (Consts.BinPath);
Project project = engine.CreateNewProject ();
//assign a real filename to be used as base path for the Exists
project.FullFileName = typeof (BuildChooseTest).Assembly.Location;
project.LoadXml (documentString);
Assert.AreEqual ("no", project.GetEvaluatedProperty ("Exists"), "A1");
}
[Test]
public void EvaluationOrder ()
{
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Choose>
<When Condition=""true"">
<PropertyGroup>
<Foo>Bar</Foo>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<Foo>Baz</Foo>
</PropertyGroup>
</Otherwise>
</Choose>
<PropertyGroup>
<Test>$(Foo)</Test>
</PropertyGroup>
</Project>
";
Engine engine = new Engine (Consts.BinPath);
Project project = engine.CreateNewProject ();
project.LoadXml (documentString);
Assert.AreEqual ("Bar", project.GetEvaluatedProperty ("Test"));
}
}
}

View File

@@ -0,0 +1,165 @@
//
// BuildItemGroupCollectionTest.cs
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
//
// (C) 2006 Marek Sieradzki
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Collections;
using Microsoft.Build.BuildEngine;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using NUnit.Framework;
namespace MonoTests.Microsoft.Build.BuildEngine {
[TestFixture]
public class BuildItemGroupCollectionTest {
Engine engine;
Project project;
[Test]
[Category ("NotDotNet")]
[ExpectedException (typeof (ArgumentNullException))]
public void TestCopyTo1 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<ItemGroup>
<Name Include='Value' />
</ItemGroup>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
project.ItemGroups.CopyTo (null, 0);
}
[Test]
[ExpectedException (typeof (IndexOutOfRangeException))]
public void TestCopyTo2 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<ItemGroup>
<Name Include='Value' />
</ItemGroup>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
project.ItemGroups.CopyTo (new BuildItemGroup [1], -1);
}
[Test]
[ExpectedException (typeof (InvalidCastException))]
public void TestCopyTo3 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<ItemGroup>
<Name Include='Value' />
</ItemGroup>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
project.ItemGroups.CopyTo (new BuildItemGroup [][] { new BuildItemGroup [] {
new BuildItemGroup ()}}, 0);
}
[Test]
[ExpectedException (typeof (IndexOutOfRangeException))]
public void TestCopyTo4 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<ItemGroup>
<Name Include='Value' />
</ItemGroup>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
project.ItemGroups.CopyTo (new BuildItemGroup [1], 2);
}
[Test]
[ExpectedException (typeof (IndexOutOfRangeException))]
public void TestCopyTo5 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<ItemGroup>
<Name Include='Value' />
</ItemGroup>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
project.ItemGroups.CopyTo (new BuildItemGroup [1], 1);
}
[Test]
[ExpectedException (typeof (IndexOutOfRangeException))]
public void TestCopyTo6 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<ItemGroup>
</ItemGroup>
<ItemGroup>
</ItemGroup>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
project.ItemGroups.CopyTo (new BuildItemGroup [1], 0);
}
}
}

View File

@@ -0,0 +1,168 @@
//
// BuildPropertyGroupCollectionTest.cs
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
//
// (C) 2006 Marek Sieradzki
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Collections;
using Microsoft.Build.BuildEngine;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using NUnit.Framework;
namespace MonoTests.Microsoft.Build.BuildEngine {
[TestFixture]
public class BuildPropertyGroupCollectionTest {
Engine engine;
Project project;
[Test]
[Category ("NotDotNet")]
[ExpectedException (typeof (ArgumentNullException))]
public void TestCopyTo1 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<PropertyGroup>
<Name>Value</Name>
</PropertyGroup>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
project.PropertyGroups.CopyTo (null, 0);
}
// Index was outside the bounds of the array.
[Test]
[ExpectedException (typeof (IndexOutOfRangeException))]
public void TestCopyTo2 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<PropertyGroup>
<Name>Value</Name>
</PropertyGroup>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
project.PropertyGroups.CopyTo (new BuildPropertyGroup [1], -1);
}
[Test]
[ExpectedException (typeof (InvalidCastException))]
public void TestCopyTo3 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<PropertyGroup>
<Name>Value</Name>
</PropertyGroup>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
project.PropertyGroups.CopyTo (new BuildPropertyGroup [][] { new BuildPropertyGroup [] {
new BuildPropertyGroup ()}}, 0);
}
// Index was outside the bounds of the array.
[Test]
[ExpectedException (typeof (IndexOutOfRangeException))]
public void TestCopyTo4 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<PropertyGroup>
<Name>Value</Name>
</PropertyGroup>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
project.PropertyGroups.CopyTo (new BuildPropertyGroup [1], 2);
}
// Index was outside the bounds of the array.
[Test]
[ExpectedException (typeof (IndexOutOfRangeException))]
public void TestCopyTo5 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<PropertyGroup>
<Name>Value</Name>
</PropertyGroup>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
project.PropertyGroups.CopyTo (new BuildPropertyGroup [1], 1);
}
[Test]
[ExpectedException (typeof (IndexOutOfRangeException))]
public void TestCopyTo6 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<PropertyGroup>
</PropertyGroup>
<PropertyGroup>
</PropertyGroup>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
project.PropertyGroups.CopyTo (new BuildPropertyGroup [1], 0);
}
}
}

View File

@@ -0,0 +1,386 @@
//
// BuildPropertyTest.cs
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
//
// (C) 2006 Marek Sieradzki
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Collections;
using System.Xml;
using Microsoft.Build.BuildEngine;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using NUnit.Framework;
namespace MonoTests.Microsoft.Build.BuildEngine {
[TestFixture]
public class BuildPropertyTest {
BuildProperty bp;
Engine engine;
Project project;
BuildProperty [] GetProperties (BuildPropertyGroup bpg)
{
BuildProperty [] arr = new BuildProperty [bpg.Count];
int i = 0;
foreach (BuildProperty bp in bpg)
arr [i++] = bp;
return arr;
}
[Test]
public void TestCtor1 ()
{
string name = "name";
string value = "value";
bp = new BuildProperty (name, value);
Assert.AreEqual (name, bp.Name, "A1");
Assert.AreEqual (value, bp.Value, "A2");
Assert.AreEqual (String.Empty, bp.Condition, "A3");
Assert.AreEqual (value, bp.FinalValue, "A4");
Assert.AreEqual (false, bp.IsImported, "A5");
Assert.AreEqual (value, bp.ToString (), "A6");
name = "name";
value = "$(AnotherProperty)";
bp = new BuildProperty (name, value);
Assert.AreEqual (name, bp.Name, "A7");
Assert.AreEqual (value, bp.Value, "A8");
Assert.AreEqual (String.Empty, bp.Condition, "A9");
Assert.AreEqual (value, bp.FinalValue, "A10");
Assert.AreEqual (false, bp.IsImported, "A11");
Assert.AreEqual (value, bp.ToString (), "A12");
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void TestCtor2 ()
{
bp = new BuildProperty (null, "value");
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void TestCtor3 ()
{
bp = new BuildProperty ("name", null);
}
// A shallow clone of this object cannot be created.
[Test]
[ExpectedException (typeof (InvalidOperationException))]
public void TestClone1 ()
{
bp = new BuildProperty ("name", "value");
bp.Clone (false);
}
[Test]
public void TestClone2 ()
{
bp = new BuildProperty ("name", "value");
bp.Clone (true);
}
[Test]
[Category ("NotWorking")]
public void TestClone3 ()
{
BuildProperty a,b;
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<PropertyGroup>
<Name>Value</Name>
</PropertyGroup>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
a = project.EvaluatedProperties ["Name"];
Assert.AreEqual ("Value", a.Value, "A1");
b = a.Clone (false);
b.Value = "AnotherValue";
Assert.AreEqual ("Value", a.Value, "A2");
}
[Test]
[Category ("NotWorking")]
public void TestClone4 ()
{
BuildProperty a,b;
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<PropertyGroup>
<Name>Value</Name>
</PropertyGroup>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
a = project.EvaluatedProperties ["Name"];
Assert.AreEqual ("Value", a.Value, "A1");
b = a.Clone (true);
b.Value = "AnotherValue";
Assert.AreEqual ("Value", a.Value, "A2");
}
[Test]
[Category ("NotWorking")]
public void TestClone5 ()
{
BuildProperty a,b;
IList properties = new ArrayList ();
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<PropertyGroup>
<Name>Value</Name>
</PropertyGroup>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
foreach (BuildPropertyGroup bpg in project.PropertyGroups)
foreach (BuildProperty bpr in bpg)
properties.Add (bpr);
a = (BuildProperty) properties [0];
Assert.AreEqual ("Value", a.Value, "A1");
b = a.Clone (false);
b.Value = "AnotherValue";
Assert.AreEqual ("Value", a.Value, "A2");
}
[Test]
[Category ("NotWorking")]
public void TestClone6 ()
{
BuildProperty a,b;
IList properties = new ArrayList ();
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<PropertyGroup>
<Name>Value</Name>
</PropertyGroup>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
foreach (BuildPropertyGroup bpg in project.PropertyGroups)
foreach (BuildProperty bpr in bpg)
properties.Add (bpr);
a = (BuildProperty) properties [0];
Assert.AreEqual ("Value", a.Value, "A1");
b = a.Clone (true);
b.Value = "AnotherValue";
Assert.AreEqual ("Value", a.Value, "A2");
}
[Test]
[Category ("NotWorking")]
public void TestCondition1 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<PropertyGroup>
<Name>Value</Name>
</PropertyGroup>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
BuildProperty a = project.EvaluatedProperties ["Name"];
a.Condition = "true";
Assert.AreEqual ("true", a.Condition, "A1");
}
// Cannot set a condition on an object not represented by an XML element in the project file.
[Test]
[ExpectedException (typeof (InvalidOperationException))]
public void TestCondition2 ()
{
BuildProperty a = new BuildProperty ("name", "value");
a.Condition = "true";
}
[Test]
public void TestOpExplicit1 ()
{
bp = new BuildProperty ("name", "value");
Assert.AreEqual ("value", (string) bp, "A1");
}
[Test]
public void TestOpExplicit2 ()
{
BuildProperty bp = null;
Assert.AreEqual (String.Empty, (string) bp, "A1");
}
[Test]
public void TestToString ()
{
bp = new BuildProperty ("name", "a;b");
Assert.AreEqual ("a;b", bp.ToString ());
}
[Test]
public void TestValue1 ()
{
BuildProperty a;
BuildPropertyGroup [] bpgs = new BuildPropertyGroup [1];
BuildProperty [] props;
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<PropertyGroup>
<Name>Value</Name>
</PropertyGroup>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
a = project.EvaluatedProperties ["Name"];
a.Value = "$(something)";
Assert.AreEqual ("$(something)", a.Value, "A1");
project.PropertyGroups.CopyTo (bpgs, 0);
props = GetProperties (bpgs [0]);
Assert.AreEqual ("Value", props [0].Value, "A2");
}
[Test]
public void TestValue2 ()
{
BuildPropertyGroup [] bpgs = new BuildPropertyGroup [1];
BuildProperty [] props;
XmlDocument xd;
XmlNode node;
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<PropertyGroup>
<Name>Value</Name>
</PropertyGroup>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
project.PropertyGroups.CopyTo (bpgs, 0);
props = GetProperties (bpgs [0]);
props [0].Value = "AnotherValue";
xd = new XmlDocument ();
xd.LoadXml (project.Xml);
node = xd.SelectSingleNode ("tns:Project/tns:PropertyGroup/tns:Name", TestNamespaceManager.NamespaceManager);
Assert.AreEqual ("AnotherValue", node.InnerText, "A1");
}
[Test]
[Category ("NotDotNet")]
public void TestValueXml ()
{
BuildPropertyGroup [] bpgs = new BuildPropertyGroup [1];
BuildProperty [] props;
XmlDocument xd;
XmlNode node;
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<PropertyGroup>
<Name>Value</Name>
</PropertyGroup>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
project.PropertyGroups.CopyTo (bpgs, 0);
bpgs[0].AddNewProperty("XmlProp", "<XmlStuff></XmlStuff>");
xd = new XmlDocument ();
xd.LoadXml (project.Xml);
node = xd.SelectSingleNode ("tns:Project/tns:PropertyGroup/tns:XmlProp/tns:XmlStuff", TestNamespaceManager.NamespaceManager);
if (node == null) {
Console.WriteLine (project.Xml);
Assert.Fail ("Expected node to be non-null");
}
}
}
}

View File

@@ -0,0 +1,476 @@
//
// BuildTaskTest.cs
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
//
// (C) 2005 Marek Sieradzki
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Collections;
using System.Collections.Generic;
using Microsoft.Build.BuildEngine;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using NUnit.Framework;
namespace MonoTests.Microsoft.Build.BuildEngine {
[TestFixture]
public class BuildTaskTest {
static BuildTask[] GetTasks (Target t)
{
List <BuildTask> list = new List <BuildTask> ();
foreach (BuildTask bt in t)
list.Add (bt);
return list.ToArray ();
}
[Test]
public void TestFromXml ()
{
Engine engine;
Project project;
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<PropertyGroup>
<Property>true</Property>
</PropertyGroup>
<Target Name='T'>
<Message Text='Text' />
<Message Text='Text' Condition='$(Property)' ContinueOnError='$(Property)' />
</Target>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Target[] t = new Target [1];
BuildTask[] bt;
project.Targets.CopyTo (t, 0);
bt = GetTasks (t [0]);
Assert.AreEqual (String.Empty, bt [0].Condition, "A1");
Assert.IsFalse (bt [0].ContinueOnError, "A2");
Assert.IsNull (bt [0].HostObject, "A3");
Assert.AreEqual ("Message", bt [0].Name, "A4");
Assert.IsNotNull (bt [0].Type, "A5");
Assert.AreEqual ("$(Property)", bt [1].Condition, "A6");
Assert.IsTrue (bt [1].ContinueOnError, "A7");
Assert.IsNull (bt [1].HostObject, "A8");
Assert.AreEqual ("Message", bt [0].Name, "A9");
Assert.IsNotNull (bt [0].Type, "A10");
}
[Test]
public void TestGetParameterNames ()
{
Engine engine;
Project project;
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Target Name='T'>
<Message Text='Text' Importance='low' Condition='true' ContinueOnError='true' />
</Target>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Target[] t = new Target [1];
BuildTask[] bt;
project.Targets.CopyTo (t, 0);
bt = GetTasks (t [0]);
string[] names = bt [0].GetParameterNames ();
Assert.AreEqual (2, names.Length, "A1");
Assert.AreEqual ("Text", names [0], "A2");
Assert.AreEqual ("Importance", names [1], "A3");
}
[Test]
public void TestGetParameterValue1 ()
{
Engine engine;
Project project;
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Target Name='T'>
<Message Text='$(A)' Condition='true' />
</Target>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Target[] t = new Target [1];
BuildTask[] bt;
project.Targets.CopyTo (t, 0);
bt = GetTasks (t [0]);
Assert.AreEqual (String.Empty, bt [0].GetParameterValue ("text"), "A1");
Assert.AreEqual (String.Empty, bt [0].GetParameterValue (null), "A2");
Assert.AreEqual ("$(A)", bt [0].GetParameterValue ("Text"), "A3");
}
[Test]
public void TestGetParameterValue2 ()
{
Engine engine;
Project project;
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Target Name='T'>
<Message />
</Target>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Target[] t = new Target [1];
BuildTask[] bt;
project.Targets.CopyTo (t, 0);
bt = GetTasks (t [0]);
{
bool exception = false;
try {
bt [0].GetParameterValue ("Condition");
} catch (ArgumentException) {
exception = true;
}
Assert.IsTrue (exception, "A1");
}
{
bool exception = false;
try {
bt [0].GetParameterValue ("ContinueOnError");
} catch (ArgumentException) {
exception = true;
}
Assert.IsTrue (exception, "A2");
}
}
[Test]
public void TestSetParameterValue1 ()
{
Engine engine;
Project project;
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Target Name='T'>
<Message />
</Target>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Target[] t = new Target [1];
BuildTask[] bt;
project.Targets.CopyTo (t, 0);
bt = GetTasks (t [0]);
bt [0].SetParameterValue ("Text", "Value");
Assert.AreEqual ("Value", bt [0].GetParameterValue ("Text"), "A1");
bt [0].SetParameterValue ("text", "Value");
Assert.AreEqual ("Value", bt [0].GetParameterValue ("text"), "A2");
bt [0].SetParameterValue ("something", "Value");
Assert.AreEqual ("Value", bt [0].GetParameterValue ("something"), "A3");
bt [0].SetParameterValue ("Text", "$(A)");
Assert.AreEqual ("$(A)", bt [0].GetParameterValue ("Text"), "A4");
}
[Test]
public void TestSetParameterValue2 ()
{
Engine engine;
Project project;
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Target Name='T'>
<Message />
</Target>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Target[] t = new Target [1];
BuildTask[] bt;
project.Targets.CopyTo (t, 0);
bt = GetTasks (t [0]);
bt [0].SetParameterValue ("Text", "$(A)", true);
Assert.AreEqual (Utilities.Escape ("$(A)"), bt [0].GetParameterValue ("Text"), "A1");
bt [0].SetParameterValue ("Text", "$(A)", false);
Assert.AreEqual ("$(A)", bt [0].GetParameterValue ("Text"), "A2");
}
[Test]
public void TestProperties ()
{
Engine engine;
Project project;
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Target Name='T'>
<Message />
</Target>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Target[] t = new Target [1];
BuildTask[] bt;
project.Targets.CopyTo (t, 0);
bt = GetTasks (t [0]);
bt [0].Condition = null;
Assert.AreEqual (String.Empty, bt [0].Condition, "A1");
bt [0].Condition = "something";
Assert.AreEqual ("something", bt [0].Condition, "A2");
bt [0].ContinueOnError = true;
Assert.IsTrue (bt [0].ContinueOnError, "A3");
bt [0].ContinueOnError = false;
Assert.IsFalse (bt [0].ContinueOnError, "A4");
}
[Test]
public void TestAddOutputItem1 ()
{
Engine engine;
Project project;
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Target Name='T'>
<Message />
</Target>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Target [] t = new Target [1];
BuildTask [] bt;
project.Targets.CopyTo (t, 0);
bt = GetTasks (t [0]);
bt [0].AddOutputItem (null, null);
}
[Test]
public void TestAddOutputItem2 ()
{
Engine engine;
Project project;
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<UsingTask
AssemblyFile='Test\resources\TestTasks.dll'
TaskName='OutputTestTask'
/>
<Target Name='T'>
<OutputTestTask />
</Target>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Target [] t = new Target [1];
BuildTask [] bt;
project.Targets.CopyTo (t, 0);
bt = GetTasks (t [0]);
bt [0].AddOutputItem ("Property", "ItemName");
project.Build ("T");
Assert.IsNotNull (project.EvaluatedItems [0], "No items found");
Assert.AreEqual ("ItemName", project.EvaluatedItems [0].Name, "A1");
Assert.AreEqual ("some_text", project.EvaluatedItems [0].FinalItemSpec, "A2");
}
[Test]
public void TestTaskInNamespace()
{
Engine engine;
Project project;
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<UsingTask
AssemblyFile='Test\resources\TestTasks.dll'
TaskName='NamespacedOutputTestTask'
/>
<Target Name='T'>
<NamespacedOutputTestTask />
</Target>
</Project>
";
engine = new Engine(Consts.BinPath);
project = engine.CreateNewProject();
project.LoadXml(documentString);
Target[] t = new Target[1];
BuildTask[] bt;
project.Targets.CopyTo(t, 0);
bt = GetTasks(t[0]);
bt[0].AddOutputItem("Property", "ItemName");
project.Build("T");
Assert.AreEqual("ItemName", project.EvaluatedItems[0].Name, "A1");
Assert.AreEqual("some_text", project.EvaluatedItems[0].FinalItemSpec, "A2");
}
[Test]
public void TestAddOutputProperty1 ()
{
Engine engine;
Project project;
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Target Name='T'>
<Message />
</Target>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Target [] t = new Target [1];
BuildTask [] bt;
project.Targets.CopyTo (t, 0);
bt = GetTasks (t [0]);
bt [0].AddOutputProperty (null, null);
}
[Test]
public void TestAddOutputProperty2 ()
{
Engine engine;
Project project;
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<UsingTask
AssemblyFile='Test\resources\TestTasks.dll'
TaskName='OutputTestTask'
/>
<Target Name='T'>
<OutputTestTask />
</Target>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Target [] t = new Target [1];
BuildTask [] bt;
project.Targets.CopyTo (t, 0);
bt = GetTasks (t [0]);
bt [0].AddOutputProperty ("Property", "PropertyName");
project.Build ("T");
Assert.AreEqual ("some_text", project.EvaluatedProperties ["PropertyName"].Value, "A1");
Assert.AreEqual ("some_text", project.EvaluatedProperties ["PropertyName"].FinalValue, "A1");
}
// FIXME: edit
public void TestPublish1 ()
{
Engine engine;
Project project;
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<UsingTask
AssemblyFile='Test\resources\TestTasks.dll'
TaskName='OutputTestTask'
/>
<Target Name='T'>
<OutputTestTask />
</Target>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Target [] t = new Target [1];
BuildTask [] bt;
project.Targets.CopyTo (t, 0);
bt = GetTasks (t [0]);
bt [0].AddOutputProperty ("Property", "PropertyName");
project.Build ("T");
Assert.AreEqual ("some_text", project.EvaluatedProperties ["PropertyName"].Value, "A1");
Assert.AreEqual ("some_text", project.EvaluatedProperties ["PropertyName"].FinalValue, "A1");
}
}
}

View File

@@ -0,0 +1,418 @@
2010-06-03 Ankit Jain <jankit@novell.com>
* EngineTest.cs (TestGetLoadedProject1):
Patch by Dale Ragan <dale.ragan@sinesignal.com> .
2010-04-06 Ankit Jain <jankit@novell.com>
* Consts.cs (ToolsVersionString): New.
(GetTasksAsmPath): New.
* EngineTest.cs: Use the direct path to the tasks assembly
in the UsingTasks.
* ProjectTest.cs: Set ToolsVersion to the current profile.
2010-02-19 Ankit Jain <jankit@novell.com>
* ImportTest.cs (TestMissingImport*): Add new tests for missing
import projects.
2010-02-11 Ankit Jain <jankit@novell.com>
* ImportTest.cs (Add1): Fix test on windows.
2010-01-21 Rodrigo B. de Oliveira <rodrigo@unity3d.com>
* BuildChooseTest.cs
* BuildPropertyTest.cs:
test cases for nested Choose elements and different property
evaluation scenarios.
2009-10-08 Ankit Jain <jankit@novell.com>
* ProjectTest.cs (TestBatchedMetadataRefInOutput): New.
2009-10-01 Ankit Jain <jankit@novell.com>
* ImportTest.cs (TestAdd1): Add tests for multiple imports.
2009-09-29 Ankit Jain <jankit@novell.com>
* ProjectTest.cs (TestPropertiesFromImportedProjects): New.
2009-09-26 Ankit Jain <jankit@novell.com>
* TargetTest.cs (TestOverridingTargets): New.
2009-09-26 Ankit Jain <jankit@novell.com>
* ProjectTest.cs (TestInitialTargetsWithImports):
(TestDefaultTargets):
(TestDefaultTargetsWithImports):
(TestNoDefaultTargetsWithImports):
(TestNoDefaultTargets): New tests.
2009-08-29 Ankit Jain <jankit@novell.com>
* BuildItemTest.cs (TestSetMetadata5a): New.
* ProjectTest.cs: Add tests for different property types
with required attribute. Also, check the values - null or
empty array.
* TestTasks.cs: Add new tasks for above.
2009-08-18 Ankit Jain <jankit@novell.com>
* ProjectTest.cs (TestCaseSensitivityOfProjectElements): New.
2009-07-30 Ankit Jain <jankit@novell.com>
* EngineTest.cs (TestNewProject): Disable. Invalid for
v3.5 profile.
2009-06-09 Ankit Jain <jankit@novell.com>
* EngineTest.cs (TestMSBuildOutputs): New.
2009-06-08 Ankit Jain <jankit@novell.com>
* ProjectTest (TestBuildSolutionProject): New. Disabled for now.
* Consts.cs (RunningOnMono): Make public.
2009-06-07 Ankit Jain <jankit@novell.com>
* TargetTest (TestTargetOutputsIncludingMetadata): New.
2009-05-29 Ankit Jain <jankit@novell.com>
* EngineTest.cs (TestGlobalProperties*): New tests
and some helper methods.
* ProjectTest.cs (TestResetBuildStatus): Reset twice. Update
the event counts.
2009-05-15 Marek Sieradzki <marek.sieradzki@gmail.com>
* BuildItemTest.cs:
* BuildPropertyGroupTest.cs:
* BuildPropertyGroupCollectionTest.cs:
* BuildPropertyTest.cs:
* BuildItemGroupTest.cs:
* EngineTest.cs:
* InternalLoggerExceptionTest.cs:
* ProjectTest.cs: Don't compare exception messages.
2009-05-12 Ankit Jain <jankit@novell.com>
* ProjectTest.cs (TestAssignment1):
* UsingTaskTest.cs (TestTaskName):
(TestAssemblyNameOrAssemblyFile1):
(TestAssemblyNameOrAssemblyFile2): Don't compare exception messages.
2009-03-27 Jonathan Chambers <joncham@gmail.com>
* BuildChooseTest.cs: Enable tests.
* Microsoft.Build.Engine.Test.csproj: Update post build step.
2009-03-26 Jonathan Chambers <joncham@gmail.com>
* BuildTaskTest.cs (TestTaskInNamespace): Add test for Task in namespace.
2009-02-24 Ankit Jain <jankit@novell.com>
* UsingTaskTest.cs (TestLazyLoad{1,2,3}): New.
(TestAssemblyNameOrAssemblyFileConditionFalse): New.
(TestDuplicate1): New.
* TargetTest (CheckLoggedMessageHead): Moved to TestMessageLogger,
use that.
2009-02-15 Jonathan Chambers <joncham@gmail.com>
* BuildChooseTest.cs (TestValueXml): Add tests for Choose.
Currently not working.
2009-02-12 Jonathan Chambers <joncham@gmail.com>
* BuildPropertyTest.cs (TestValueXml): New.
2009-02-01 Ankit Jain <jankit@novell.com>
* ProjectTest.cs (TestBuild[23]): Check number of task started/finished
events.
(TestResetBuildStat): Remove "NotWorking".
(TestBuild4): Likewise. Check number of task started/finished events.
* TargetTest.cs (TestTargetOutputs1): New.
2009-01-30 Ankit Jain <jankit@novell.com>
* ProjectTest.cs (TestRequiredTask_*): New.
(TestBatchedMetadataRef5): New.
2009-01-29 Ankit Jain <jankit@novell.com>
* BuildItemTest.cs (TestBuildItemTransform): New.
2009-01-06 Ankit Jain <jankit@novell.com>
* ProjectTest.cs (TestInitialTargets): New.
2009-01-06 Ankit Jain <jankit@novell.com>
* EngineTest.cs: Update tests for null targetNames argument to
project.Build
2008-12-30 Ankit Jain <jankit@novell.com>
* ProjectTest.cs (TestBatchedMetadataRef[23]): Modify to check for
multiple items with same metadata value, incase of unqualified metadata
references.
Track changes in BatchingTestTask.
2008-12-17 Ankit Jain <jankit@novell.com>
* ProjectTest.cs (TestBatchedMetadataRef1): Modify to check for multiple
items with same metadata value.
2008-11-22 Ankit Jain <jankit@novell.com>
* ProjectTest.cs (TestBatchedMetadataRef*): New tests for metadata
references.
2008-11-21 Ankit Jain <jankit@novell.com>
* BuildItemTest.cs (TestGetEvaluatedMetadata1): Add test for 'Identity'.
2008-10-01 Ankit Jain <jankit@novell.com>
* ProjectTest.cs: Refactor BuildProjectFile tests. Add tests for loading
project from files and xml string.
2008-09-24 Ankit Jain <jankit@novell.com>
* EngineTest.cs:
* ProjectTest.cs: Add tests for Build*
2007-03-17 Marek Sieradzki <marek.sieradzki@gmail.com>
* Consts.cs: Check for runtime not platform.
2007-03-06 Marek Sieradzki <marek.sieradzki@gmail.com>
* BuildPropertyTest.cs, ProjectTest.cs: More tests.
2007-02-03 Marek Sieradzki <marek.sieradzki@gmail.com>
* BuildPropertyGroupTest.cs: More tests.
2007-01-28 Marek Sieradzki <marek.sieradzki@gmail.com>
* BuildItemTest.cs: Enabled 2 tests.
2007-01-26 Marek Sieradzki <marek.sieradzki@gmail.com>
* BuildPropertyGroupTest.cs: Trivial test for SetProperty ().
2007-01-23 Marek Sieradzki <marek.sieradzki@gmail.com>
* ProjectTest: Removed warning.
2007-01-21 Marek Sieradzki <marek.sieradzki@gmail.com>
* ProjectTest.cs: Tests for Project.AddNewItem ().
2007-01-16 Marek Sieradzki <marek.sieradzki@gmail.com>
* BuildItemTest.cs, BuildPropertyGroupTest.cs,
UsingTaskCollectionTest.cs, ImportCollectionTest.cs,
BuildItemGroupTest.cs, BuildPropertyGroupCollectionTest.cs,
TargetCollectionTest.cs, EngineTest.cs, ProjectTest.cs,
BuildItemGroupCollectionTest.cs: Added more tests and replaced
Ignores with Category ("NotDotNet")
2007-01-14 Marek Sieradzki <marek.sieradzki@gmail.com>
* BuildItemGroupTest.cs, ProjectTest.cs: Added more tests.
2007-01-12 Marek Sieradzki <marek.sieradzki@gmail.com>
* ProjectTest.cs, BuildPropertyGroupTest.cs: Enable more tests.
2007-01-12 Marek Sieradzki <marek.sieradzki@gmail.com>
* BuildItemTest.cs, BuildPropertyGroupTest.cs, TargetTest.cs,
TargetCollectionTest.cs, ProjectTest.cs: More tests.
2007-01-10 Marek Sieradzki <marek.sieradzki@gmail.com>
* BuildPropertyGroupTest.cs, BuildItemGroupTest.cs: Check if XML has
changed.
* TestNamespaceManager.cs: Added.
2007-01-08 Marek Sieradzki <marek.sieradzki@gmail.com>
* ImportTest.cs: Added test for project importing another project
importing another project.
2007-01-08 Marek Sieradzki <marek.sieradzki@gmail.com>
* BuildItemTest.cs: More tests.
* InvalidProjectFileExceptionTest.cs: Added GetObjectData () tests.
2007-01-02 Marek Sieradzki <marek.sieradzki@gmail.com>
* BuildItemTest.cs: Tests for items from XML.
* BuildPropertyGroupTest.cs, BuildTaskTest.cs, BuildItemGroupTest.cs,
BuildPropertyTest.cs, ProjectTest.cs: More tests.
2006-12-20 Marek Sieradzki <marek.sieradzki@gmail.com>
* BuildItemGroupTest.cs: Enabled TestAddNewItem2 ().
2006-12-19 Marek Sieradzki <marek.sieradzki@gmail.com>
* TargetTest.cs, TargetCollectionTest.cs: Enabled all tests.
2006-12-19 Marek Sieradzki <marek.sieradzki@gmail.com>
* BuildItemTest.cs, BuildPropertyGroupTest.cs,
UsingTaskCollectionTest.cs, TargetTest.cs, BuildItemGroupTest.cs,
BuildPropertyGroupCollectionTest.cs, TargetCollectionTest.cs,
BuildPropertyTest.cs, EngineTest.cs, ProjectTest.cs,
BuildItemGroupCollectionTest.cs: Added more tests.
2006-12-18 Marek Sieradzki <marek.sieradzki@gmail.com>
* BuildItemGroupTest.cs: Enabled a test.
2006-12-16 Marek Sieradzki <marek.sieradzki@gmail.com>
* ConsoleLoggerTest.cs: Added.
* ProjectTest.cs, BuildItemTest.cs: More tests.
2006-12-12 Marek Sieradzki <marek.sieradzki@gmail.com>
* ImportTest.cs: Added test for IsImported on imported BuildItemGroup.
2006-12-11 Marek Sieradzki <marek.sieradzki@gmail.com>
* ProjectTest.cs: Added more tests.
2006-12-08 Marek Sieradzki <marek.sieradzki@gmail.com>
* UsingTaskCollectionTest.cs: Change task name to TrueTestTask and add
a new add a test.
2006-12-07 Marek Sieradzki <marek.sieradzki@gmail.com>
* BuildItemTest.cs, BuildPropertyGroupTest.cs, BuildTaskTest.cs,
UsingTaskCollectionTest.cs, ProjectTest.cs: More tests.
2006-12-05 Marek Sieradzki <marek.sieradzki@gmail.com>
* BuildItemTest.cs: Reformatted.
* BuildTaskTest.cs, TargetTest.cs, ImportCollectionTest.cs,
TargetCollectionTest.cs, ImportTest.cs: Enabled more tests.
2006-12-04 Marek Sieradzki <marek.sieradzki@gmail.com>
* BuildPropertyGroupTest.cs, UsingTaskCollectionTest.cs,
BuildPropertyGroupCollectionTest.cs, BuildPropertyGroupTest.cs,
EngineTest.cs, UsingTaskTest.cs, Consts.cs: Added platform dependent
BinPath.
* ProjectTest.cs: New tests.
* BuildTaskTest.cs, TargetTest.cs, ImportCollectionTest.cs,
BuildItemGroupTest.cs, TargetCollectionTest.cs,
BuildItemGroupCollectionTest.cs, ImportTest.cs: Added.
2006-10-06 Marek Sieradzki <marek.sieradzki@gmail.com>
* BuildItemTest.cs:
* BuildPropertyTest.cs:
* ProjectTest.cs:
* BuildPropertyGroupCollectionTest.cs: Uncommented tests and added
[Ignore] to them.
2006-06-22 Marek Sieradzki <marek.sieradzki@gmail.com>
* UsingTaskCollectionTest.cs, UsingTaskTest.cs: Updated names.
* ProjectTest.cs: Moved most of the old tests to various/.
* Consts.cs: Added.
2006-06-14 Marek Sieradzki <marek.sieradzki@gmail.com>
* BuildPropertyGroupTest.cs: Added some tests.
* UsingTaskCollectionTest.cs: Added very simple test.
* UsingTaskTest.cs: Added test that's loading SimpleTask.dll task from
Test/resources/. Test/resources/SimpleTask.cs should be compiled
before running tests. I need to find out how to add it to Makefile.
2006-06-02 Marek Sieradzki <marek.sieradzki@gmail.com>
* BuildPropertyTest.cs: Added.
* BuildPropertyGroupTest.cs: Added.
* BuildPropertyGroupCollectionTest.cs: Added.
2006-05-27 Marek Sieradzki <marek.sieradzki@gmail.com>
* BuildItemTest.cs: Swapped expected with actual results.
* UtilitiesTest.cs: Added.
2006-05-03 Marek Sieradzki <marek.sieradzki@gmail.com>
* ProjectTest.cs, EngineTest.cs: Corrected BinPath once more.
2006-04-24 Marek Sieradzki <marek.sieradzki@gmail.com>
* ProjectTest.cs, EngineTest.cs: Corrected BinPath.
2006-04-24 Marek Sieradzki <marek.sieradzki@gmail.com>
* ProjectTest.cs: Added tests for loading of default tasks (from
Microsoft.Build.Tasks).
2006-03-29 Crestez Leonard <cdleonard@gmail.com>
* EngineTest.cs: Added test for GlobalEngine.
* ProjectTest.cs: Fixed tests.
2006-03-27 Crestez Leonard <cdleonard@gmail.com>
* ProjectTest.cs, EngineTest.cs: Added new tests.
2006-03-23 Marek Sieradzki <marek.sieradzki@gmail.com>
* Microsoft.Build.Engine.Test.csproj: Updated.
2006-03-21 Crestez Leonard <cdleonard@gmail.com>
* InternalLoggerExceptionTest.cs, InvalidProjectFileExceptionTest.cs:
Got rid of compilation warnings.
* ProjectTest.cs: Added new tests.
2006-03-21 Marek Sieradzki <marek.sieradzki@gmail.com>
* InvalidProjectFileExceptionTest.cs, EngineTest.cs, ProjectTest.cs:
Updated tests.
2006-03-18 Marek Sieradzki <marek.sieradzki@gmail.com>
* InternalLoggerExceptionTest.cs, InvalidProjectFileExceptionTest.cs,
EngineTest.cs, ProjectTest.cs: Added new tests.
* BuildItemTest.cs: Added.
* Microsoft.Build.Engine.Test.sln, Microsoft.Build.Engine.Test.csproj:
Added VS 2005/SD2 solution.
2006-03-18 Marek Sieradzki <marek.sieradzki@gmail.com>
* Project.cs: Added new tests.
2006-02-27 Marek Sieradzki <marek.sieradzki@gmail.com>
* Engine.cs, Project.cs: Removed references to IEngine and IProject.
2005-09-03 Marek Sieradzki <marek.sieradzki@gmail.com>
* ProjectTest.cs, EngineTest.cs: Added next simple tests.
2005-08-31 Marek Sieradzki <marek.sieradzki@gmail.com>
* InternalLoggerExceptionTest.cs, InvalidProjectFileExceptionTest.cs:
Added simple tests.

View File

@@ -0,0 +1,53 @@
//
// ConsoleLoggerTest.cs
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
//
// (C) 2006 Marek Sieradzki
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Xml;
using Microsoft.Build.BuildEngine;
using Microsoft.Build.Framework;
using NUnit.Framework;
namespace MonoTests.Microsoft.Build.BuildEngine {
[TestFixture]
public class ConsoleLoggerTest {
[Test]
[Category ("NotDotNet")]
public void TestAssignment ()
{
ConsoleLogger cl = new ConsoleLogger ();
Assert.IsNull (cl.Parameters, "A1");
Assert.IsTrue (cl.ShowSummary, "A2");
Assert.IsFalse (cl.SkipProjectStartedText, "A3");
Assert.AreEqual (LoggerVerbosity.Normal, cl.Verbosity, "A4");
cl.ApplyParameter ("name", "value");
Assert.IsNull (cl.Parameters);
}
}
}

View File

@@ -0,0 +1,98 @@
//
// Consts.cs
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
//
// (C) 2006 Marek Sieradzki
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.IO;
using Microsoft.Build.Utilities;
public static class Consts {
public static bool RunningOnMono ()
{
return Type.GetType ("Mono.Runtime") != null;
}
public static string BinPath {
get {
if (RunningOnMono ()) {
#if XBUILD_12
string profile = "xbuild_12";
#elif NET_4_5
string profile = "net_4_5";
#elif NET_4_0
string profile = "net_4_0";
#elif NET_3_5
string profile = "net_3_5";
#else
string profile = "net_2_0";
#endif
var corlib = typeof (object).Assembly.Location;
var lib = Path.GetDirectoryName (Path.GetDirectoryName (corlib));
return Path.Combine (lib, profile);
} else {
#if XBUILD_12
return ToolLocationHelper.GetPathToBuildTools ("12.0");
#elif NET_4_5
return ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version45);
#elif NET_4_0
return ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version40);
#elif NET_3_5
return ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version35);
#else
return ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version20);
#endif
}
}
}
public static string ToolsVersionString {
get {
#if XBUILD_12
return " ToolsVersion='12.0'";
#elif NET_4_0
return " ToolsVersion='4.0'";
#elif NET_3_5
return " ToolsVersion='3.5'";
#else
return String.Empty;
#endif
}
}
public static string GetTasksAsmPath ()
{
#if XBUILD_12
return Path.Combine (BinPath, "Microsoft.Build.Tasks.v12.0.dll");
#elif NET_4_0
return Path.Combine (BinPath, "Microsoft.Build.Tasks.v4.0.dll");
#elif NET_3_5
return Path.Combine (BinPath, "Microsoft.Build.Tasks.v3.5.dll");
#else
return Path.Combine (BinPath, "Microsoft.Build.Tasks.dll");
#endif
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,168 @@
//
// ImportCollectionTest.cs
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
//
// (C) 2006 Marek Sieradzki
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Collections;
using Microsoft.Build.BuildEngine;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using NUnit.Framework;
namespace MonoTests.Microsoft.Build.BuildEngine {
[TestFixture]
public class ImportCollectionTest {
Engine engine;
Project project;
[Test]
[ExpectedException (typeof (InvalidProjectFileException))]
public void TestAdd1 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Import Project='project_that_doesnt_exist'/>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
}
[Test]
public void TestAdd2 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Import Project='Test/resources/Import.csproj'/>
<Import Project='Test/resources/Import.csproj'/>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Assert.AreEqual (1, project.Imports.Count, "A1");
Assert.AreEqual (false, project.Imports.IsSynchronized, "A2");
}
[Test]
[Category ("NotDotNet")]
[ExpectedException (typeof (ArgumentNullException))]
public void TestCopyTo1 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Import Project='Test/resources/Import.csproj'/>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
project.Imports.CopyTo (null, 0);
}
[Test]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void TestCopyTo2 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Import Project='Test/resources/Import.csproj'/>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
project.Imports.CopyTo (new Import [1], -1);
}
[Test]
[ExpectedException (typeof (InvalidCastException))]
public void TestCopyTo3 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Import Project='Test/resources/Import.csproj'/>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
project.Imports.CopyTo (new Import [][] { new Import [] { null } }, 0);
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void TestCopyTo4 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Import Project='Test/resources/Import.csproj'/>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
project.Imports.CopyTo (new Import [1], 2);
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void TestCopyTo5 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Import Project='Test/resources/Import.csproj'/>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
project.Imports.CopyTo (new Import [1], 1);
}
}
}

View File

@@ -0,0 +1,270 @@
//
// ImportTest.cs
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
//
// (C) 2006 Marek Sieradzki
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Collections;
using Microsoft.Build.BuildEngine;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using NUnit.Framework;
using System.IO;
namespace MonoTests.Microsoft.Build.BuildEngine {
[TestFixture]
public class ImportTest {
Engine engine;
Project project;
[Test]
public void TestAdd1 ()
{
string first = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Import Project='second.proj'/>
</Project>
";
using (StreamWriter sw = new StreamWriter ("Test/resources/first.proj")) {
sw.Write (first);
}
string second = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
</Project>
";
using (StreamWriter sw = new StreamWriter ("Test/resources/second.proj")) {
sw.Write (second);
}
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Import Project='Test\resources\first.proj'/>
<Import Project='Test\resources\Import.csproj' Condition='false'/>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Import[] t = new Import [2];
Assert.AreEqual (2, project.Imports.Count, "Number of imports");
project.Imports.CopyTo (t, 0);
string base_dir = Path.Combine (Environment.CurrentDirectory, Path.Combine ("Test", "resources"));
Assert.IsNull (t [0].Condition, "A1");
Assert.AreEqual (false, t[0].IsImported, "A5");
Assert.AreEqual ("Test\\resources\\first.proj", t[0].ProjectPath, "A6");
Assert.AreEqual (Path.Combine (base_dir, "first.proj"), t[0].EvaluatedProjectPath, "A7");
Assert.AreEqual (true, t[1].IsImported, "A2");
Assert.AreEqual ("second.proj", t[1].ProjectPath, "A3");
Assert.AreEqual (Path.Combine (base_dir, "second.proj"), t[1].EvaluatedProjectPath, "A4");
}
[Test]
[ExpectedException (typeof (InvalidProjectFileException))]
public void TestAdd2 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Import Project=''/>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
}
[Test]
[Category ("NotWorking")]
public void TestAdd3 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Import Project='Test/resources/SelfImport.csproj'/>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Assert.AreEqual (1, project.Imports.Count, "A1");
}
[Test]
public void TestRelativeImport1 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Import Project='Test/resources/RelativeImport1.csproj'/>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Assert.AreEqual ("B", project.EvaluatedProperties ["A"].FinalValue, "A1");
}
[Test]
public void TestItems1 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Import Project='Test/resources/Items.csproj'/>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
BuildItemGroup [] groups = new BuildItemGroup [1];
project.ItemGroups.CopyTo (groups, 0);
Assert.IsTrue (groups [0].IsImported, "A1");
Assert.AreEqual (1, groups [0].Count, "A2");
}
[Test]
[ExpectedException (typeof (InvalidProjectFileException))]
public void TestMissingImport1 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Import Project='Test/resources/NonExistantProject.proj'/>
</Project>";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString, ProjectLoadSettings.None);
}
[Test]
public void TestMissingImport2 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Import Project='Test/resources/NonExistantProject.proj'/>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString, ProjectLoadSettings.IgnoreMissingImports);
Assert.AreEqual (1, project.Imports.Count, "A1");
}
[Test]
[ExpectedException (typeof (InvalidProjectFileException))]
public void TestMissingImportDefault ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Import Project='Test/resources/NonExistantProject.proj'/>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
}
#if NET_4_0
[Test]
public void TestImportWildcard ()
{
string main_project_xml = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""4.0"">
<ItemGroup>
<FooItem Include=""From main.proj""/>
</ItemGroup>
<Import Project=""tmp\*""/>
<Target Name=""Build"">
<Message Text=""FooItem: @(FooItem)""/>
</Target>
</Project>";
string other_project_xml = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""4.0"">
<ItemGroup>
<FooItem Include=""From $(MSBuildThisFile)""/>
</ItemGroup>
</Project>";
Engine engine = new Engine (Consts.BinPath);
MonoTests.Microsoft.Build.Tasks.TestMessageLogger logger =
new MonoTests.Microsoft.Build.Tasks.TestMessageLogger ();
engine.RegisterLogger (logger);
string base_dir = Path.GetFullPath (Path.Combine ("Test", "resources")) + Path.DirectorySeparatorChar;
string tmp_dir = Path.GetFullPath (Path.Combine (base_dir, "tmp")) + Path.DirectorySeparatorChar;
string main_project = Path.Combine (base_dir, "main.proj");
string first_project = Path.Combine (tmp_dir, "first.proj");
string second_project = Path.Combine (tmp_dir, "second.proj");
Directory.CreateDirectory (tmp_dir);
File.WriteAllText (main_project, main_project_xml);
File.WriteAllText (first_project, other_project_xml);
File.WriteAllText (second_project, other_project_xml);
Project project = engine.CreateNewProject ();
project.Load (main_project);
try {
Assert.IsTrue (project.Build ("Build"), "Build failed");
logger.CheckLoggedMessageHead ("FooItem: From main.proj;From first.proj;From second.proj", "A1");
Assert.AreEqual (0, logger.NormalMessageCount, "Unexpected extra messages found");
} catch {
logger.DumpMessages ();
throw;
} finally {
File.Delete (main_project);
File.Delete (first_project);
File.Delete (second_project);
}
}
#endif
}
}

View File

@@ -0,0 +1,60 @@
//
// InternalLoggerExceptionTest.cs:
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
//
// (C) 2005 Marek Sieradzki
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using Microsoft.Build.BuildEngine;
using NUnit.Framework;
namespace MonoTests.Microsoft.Build.BuildEngine {
[TestFixture]
public class InternalLoggerExceptionTest {
// An InternalLoggerException can only be thrown by the MSBuild engine.
// The public constructors of this class cannot be used to create an instance of the exception.
[Test]
[ExpectedException (typeof (System.InvalidOperationException))]
public void TestCtorMessage ()
{
string message = "message";
new InternalLoggerException (message);
}
// An InternalLoggerException can only be thrown by the MSBuild engine.
// The public constructors of this class cannot be used to create an instance of the exception.
[Test]
[ExpectedException (typeof (System.InvalidOperationException))]
public void TestCtorMessageException ()
{
string message = "message";
Exception e = new Exception ("Inner exception message.");
new InternalLoggerException (message, e);
}
}
}

View File

@@ -0,0 +1,150 @@
//
// InvalidProjectFileExceptionTest.cs:
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
//
// (C) 2005 Marek Sieradzki
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.IO;
using System.Reflection;
using System.Runtime.Serialization;
using System.Xml;
using Microsoft.Build.BuildEngine;
using NUnit.Framework;
namespace MonoTests.Microsoft.Build.BuildEngine {
[TestFixture]
public class InvalidProjectFileExceptionTest {
[Test]
public void TestCtorMessage ()
{
InvalidProjectFileException ipfe;
string message = "message";
ipfe = new InvalidProjectFileException (message);
Assert.AreEqual (message, ipfe.Message, "Message");
}
[Test]
public void TestCtorProjectFile ()
{
InvalidProjectFileException ipfe;
string projectFile = "projectFile";
int lineNumber = 1;
int columnNumber = 2;
int endLineNumber = 3;
int endColumnNumber = 4;
string message = "message";
string errorSubcategory = "errorSubcategory";
string errorCode = "CS0000";
string helpKeyword = "helpKeyword";
ipfe = new InvalidProjectFileException (projectFile, lineNumber, columnNumber, endLineNumber, endColumnNumber,
message, errorSubcategory, errorCode, helpKeyword);
Assert.AreEqual (projectFile, ipfe.ProjectFile, "A1");
Assert.AreEqual (lineNumber, ipfe.LineNumber, "A2");
Assert.AreEqual (columnNumber, ipfe.ColumnNumber, "A3");
Assert.AreEqual (endLineNumber, ipfe.EndLineNumber, "A4");
Assert.AreEqual (endColumnNumber, ipfe.EndColumnNumber, "A5");
Assert.AreEqual (message, ipfe.BaseMessage, "A6");
Assert.AreEqual (message + " " + projectFile, ipfe.Message, "A7");
Assert.AreEqual (errorSubcategory, ipfe.ErrorSubcategory, "A8");
Assert.AreEqual (errorCode, ipfe.ErrorCode, "A9");
Assert.AreEqual (helpKeyword, ipfe.HelpKeyword, "A10");
}
[Test]
public void TestCtorMessageException ()
{
string message = "message";
Exception e = new Exception ("Exception message");
new InvalidProjectFileException (message, e);
}
[Test]
public void TestCtorNode ()
{
// FIXME: we need to load xml file to load something with non-empty XmlElement.BaseUri
/*
XmlDocument xd = new XmlDocument ();
InvalidProjectFileException ipfe;
string message = "message";
string errorSubcategory = "errorSubcategory";
string errorCode = "CS0000";
string helpKeyword = "helpKeyword";
ipfe = new InvalidProjectFileException (null, message, errorSubcategory, errorCode, helpKeyword);
Assert.AreEqual (message, ipfe.BaseMessage, "A1");
Assert.AreEqual (errorSubcategory, ipfe.ErrorSubcategory, "A2");
Assert.AreEqual (errorCode, ipfe.ErrorCode, "A3");
Assert.AreEqual (helpKeyword, ipfe.HelpKeyword, "A4");
*/
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void TestGetObjectData1 ()
{
InvalidProjectFileException ipfe = new InvalidProjectFileException ();
ipfe.GetObjectData (null, new StreamingContext ());
}
[Test]
public void TestGetObjectData2 ()
{
StreamingContext sc = new StreamingContext ();
SerializationInfo si = new SerializationInfo (typeof (InvalidProjectFileException), new FormatterConverter ());
InvalidProjectFileException ipfe;
string projectFile = "projectFile";
int lineNumber = 1;
int columnNumber = 2;
int endLineNumber = 3;
int endColumnNumber = 4;
string message = "message";
string errorSubcategory = "errorSubcategory";
string errorCode = "CS0000";
string helpKeyword = "helpKeyword";
ipfe = new InvalidProjectFileException (projectFile, lineNumber, columnNumber, endLineNumber, endColumnNumber,
message, errorSubcategory, errorCode, helpKeyword);
ipfe.GetObjectData (si, sc);
Assert.AreEqual (projectFile, si.GetString ("projectFile"), "A1");
Assert.AreEqual (lineNumber, si.GetInt32 ("lineNumber"), "A2");
Assert.AreEqual (columnNumber, si.GetInt32 ("columnNumber"), "A3");
Assert.AreEqual (endLineNumber, si.GetInt32 ("endLineNumber"), "A4");
Assert.AreEqual (endColumnNumber, si.GetInt32 ("endColumnNumber"), "A5");
Assert.AreEqual (message, si.GetString ("Message"), "A6");
Assert.AreEqual (errorSubcategory, si.GetString ("errorSubcategory"), "A7");
Assert.AreEqual (errorCode, si.GetString ("errorCode"), "A8");
Assert.AreEqual (helpKeyword, si.GetString ("helpKeyword"), "A9");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,347 @@
//
// TargetCollectionTest.cs
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
//
// (C) 2006 Marek Sieradzki
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Collections;
using Microsoft.Build.BuildEngine;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using NUnit.Framework;
namespace MonoTests.Microsoft.Build.BuildEngine {
[TestFixture]
public class TargetCollectionTest {
Engine engine;
Project project;
[Test]
public void TestEmpty ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Assert.AreEqual (0, project.Targets.Count, "A1");
Assert.IsFalse (project.Targets.IsSynchronized, "A2");
Assert.IsNotNull (project.Targets.SyncRoot, "A3");
}
[Test]
public void TestAddNewTarget1 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
project.Targets.AddNewTarget ("name");
Assert.AreEqual (1, project.Targets.Count, "A1");
Assert.AreEqual ("name", project.Targets ["name"].Name, "A2");
Assert.IsFalse (project.Targets ["name"].IsImported, "A3");
Assert.AreEqual (String.Empty, project.Targets ["name"].Condition, "A4");
Assert.AreEqual (String.Empty, project.Targets ["name"].DependsOnTargets, "A5");
}
[Test]
[ExpectedException (typeof (InvalidProjectFileException))]
public void TestAddNewTarget2 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
project.Targets.AddNewTarget (null);
}
[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 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Target Name='a' />
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
project.Targets.CopyTo (null, 0);
}
[Test]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void TestCopyTo2 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Target Name='a' />
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
project.Targets.CopyTo (new Target [1], -1);
}
[Test]
[ExpectedException (typeof (InvalidCastException))]
public void TestCopyTo3 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Target Name='a' />
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
project.Targets.CopyTo (new Target [][] { new Target [] { null } }, 0);
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void TestCopyTo4 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Target Name='a' />
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
project.Targets.CopyTo (new Target [1], 2);
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void TestCopyTo5 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Target Name='a' />
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
project.Targets.CopyTo (new Target [1], 1);
}
[Test]
public void TestExists1 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Target Name='name' />
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Assert.AreEqual (1, project.Targets.Count, "A1");
Assert.IsTrue (project.Targets.Exists ("name"), "A2");
Assert.IsTrue (project.Targets.Exists ("NAME"), "A3");
Assert.IsFalse (project.Targets.Exists ("something_that_doesnt_exist"), "A4");
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void TestExists2 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Target Name='name' />
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
project.Targets.Exists (null);
}
[Test]
public void TestGetEnumerator ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Target Name='first' />
<Target Name='second' />
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
ArrayList targets = new ArrayList ();
foreach (Target t in project.Targets)
targets.Add (t);
Assert.AreEqual ("first", ((Target) targets [0]).Name, "A1");
Assert.AreEqual ("second", ((Target) targets [1]).Name, "A1");
}
[Test]
public void TestRemoveTarget1 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Target Name='first' />
<Target Name='second' />
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Assert.IsTrue (project.Targets.Exists ("first"), "A1");
Assert.IsTrue (project.Targets.Exists ("second"), "A1");
project.Targets.RemoveTarget (project.Targets ["first"]);
Assert.IsFalse (project.Targets.Exists ("first"), "A1");
Assert.IsTrue (project.Targets.Exists ("second"), "A1");
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
[Category ("NotDotNet")]
public void TestRemoveTarget2 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Target Name='first' />
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
project.Targets.RemoveTarget (null);
}
[Test]
public void TestIndexer1 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Target Name='first' />
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Target t1 = project.Targets ["first"];
Assert.AreEqual ("first", t1.Name, "A1");
Target t2 = project.Targets ["target_that_doesnt_exist"];
Assert.IsNull (t2, "A2");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,49 @@
//
// TestNamespaceManager.cs
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
//
// (C) 2006 Marek Sieradzki
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Collections;
using System.Xml;
using Microsoft.Build.BuildEngine;
using NUnit.Framework;
namespace MonoTests.Microsoft.Build.BuildEngine {
public class TestNamespaceManager {
static XmlNamespaceManager manager;
internal static XmlNamespaceManager NamespaceManager
{
get
{
if (manager == null) {
manager = new XmlNamespaceManager (new NameTable ());
manager.AddNamespace ("tns", "http://schemas.microsoft.com/developer/msbuild/2003");
}
return manager;
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More