private TestHostContext CreateTestContext([CallerMemberName] String testName = "") { var hc = new TestHostContext(this, testName); var expressionManager = new ExpressionManager(); expressionManager.Initialize(hc); hc.SetSingleton <IExpressionManager>(expressionManager); Dictionary <string, VariableValue> variablesToCopy = new Dictionary <string, VariableValue>(); _variables = new Variables( hostContext: hc, copy: variablesToCopy); _ec = new Mock <IExecutionContext>(); _ec.SetupAllProperties(); _ec.Setup(x => x.Variables).Returns(_variables); _contexts = new DictionaryContextData(); _jobContext = new JobContext(); _contexts["github"] = new DictionaryContextData(); _contexts["runner"] = new DictionaryContextData(); _contexts["job"] = _jobContext; _ec.Setup(x => x.ExpressionValues).Returns(_contexts); _ec.Setup(x => x.JobContext).Returns(_jobContext); _stepContext = new StepsContext(); _ec.Setup(x => x.StepsContext).Returns(_stepContext); _ec.Setup(x => x.PostJobSteps).Returns(new Stack <IStep>()); _stepsRunner = new StepsRunner(); _stepsRunner.Initialize(hc); return(hc); }
private TestHostContext CreateTestContext([CallerMemberName] String testName = "") { var hc = new TestHostContext(this, testName); _ec = new Mock <IExecutionContext>(); _ec.SetupAllProperties(); _stepsRunner = new StepsRunner(); _stepsRunner.Initialize(hc); return(hc); }
private TestHostContext CreateTestContext([CallerMemberName] String testName = "") { var hc = new TestHostContext(this, testName); List <string> warnings; _variables = new Variables( hostContext: hc, copy: new Dictionary <string, string>(), maskHints: new List <MaskHint>(), warnings: out warnings); _ec = new Mock <IExecutionContext>(); _ec.SetupAllProperties(); _ec.Setup(x => x.Variables).Returns(_variables); _stepsRunner = new StepsRunner(); _stepsRunner.Initialize(hc); return(hc); }
private TestHostContext CreateTestContext([CallerMemberName] String testName = "") { var hc = new TestHostContext(this, testName); Dictionary <string, VariableValue> variablesToCopy = new Dictionary <string, VariableValue>(); _variables = new Variables( hostContext: hc, copy: variablesToCopy); _env = new Dictionary <string, string>() { { "env1", "1" }, { "test", "github_actions" } }; _ec = new Mock <IExecutionContext>(); _ec.SetupAllProperties(); _ec.Setup(x => x.Global).Returns(new GlobalContext { WriteDebug = true }); _ec.Object.Global.Variables = _variables; _ec.Object.Global.EnvironmentVariables = _env; _contexts = new DictionaryContextData(); _jobContext = new JobContext(); _contexts["github"] = new GitHubContext(); _contexts["runner"] = new DictionaryContextData(); _contexts["job"] = _jobContext; _ec.Setup(x => x.ExpressionValues).Returns(_contexts); _ec.Setup(x => x.ExpressionFunctions).Returns(new List <IFunctionInfo>()); _ec.Setup(x => x.JobContext).Returns(_jobContext); _stepContext = new StepsContext(); _ec.Object.Global.StepsContext = _stepContext; _ec.Setup(x => x.PostJobSteps).Returns(new Stack <IStep>()); var trace = hc.GetTrace(); _ec.Setup(x => x.Write(It.IsAny <string>(), It.IsAny <string>())).Callback((string tag, string message) => { trace.Info($"[{tag}]{message}"); }); _stepsRunner = new StepsRunner(); _stepsRunner.Initialize(hc); return(hc); }
private TestHostContext CreateTestContext([CallerMemberName] String testName = "") { var hc = new TestHostContext(this, testName); var expressionManager = new ExpressionManager(); expressionManager.Initialize(hc); hc.SetSingleton <IExpressionManager>(expressionManager); Dictionary <string, VariableValue> variablesToCopy = new Dictionary <string, VariableValue>(); _variables = new Variables( hostContext: hc, copy: variablesToCopy); _env = new Dictionary <string, string>() { { "env1", "1" }, { "test", "github_actions" } }; _ec = new Mock <IExecutionContext>(); _ec.SetupAllProperties(); _ec.Setup(x => x.Variables).Returns(_variables); _contexts = new DictionaryContextData(); _jobContext = new JobContext(); _contexts["github"] = new DictionaryContextData(); _contexts["runner"] = new DictionaryContextData(); _contexts["job"] = _jobContext; _ec.Setup(x => x.ExpressionValues).Returns(_contexts); _ec.Setup(x => x.JobContext).Returns(_jobContext); _stepContext = new StepsContext(); _ec.Setup(x => x.StepsContext).Returns(_stepContext); _ec.Setup(x => x.PostJobSteps).Returns(new Stack <IStep>()); var trace = hc.GetTrace(); _ec.Setup(x => x.Write(It.IsAny <string>(), It.IsAny <string>())).Callback((string tag, string message) => { trace.Info($"[{tag}]{message}"); }); _stepsRunner = new StepsRunner(); _stepsRunner.Initialize(hc); return(hc); }
private TestHostContext CreateTestContext([CallerMemberName] String testName = "") { var hc = new TestHostContext(this, testName); var expressionManager = new ExpressionManager(); expressionManager.Initialize(hc); hc.SetSingleton <IExpressionManager>(expressionManager); List <string> warnings; _variables = new Variables( hostContext: hc, copy: new Dictionary <string, VariableValue>(), warnings: out warnings); _ec = new Mock <IExecutionContext>(); _ec.SetupAllProperties(); _ec.Setup(x => x.Variables).Returns(_variables); _stepsRunner = new StepsRunner(); _stepsRunner.Initialize(hc); return(hc); }
private TestHostContext CreateTestContext([CallerMemberName] String testName = "") { var hc = new TestHostContext(this, testName); var expressionManager = new ExpressionManager(); expressionManager.Initialize(hc); hc.SetSingleton <IExpressionManager>(expressionManager); Dictionary <string, VariableValue> variablesToCopy = new Dictionary <string, VariableValue>(); variablesToCopy.Add(Constants.Variables.Agent.RetainDefaultEncoding, new VariableValue("true", false)); List <string> warnings; _variables = new Variables( hostContext: hc, copy: variablesToCopy, warnings: out warnings); _ec = new Mock <IExecutionContext>(); _ec.SetupAllProperties(); _ec.Setup(x => x.Variables).Returns(_variables); _stepsRunner = new StepsRunner(); _stepsRunner.Initialize(hc); return(hc); }