| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
using System; |
| 5 |
using System.Collections; |
| 6 |
using System.Collections.Generic; |
| 7 |
using System.IO; |
| 8 |
using System.Linq; |
| 9 |
using System.Reflection; |
| 10 |
using System.Text; |
| 11 |
using System.Threading.Tasks; |
| 12 |
using Microsoft.Build.Framework; |
| 13 |
|
| 14 |
namespace Microsoft.NuGet.Build.Tasks.Tests.Helpers |
| 15 |
{ |
| 16 |
public class MockBuildEngine : IBuildEngine, IBuildEngine2, IBuildEngine3, IBuildEngine4 |
| 17 |
{ |
| 18 |
public MockBuildEngine(TextWriter output) |
| 19 |
{ |
| 20 |
this.Output = output; |
| 21 |
} |
| 22 |
|
| 23 |
private TextWriter Output { get; } |
| 24 |
|
| 25 |
int IBuildEngine.ColumnNumberOfTaskNode => -1; |
| 26 |
|
| 27 |
bool IBuildEngine.ContinueOnError => false; |
| 28 |
|
| 29 |
int IBuildEngine.LineNumberOfTaskNode => -1; |
| 30 |
|
| 31 |
string IBuildEngine.ProjectFileOfTaskNode => "this.xml"; |
| 32 |
|
| 33 |
bool IBuildEngine2.IsRunningMultipleNodes => false; |
| 34 |
|
| 35 |
bool IBuildEngine.BuildProjectFile(string projectFileName, string[] targetNames, IDictionary globalProperties, IDictionary targetOutputs) => true; |
| 36 |
|
| 37 |
void IBuildEngine.LogCustomEvent(CustomBuildEventArgs e) |
| 38 |
{ |
| 39 |
this.Output.WriteLine($"Custom: {e.Message}"); |
| 40 |
} |
| 41 |
|
| 42 |
void IBuildEngine.LogErrorEvent(BuildErrorEventArgs e) |
| 43 |
{ |
| 44 |
this.Output.WriteLine($"Error: {e.Message}"); |
| 45 |
} |
| 46 |
|
| 47 |
void IBuildEngine.LogMessageEvent(BuildMessageEventArgs e) |
| 48 |
{ |
| 49 |
this.Output.WriteLine($"Message: {e.Message}"); |
| 50 |
} |
| 51 |
|
| 52 |
void IBuildEngine.LogWarningEvent(BuildWarningEventArgs e) |
| 53 |
{ |
| 54 |
this.Output.WriteLine($"Warning: {e.Message}"); |
| 55 |
} |
| 56 |
|
| 57 |
private Dictionary<object, object> Tasks = new Dictionary<object, object>(); |
| 58 |
|
| 59 |
void IBuildEngine4.RegisterTaskObject(object key, object obj, RegisteredTaskObjectLifetime lifetime, bool allowEarlyCollection) |
| 60 |
{ |
| 61 |
Tasks.Add(key, obj); |
| 62 |
} |
| 63 |
|
| 64 |
object IBuildEngine4.GetRegisteredTaskObject(object key, RegisteredTaskObjectLifetime lifetime) |
| 65 |
{ |
| 66 |
return null; |
| 67 |
} |
| 68 |
|
| 69 |
object IBuildEngine4.UnregisterTaskObject(object key, RegisteredTaskObjectLifetime lifetime) |
| 70 |
{ |
| 71 |
var obj = Tasks[key]; |
| 72 |
Tasks.Remove(key); |
| 73 |
return obj; |
| 74 |
} |
| 75 |
|
| 76 |
BuildEngineResult IBuildEngine3.BuildProjectFilesInParallel(string[] projectFileNames, string[] targetNames, IDictionary[] globalProperties, IList<string>[] removeGlobalProperties, string[] toolsVersion, bool returnTargetOutputs) |
| 77 |
{ |
| 78 |
throw new NotImplementedException(); |
| 79 |
} |
| 80 |
|
| 81 |
void IBuildEngine3.Yield() { } |
| 82 |
|
| 83 |
void IBuildEngine3.Reacquire() { } |
| 84 |
|
| 85 |
bool IBuildEngine2.BuildProjectFile(string projectFileName, string[] targetNames, IDictionary globalProperties, IDictionary targetOutputs, string toolsVersion) => true; |
| 86 |
|
| 87 |
bool IBuildEngine2.BuildProjectFilesInParallel(string[] projectFileNames, string[] targetNames, IDictionary[] globalProperties, IDictionary[] targetOutputsPerProject, string[] toolsVersion, bool useResultsCache, bool unloadProjectsOnCompletion) => true; |
| 88 |
} |
| 89 |
} |