Esempio n. 1
0
        public void Display_data_contract_has_not_been_broken()
        {
            var socket    = new TextSocket();
            var sender    = new MessageSender(socket, new SignatureValidator("key", "HMACSHA256"));
            var transient = new Dictionary <string, object> {
                { "display_id", "none" }
            };
            var output      = "some result";
            var displayData = new DisplayData(
                data: new Dictionary <string, object>
            {
                { "text/html", output },
                { "text/plain", output }
            },
                transient: transient);


            var header = new Header(messageType: JupyterMessageContentTypes.DisplayData, messageId: Guid.Empty.ToString(),
                                    version: "5.3", username: Constants.USERNAME, session: "test session",
                                    date: DateTime.MinValue.ToString("yyyy-MM-ddTHH:mm:ssZ"));
            var replyMessage = new Message(header, content: displayData);

            sender.Send(replyMessage);

            var encoded = socket.GetEncodedMessage();

            this.Assent(encoded, _configuration);
        }
Esempio n. 2
0
        public void KernelInfoReply_contract_has_not_been_broken()
        {
            var socket          = new TextSocket();
            var sender          = new MessageSender(socket, new SignatureValidator("key", "HMACSHA256"));
            var kernelInfoReply = new KernelInfoReply(
                Constants.MESSAGE_PROTOCOL_VERSION,
                ".NET",
                "0.0.3",
                new LanguageInfo(
                    name: "C#",
                    version: typeof(string).Assembly.ImageRuntimeVersion.Substring(1),
                    mimeType: "text/x-csharp",
                    fileExtension: ".cs",
                    pygmentsLexer: "c#"
                    ));
            var header = new Header(messageType: JupyterMessageContentTypes.KernelInfoReply, messageId: Guid.Empty.ToString(),
                                    version: Constants.MESSAGE_PROTOCOL_VERSION, username: Constants.USERNAME, session: "test session",
                                    date: DateTime.MinValue.ToString("yyyy-MM-ddTHH:mm:ssZ"));
            var replyMessage = new Message(header, content: kernelInfoReply);

            sender.Send(replyMessage);

            var encoded = socket.GetEncodedMessage();

            this.Assent(encoded, _configuration);
        }
Esempio n. 3
0
        public void Input_cell_honors_custom_metadata()
        {
            var socket    = new TextSocket();
            var sender    = new MessageSender(socket, new SignatureValidator("key", "HMACSHA256"));
            var transient = new Dictionary <string, object> {
                { "display_id", "none" }
            };
            var output        = "some result";
            var executeResult = new ExecuteResult(
                12,
                transient: transient,
                data: new Dictionary <string, object> {
                { "text/html", output },
                { "text/plain", output }
            });

            var header = new Header(messageType: JupyterMessageContentTypes.ExecuteResult, messageId: Guid.Empty.ToString(),
                                    version: "5.3", username: Constants.USERNAME, session: "test session",
                                    date: DateTime.MinValue.ToString("yyyy-MM-ddTHH:mm:ssZ"));

            var metaData = new Dictionary <string, object>
            {
                { "dotnet_interactive", new InputCellMetadata("fsharp") }
            };

            var replyMessage = new Message(header, content: executeResult, metaData: metaData);

            sender.Send(replyMessage);

            var encoded = socket.GetEncodedMessage();

            this.Assent(encoded, _configuration);
        }
Esempio n. 4
0
        public void Complete_reply_contract_has_not_been_broken()
        {
            var socket = new TextSocket();
            var sender = new MessageSender(socket, new SignatureValidator("key", "HMACSHA256"));

            var completeReply = new CompleteReply(0, 0, matches: new List <string> {
                "Write", "WriteLine"
            });

            var header = new Header(messageType: JupyterMessageContentTypes.CompleteReply, messageId: Guid.Empty.ToString(),
                                    version: "5.3", username: Constants.USERNAME, session: "test session",
                                    date: DateTime.MinValue.ToString("yyyy-MM-ddTHH:mm:ssZ"));

            var replyMessage = new Message(header, content: completeReply);

            sender.Send(replyMessage);

            var encoded = socket.GetEncodedMessage();

            this.Assent(encoded, _configuration);
        }