Welcome to mirror list, hosted at ThFree Co, Russian Federation.

MockBuildEngine.cs « Helpers « Microsoft.NuGet.Build.Tasks.Tests « src - github.com/mono/NuGet.BuildTasks.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8686871d7b1d74ad887a43b6b736a8e09b38e61e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Copyright (c) .NET Foundation. All rights reserved. 
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Build.Framework;

namespace Microsoft.NuGet.Build.Tasks.Tests.Helpers
{
    public class MockBuildEngine : IBuildEngine, IBuildEngine2, IBuildEngine3, IBuildEngine4
    {
        public MockBuildEngine(TextWriter output)
        {
            this.Output = output;
        }

        private TextWriter Output { get; }

        int IBuildEngine.ColumnNumberOfTaskNode => -1;

        bool IBuildEngine.ContinueOnError => false;

        int IBuildEngine.LineNumberOfTaskNode => -1;

        string IBuildEngine.ProjectFileOfTaskNode => "this.xml";

        bool IBuildEngine2.IsRunningMultipleNodes => false;

        bool IBuildEngine.BuildProjectFile(string projectFileName, string[] targetNames, IDictionary globalProperties, IDictionary targetOutputs) => true;

        void IBuildEngine.LogCustomEvent(CustomBuildEventArgs e)
        {
            this.Output.WriteLine($"Custom: {e.Message}");
        }

        void IBuildEngine.LogErrorEvent(BuildErrorEventArgs e)
        {
            this.Output.WriteLine($"Error: {e.Message}");
        }

        void IBuildEngine.LogMessageEvent(BuildMessageEventArgs e)
        {
            this.Output.WriteLine($"Message: {e.Message}");
        }

        void IBuildEngine.LogWarningEvent(BuildWarningEventArgs e)
        {
            this.Output.WriteLine($"Warning: {e.Message}");
        }

        private Dictionary<object, object> Tasks = new Dictionary<object, object>();

        void IBuildEngine4.RegisterTaskObject(object key, object obj, RegisteredTaskObjectLifetime lifetime, bool allowEarlyCollection)
        {
            Tasks.Add(key, obj);
        }

        object IBuildEngine4.GetRegisteredTaskObject(object key, RegisteredTaskObjectLifetime lifetime)
        {
            return null;
        }

        object IBuildEngine4.UnregisterTaskObject(object key, RegisteredTaskObjectLifetime lifetime)
        {
            var obj = Tasks[key];
            Tasks.Remove(key);
            return obj;
        }

        BuildEngineResult IBuildEngine3.BuildProjectFilesInParallel(string[] projectFileNames, string[] targetNames, IDictionary[] globalProperties, IList<string>[] removeGlobalProperties, string[] toolsVersion, bool returnTargetOutputs)
        {
            throw new NotImplementedException();
        }

        void IBuildEngine3.Yield() { }

        void IBuildEngine3.Reacquire() { }

        bool IBuildEngine2.BuildProjectFile(string projectFileName, string[] targetNames, IDictionary globalProperties, IDictionary targetOutputs, string toolsVersion) => true;

        bool IBuildEngine2.BuildProjectFilesInParallel(string[] projectFileNames, string[] targetNames, IDictionary[] globalProperties, IDictionary[] targetOutputsPerProject, string[] toolsVersion, bool useResultsCache, bool unloadProjectsOnCompletion) => true;
    }
}