public async Task it_returns_completion_list_for_types_imported_at_runtime(Language language) { var kernel = CreateKernel(language); var dll = new FileInfo(typeof(JsonConvert).Assembly.Location).FullName; var code = language switch { Language.CSharp => $"#r \"{dll}\"", Language.FSharp => $"#r @\"{dll}\"" }; await kernel.SendAsync(new SubmitCode(code)); await kernel.SendAsync(new RequestCompletions("Newtonsoft.Json.JsonConvert.", new LinePosition(0, 28))); KernelEvents.Should() .ContainSingle(e => e is CompletionRequestReceived); KernelEvents.Single(e => e is CompletionsProduced) .As <CompletionsProduced>() .Completions .Should() .Contain(i => i.DisplayText == "SerializeObject"); }
public async Task it_can_cancel_execution(Language language) { var kernel = CreateKernel(language); var source = language switch { Language.FSharp => "System.Threading.Thread.Sleep(3000)\r\n2", Language.CSharp => "System.Threading.Thread.Sleep(3000);2" }; var submitCodeCommand = new SubmitCode(source); var codeSubmission = kernel.SendAsync(submitCodeCommand); var interruptionCommand = new CancelCurrentCommand(); await kernel.SendAsync(interruptionCommand); await codeSubmission; // verify cancel command KernelEvents .Single(e => e is CurrentCommandCancelled); // verify failure KernelEvents .OfType <CommandFailed>() .Should() .BeEquivalentTo(new CommandFailed(null, interruptionCommand, "Command cancelled")); // verify `2` isn't evaluated and returned KernelEvents .OfType <ReturnValueProduced>() .Should() .BeEmpty(); }
public async Task it_returns_completion_list_for_types() { var kernel = await CreateKernelAsync(); await kernel.SendAsync(new RequestCompletion("System.Console.", 15)); KernelEvents.Should() .ContainSingle(e => e is CompletionRequestReceived); KernelEvents.Single(e => e is CompletionRequestCompleted) .As <CompletionRequestCompleted>() .CompletionList .Should() .Contain(i => i.DisplayText == "ReadLine"); }
public async Task it_returns_completion_list_for_previously_declared_variables() { var kernel = await CreateKernelAsync(); await kernel.SendAsync( new SubmitCode("var alpha = new Random();")); await kernel.SendAsync(new RequestCompletion("al", 2)); KernelEvents.Should() .ContainSingle(e => e is CompletionRequestReceived); KernelEvents.Single(e => e is CompletionRequestCompleted) .As <CompletionRequestCompleted>() .CompletionList .Should() .Contain(i => i.DisplayText == "alpha"); }
// no F# equivalent, because it doesn't have the concept of complete/incomplete submissions public async Task it_can_analyze_incomplete_submissions(Language language) { var kernel = CreateKernel(language); var source = language switch { Language.CSharp => "var a =", Language.PowerShell => "$a =" }; await SubmitCode(kernel, source, submissionType : SubmissionType.Diagnose); KernelEvents .Single(e => e is IncompleteCodeSubmissionReceived); KernelEvents .Should() .Contain(e => e is IncompleteCodeSubmissionReceived); }
public async Task it_returns_completion_list_for_types_imported_at_runtime() { var kernel = CreateKernel(); var dll = new FileInfo(typeof(JsonConvert).Assembly.Location).FullName; await kernel.SendAsync( new SubmitCode($"#r \"{dll}\"")); await kernel.SendAsync(new RequestCompletion("Newtonsoft.Json.JsonConvert.", 28)); KernelEvents.Should() .ContainSingle(e => e is CompletionRequestReceived); KernelEvents.Single(e => e is CompletionRequestCompleted) .As <CompletionRequestCompleted>() .CompletionList .Should() .Contain(i => i.DisplayText == "SerializeObject"); }