Exemplo n.º 1
0
        public async Task <int> Run(CSharpRepl repl, IClusterClient client)
        {
            try {
                var querier = client.GetGrain <IGenericQuerier>(0);
                var res     = await querier.Query(Name.AsImmutable());

                IFormatter formatter = new BinaryFormatter();
                Stream     stream    = new MemoryStream(res.Value.Item2, false);
                var        obj       = formatter.Deserialize(stream);
                stream.Close();

                if (VariableName != null)
                {
                    await repl.AddToState(obj, VariableName, res.Value.Item1);
                }
                else
                {
                    await repl.Display(obj, res.Value.Item1);
                }
                return(0);
            }
            catch (Exception e) {
                Console.WriteLine(e.Message);
                return(1);
            }
        }
Exemplo n.º 2
0
 public async Task handles_executeRequest()
 {
     var kernel  = new CSharpRepl();
     var handler = new ExecuteRequestHandler(kernel);
     var request = Message.Create(new ExecuteRequest("var a =12;"), null);
     await handler.Handle(new JupyterRequestContext(_serverChannel, _ioPubChannel, request, _kernelStatus));
 }
Exemplo n.º 3
0
        public void cannot_handle_requests_that_are_not_executeRequest()
        {
            var         kernel          = new CSharpRepl();
            var         handler         = new CompleteRequestHandler(kernel);
            var         request         = Message.Create(new DisplayData(), null);
            Func <Task> messageHandling = () => handler.Handle(new JupyterRequestContext(_serverChannel, _ioPubChannel, request, _kernelStatus));

            messageHandling.Should().ThrowExactly <InvalidOperationException>();
        }
Exemplo n.º 4
0
        public async Task sends_ExecuteReply_message_on_codeSubmissionEvaluated()
        {
            var kernel = new CSharpRepl();

            var handler = new ExecuteRequestHandler(kernel);
            var request = Message.Create(new ExecuteRequest("var a =12;"), null);
            await handler.Handle(new JupyterRequestContext(_serverChannel, _ioPubChannel, request, _kernelStatus));

            _serverRecordingSocket.DecodedMessages
            .Should().Contain(message =>
                              message.Contains(MessageTypeValues.ExecuteReply));
        }
Exemplo n.º 5
0
        public async Task sends_executeReply_with_error_message_on_codeSubmissionEvaluated()
        {
            var kernel = new CSharpRepl();

            var handler = new ExecuteRequestHandler(kernel);
            var request = Message.Create(new ExecuteRequest("asdes"), null);
            await handler.Handle(new JupyterRequestContext(_serverChannel, _ioPubChannel, request, _kernelStatus));

            _serverRecordingSocket.DecodedMessages
            .Should()
            .Contain(message => message.Contains(MessageTypeValues.ExecuteReply))
            .And
            .Contain(message => message.Contains($"\"status\":\"{StatusValues.Error}\""));

            _ioRecordingSocket.DecodedMessages
            .Should().Contain(message =>
                              message.Contains(MessageTypeValues.Stream));
        }