public async Task pound_r_is_not_split_into_separate_command_from_csharp_code() { var receivedCommands = new List <IKernelCommand>(); using var kernel = new CSharpKernel(); kernel.AddMiddleware((command, context, next) => { receivedCommands.Add(command); return(Task.CompletedTask); }); kernel.UseNugetDirective(); var path = Path.GetTempFileName(); var poundR_and_usingStatement = $@"#r ""{path}""{Environment.NewLine}using Some.Namespace;"; var nextSubmission = "// the code"; kernel.DeferCommand(new SubmitCode(poundR_and_usingStatement)); await kernel.SubmitCodeAsync(nextSubmission); receivedCommands .Cast <SubmitCode>() .Select(c => c.Code.Trim()) .Should() .BeEquivalentSequenceTo( poundR_and_usingStatement, nextSubmission); }
public async Task When_SubmitCode_command_adds_packages_to_csharp_kernel_then_the_submission_is_not_passed_to_csharpScript() { using var cSharpKernel = new CSharpKernel(); using var events = cSharpKernel.KernelEvents.ToSubscribedList(); var kernel = new CompositeKernel { cSharpKernel.UseNugetDirective() }; var command = new SubmitCode("#r \"nuget:Microsoft.ML, 1.3.1\" \nvar a = new List<int>();"); await kernel.SendAsync(command); events .OfType <CodeSubmissionReceived>() .Should() .NotContain(e => e.Code.Contains("#r")); }