5 // Jonathan Pryor (jonp@xamarin.com)
7 // (C) 2013 Xamarin Inc.
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:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
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.
29 using System.Collections.Generic;
30 using System.Diagnostics;
34 using Microsoft.Build.Framework;
35 using Microsoft.Build.Utilities;
37 using NUnit.Framework;
39 namespace MonoTests.Microsoft.Build.Utilities {
42 public class ToolTaskTest {
45 public void LogEventsFromTextOutput ()
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" },
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]);
61 class LogEventsFromTextOutputToolTask : ToolTask {
63 public List<string> Codes {
64 get {return engine.Codes;}
67 CodeLoggingBuildEngine engine = new CodeLoggingBuildEngine ();
69 public LogEventsFromTextOutputToolTask ()
74 protected override string GenerateFullPathToTool ()
76 throw new NotImplementedException ();
79 protected override string ToolName {
80 get {throw new NotImplementedException ();}
83 public void LogEventsFromTextOutput (string line)
85 base.LogEventsFromTextOutput (line, MessageImportance.Normal);
89 class CodeLoggingBuildEngine : IBuildEngine {
91 public List<string> Codes = new List<string> ();
93 public int ColumnNumberOfTaskNode {
95 throw new NotImplementedException ();
99 public bool ContinueOnError {
101 throw new NotImplementedException ();
105 public int LineNumberOfTaskNode {
107 throw new NotImplementedException ();
111 public string ProjectFileOfTaskNode {
113 throw new NotImplementedException ();
117 public bool BuildProjectFile (string projectFileName, string[] targetNames, System.Collections.IDictionary globalProperties, System.Collections.IDictionary targetOutputs)
119 throw new NotImplementedException ();
122 public void LogCustomEvent (CustomBuildEventArgs e)
126 public void LogErrorEvent (BuildErrorEventArgs e)
131 public void LogMessageEvent (BuildMessageEventArgs e)
135 public void LogWarningEvent (BuildWarningEventArgs e)