Add [Category ("NotWorking")] to failing test.
[mono.git] / mcs / class / Microsoft.Build.Utilities / Test / Microsoft.Build.Utilities / ToolTaskTest.cs
1 //
2 // ToolTaskTest.cs:
3 //
4 // Author:
5 //   Jonathan Pryor (jonp@xamarin.com)
6 //
7 // (C) 2013 Xamarin Inc.
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.Generic;
30 using System.Diagnostics;
31 using System.IO;
32 using System.Linq;
33
34 using Microsoft.Build.Framework;
35 using Microsoft.Build.Utilities;
36
37 using NUnit.Framework;
38
39 namespace MonoTests.Microsoft.Build.Utilities {
40
41         [TestFixture]
42         public class ToolTaskTest {
43
44                 [Test]
45                 public void LogEventsFromTextOutput ()
46                 {
47                         var messages = new[] {
48                                 new {Code = "CS0152", Line = "class1.cs(16,4): error CS0152: The label `case 1:' already occurs in this switch statement" },
49                         };
50
51                         var task = new LogEventsFromTextOutputToolTask ();
52                         foreach (var m in messages) {
53                                 task.LogEventsFromTextOutput (m.Line);
54                                 Assert.IsTrue (task.Codes.Count > 0, "No error logged for line: {0}", m.Line);
55                                 Assert.AreEqual (m.Code, task.Codes [0]);
56                                 task.Codes.Clear ();
57                         }
58                 }
59         }
60
61         class LogEventsFromTextOutputToolTask : ToolTask {
62
63                 public List<string> Codes {
64                         get {return engine.Codes;}
65                 }
66
67                 CodeLoggingBuildEngine engine = new CodeLoggingBuildEngine ();
68
69                 public LogEventsFromTextOutputToolTask ()
70                 {
71                         BuildEngine = engine;
72                 }
73
74                 protected override string GenerateFullPathToTool ()
75                 {
76                         throw new NotImplementedException ();
77                 }
78
79                 protected override string ToolName {
80                         get {throw new NotImplementedException ();}
81                 }
82
83                 public void LogEventsFromTextOutput (string line)
84                 {
85                         base.LogEventsFromTextOutput (line, MessageImportance.Normal);
86                 }
87         }
88
89         class CodeLoggingBuildEngine : IBuildEngine {
90
91                 public List<string> Codes = new List<string> ();
92
93                 public int ColumnNumberOfTaskNode {
94                         get {
95                                 throw new NotImplementedException ();
96                         }
97                 }
98
99                 public bool ContinueOnError {
100                         get {
101                                 throw new NotImplementedException ();
102                         }
103                 }
104
105                 public int LineNumberOfTaskNode {
106                         get {
107                                 throw new NotImplementedException ();
108                         }
109                 }
110
111                 public string ProjectFileOfTaskNode {
112                         get {
113                                 throw new NotImplementedException ();
114                         }
115                 }
116
117                 public bool BuildProjectFile (string projectFileName, string[] targetNames, System.Collections.IDictionary globalProperties, System.Collections.IDictionary targetOutputs)
118                 {
119                         throw new NotImplementedException ();
120                 }
121
122                 public void LogCustomEvent (CustomBuildEventArgs e)
123                 {
124                 }
125
126                 public void LogErrorEvent (BuildErrorEventArgs e)
127                 {
128                         Codes.Add (e.Code);
129                 }
130
131                 public void LogMessageEvent (BuildMessageEventArgs e)
132                 {
133                 }
134
135                 public void LogWarningEvent (BuildWarningEventArgs e)
136                 {
137                         Codes.Add (e.Code);
138                 }
139         }
140 }
141