/
EvilBeaver
/
OneScript
Обзор
Документация
Войти
/
EvilBeaver
/
OneScript
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
v1.8.4
src/NUnitTests/EngineWrapperNUnit.cs
86 строк
2 KB
EvilBeaver
Глобальная чистка неиспользуемых using
24 дек 2021, 11:01
24 дек 2021, 11:01
c343f53
Код
Авторство
О чём код?
/*---------------------------------------------------------- This Source Code Form is subject to the terms of the Mozilla Public License, v.2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ----------------------------------------------------------*/ using System; using ScriptEngine; using ScriptEngine.Environment; using ScriptEngine.HostedScript; using ScriptEngine.HostedScript.Library; namespace NUnitTests { internal class EngineWrapperNUnit : IHostApplication { private string[] commandLineArgs; public HostedScriptEngine Engine { get; private set; } public HostedScriptEngine StartEngine() { Engine = new HostedScriptEngine(); Engine.Initialize(); commandLineArgs = new string[] { }; return Engine; } public int RunTestString(string source) { var process = Engine.CreateProcess(this, Engine.Loader.FromString(source)); return process.Start(); } private int RunTestScript(ICodeSource source, string resourceName) { var module = Engine.GetCompilerService().Compile(source); Engine.LoadUserScript(new UserAddedScript { Type = UserAddedScriptType.Class, Image = module, Symbol = resourceName }); var process = Engine.CreateProcess(this, source); return process.Start(); } internal int RunTestScriptFromPath(string scriptFilePath, string argsScript = "") { if (argsScript != "") commandLineArgs = argsScript.Split(' '); var sourceToCompile = Engine.Loader.FromFile(scriptFilePath); return RunTestScript(sourceToCompile, scriptFilePath); } public string[] GetCommandLineArguments() { return commandLineArgs; } public bool InputString(out string result, string prompt, int maxLen, bool multiline) { result = ""; return false; } public void ShowExceptionInfo(Exception exc) { throw exc; } public void Echo(string str, MessageStatusEnum status = MessageStatusEnum.Ordinary) { Console.WriteLine(str); } } }