Merge pull request #1066 from esdrubal/bug19313
[mono.git] / mcs / class / Microsoft.Build.Engine / Test / various / Properties.cs
index ba809fc5c1129cf6221788c3e2ece3148157719f..795a71230663dc1bc363989138e1b4d6ec189947 100644 (file)
@@ -1,8 +1,9 @@
 //
 // Properties.cs
 //
-// Author:
+// Authors:
 //   Marek Sieradzki (marek.sieradzki@gmail.com)
+//   Marek Safar (marek.safar@gmail.com)
 //
 // (C) 2006 Marek Sieradzki
 //
@@ -99,10 +100,12 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various {
                                                <PropertyGroup>
                                                        <Config>debug</Config>
                                                        <NullValue>null</NullValue>
+                                                       <TargetValue>  </TargetValue>
                                                        <Prop1>$(Config.Substring(0,3)) </Prop1>
                                                        <Prop2>$(Config.Length )</Prop2>
                                                        <Prop3>$(Config.StartsWith ('DE', System.StringComparison.OrdinalIgnoreCase))</Prop3>
                                                        <Prop4>$(NullValue.StartsWith ('Te', StringComparison.OrdinalIgnoreCase))</Prop4>
+                                                       <Prop5>$(TargetValue.Trim('\\'))</Prop5>
                                                </PropertyGroup>
                                        </Project>
                                ";
@@ -112,6 +115,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various {
                        Assert.AreEqual ("5", proj.GetEvaluatedProperty ("Prop2"), "#2");
                        Assert.AreEqual ("True", proj.GetEvaluatedProperty ("Prop3"), "#3");
                        Assert.AreEqual ("False", proj.GetEvaluatedProperty ("Prop4"), "#4");
+                       Assert.AreEqual ("", proj.GetEvaluatedProperty ("Prop5"), "#5");
                }
 
                [Test]
@@ -156,6 +160,37 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various {
                        Assert.AreEqual (DateTime.Now.ToString ("yyyy.MM.dd"), proj.GetEvaluatedProperty ("Prop1"), "#1");
                }
 
+               [Test]
+               public void InstanceMemberOnStaticProperty ()
+               {
+                       string documentString = @"
+                                       <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
+                                               <PropertyGroup>
+                                                       <Prop1>$([System.DateTime]::Now.Year)</Prop1>
+                                               </PropertyGroup>
+                                       </Project>
+                               ";
+
+                       proj.LoadXml (documentString);
+                       Assert.AreEqual (DateTime.Now.Year.ToString (), proj.GetEvaluatedProperty ("Prop1"), "#1");
+               }
+
+               [Test]
+               public void InstanceMembersOnStaticMethod ()
+               {
+                       string documentString = @"
+                                       <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
+                                               <PropertyGroup>
+                                                       <Prop1>$([System.String]::Concat('a', 'bb', 'c').Length.GetHashCode ())</Prop1>
+
+                                               </PropertyGroup>
+                                       </Project>
+                               ";
+
+                       proj.LoadXml (documentString);
+                       Assert.AreEqual (4.GetHashCode ().ToString (), proj.GetEvaluatedProperty ("Prop1"), "#1");
+               }
+
                [Test]
                public void MSBuildPropertyFunctions ()
                {
@@ -171,6 +206,23 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various {
 
                        proj.LoadXml (documentString);
                        Assert.AreEqual ("6.6", proj.GetEvaluatedProperty ("Prop1"), "#1");
-               }               
+               }
+
+               [Test]
+               public void Constructor ()
+               {
+                       string documentString = @"
+                                       <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
+                                               <PropertyGroup>
+                                                       <NumberOne>0.6</NumberOne>
+                                                       <NumberTwo>6</NumberTwo>
+                                                       <Prop1>$([System.String]::new('value').EndsWith ('ue'))</Prop1>
+                                               </PropertyGroup>
+                                       </Project>
+                               ";
+
+                       proj.LoadXml (documentString);
+                       Assert.AreEqual ("True", proj.GetEvaluatedProperty ("Prop1"), "#1");
+               }
        }
 }