public void ShouldHandleIssue235() { string code = @"using AgileObjects.AgileMapper; public class TestClass { public TestClass() { IMapper mapper = Mapper.CreateNew(); } }"; string script = @"#r ""nuget: AgileObjects.AgileMapper, 0.23.1"" #r ""TestLibrary.dll"" using AgileObjects.AgileMapper; IMapper mapper = Mapper.CreateNew(); var testClass = new TestClass(); Console.WriteLine(""Hello World!"");"; using (var disposableFolder = new DisposableFolder()) { var projectFolder = Path.Combine(disposableFolder.Path, "TestLibrary"); ProcessHelper.RunAndCaptureOutput("dotnet", new[] { "new classlib -n TestLibrary" }, disposableFolder.Path); ProcessHelper.RunAndCaptureOutput("dotnet", new[] { "add TestLibrary.csproj package AgileObjects.AgileMapper -v 0.23.0" }, projectFolder); File.WriteAllText(Path.Combine(projectFolder, "Class1.cs"), code); File.WriteAllText(Path.Combine(projectFolder, "script.csx"), script); ProcessHelper.RunAndCaptureOutput("dotnet", new[] { "build -c release -o ./" }, projectFolder); var dotnetScriptArguments = GetDotnetScriptArguments(Path.Combine(projectFolder, "script.csx")); var result = ProcessHelper.RunAndCaptureOutput("dotnet", dotnetScriptArguments); Assert.Contains("Hello World!", result.output); } }
public void ShouldRegisterToRunCsxScriptDirectly() { using (var scriptFolder = new DisposableFolder()) { var(output, exitCode) = ScriptTestRunner.Default.Execute("init", scriptFolder.Path); Assert.True(exitCode == 0, output); var scriptPath = Path.Combine(scriptFolder.Path, "main.csx"); if (ScriptEnvironment.Default.IsWindows) { (output, exitCode) = ProcessHelper.RunAndCaptureOutput("reg.exe", @"query HKCU\Software\Classes\.csx"); Assert.Equal(0, exitCode); (output, exitCode) = ProcessHelper.RunAndCaptureOutput("reg.exe", @"query HKCU\software\classes\dotnetscript\Shell\Open\Command"); Assert.Equal(0, exitCode); Assert.Matches(new Regex(@" \b REG_EXPAND_SZ # type [ ]+ ""%ProgramFiles%\\dotnet\\dotnet.exe"" # unexpanded %ProgramFiles% + quoted [ ]+ exec [ ]+ ""([A-Z]:|\\)\\(.+?)\\dotnet-script.dll"" # absolute + quoted [ ]+ ""%1"" # quoted [ ]+ -- [ ]+ %\* # unquoted ", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.IgnorePatternWhitespace), output); } else { var text = File.ReadAllText(scriptPath); Assert.True(text.StartsWith("#!/usr/bin/env dotnet-script"), "should have shebang"); Assert.True(text.IndexOf("\r\n") < 0, "should have not have windows cr/lf"); } } }
private (string output, int exitCode) ExecuteCodeInReleaseMode(string code) { var result = ProcessHelper.RunAndCaptureOutput("dotnet", GetDotnetScriptArguments($"-c", new[] { "release", "eval", $"\"{code}\"" })); return(result); }
private (string output, int exitCode) Execute(string fixture, params string[] arguments) { var result = ProcessHelper.RunAndCaptureOutput("dotnet", GetDotnetScriptArguments(Path.Combine("..", "..", "..", "TestFixtures", fixture), arguments)); return(result); }
private static (string output, int exitCode) Execute(string args, string workingDirectory) { var result = ProcessHelper.RunAndCaptureOutput("dotnet", GetDotnetScriptArguments(args), workingDirectory); return(result); }
public (string output, int exitCode) Execute(params string[] arguments) { var result = ProcessHelper.RunAndCaptureOutput("dotnet", GetDotnetScriptArguments(arguments)); return(result); }
public (string output, int exitCode) ExecuteCodeInReleaseMode(string code) { var result = ProcessHelper.RunAndCaptureOutput("dotnet", GetDotnetScriptArguments($"-c release eval \"{code}\"")); return(result); }