[resgen] Implement conditional resources (#if/#ifdef)
[mono.git] / mcs / class / Microsoft.Build.Tasks / Test / Microsoft.Build.Tasks / MessageTest.cs
1 //
2 // MessageTest.cs
3 //
4 // Author:
5 //   Marek Sieradzki (marek.sieradzki@gmail.com)
6 //
7 // (C) 2006 Marek Sieradzki
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
28 using System;
29 using System.Collections;
30 using Microsoft.Build.BuildEngine;
31 using Microsoft.Build.Framework;
32 using Microsoft.Build.Tasks;
33 using Microsoft.Build.Utilities;
34 using NUnit.Framework;
35
36 namespace MonoTests.Microsoft.Build.Tasks {
37
38
39         [TestFixture]
40         public class MessageTest {
41         
42                 Engine engine;
43                 Project project;
44                 TestMessageLogger testLogger;
45
46                 [Test]
47                 public void TestDefaultValues()
48                 {
49                         Message message = new Message();
50                         Assert.AreEqual(null, message.Text, "A1");
51                         Assert.AreEqual(null, message.Importance, "A2");
52                 }
53                 
54                 [Test]
55                 public void TestAssignment ()
56                 {
57                         string importance = "importance";
58                         string text = "text";
59                         
60                         Message message = new Message ();
61                         
62                         message.Importance = importance;
63                         message.Text = text;
64                         
65                         Assert.AreEqual (importance, message.Importance, "A1");
66                         Assert.AreEqual (text, message.Text, "A2");
67                 }
68                 
69                 [Test]
70                 public void TestExecution ()
71                 {
72                         string documentString = @"
73                                 <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
74                                         <Target Name='1'>
75                                                 <Message Text='Text1' Importance='Low'/>
76                                                 <Message Text='Text2' Importance='Normal'/>
77                                                 <Message Text='Text3' Importance='High'/>
78                                                 <Message Text='Text4' Importance='low'/>
79                                                 <Message Text='Text5' Importance='normal'/>
80                                                 <Message Text='Text6' Importance='high'/>
81                                                 <Message Text='Text7' />
82                                                 <Message Text='Text8' Importance='weird_importance'/>
83                                         </Target>
84                                 </Project>
85                         ";
86                         
87                         engine = new Engine (Consts.BinPath);
88                         testLogger = new TestMessageLogger ();
89                         engine.RegisterLogger (testLogger);
90                         
91                         project = engine.CreateNewProject ();
92                         project.LoadXml (documentString);
93                         if (project.Build ("1")) {
94                                 testLogger.DumpMessages ();
95                                 Assert.Fail ("Build should have failed");
96                         }
97                         
98                         Assert.AreEqual (0, testLogger.CheckAny ("Text1", MessageImportance.Low), "A1");
99                         Assert.AreEqual (0, testLogger.CheckAny ("Text2", MessageImportance.Normal), "A2");
100                         Assert.AreEqual (0, testLogger.CheckAny ("Text3", MessageImportance.High), "A3");
101                         Assert.AreEqual (0, testLogger.CheckAny ("Text4", MessageImportance.Low), "A4");
102                         Assert.AreEqual (0, testLogger.CheckAny ("Text5", MessageImportance.Normal), "A5");
103                         Assert.AreEqual (0, testLogger.CheckAny ("Text6", MessageImportance.High), "A6");
104                         Assert.AreEqual (0, testLogger.CheckAny ("Text7", MessageImportance.Normal), "A7");
105                         Assert.AreEqual (1, testLogger.CheckAny ("Text8", MessageImportance.Normal), "A8");
106                 }
107         }
108 }       
109