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: MessageTypeValues.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);
        }
        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(

                "5.3",
                ".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: MessageTypeValues.KernelInfoReply, 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: kernelInfoReply);

            sender.Send(replyMessage);

            var encoded = socket.GetEncodedMessage();

            this.Assent(encoded, _configuration);
        }
        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: MessageTypeValues.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);
        }
Ejemplo n.º 4
0
        public void Execute_result_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 executeResult = new ExecuteResult
            {
                Data = new JObject
                {
                    { "text/html", output },
                    { "text/plain", output }
                },
                Transient      = transient,
                ExecutionCount = 12
            };

            var header = new Header
            {
                Username    = Constants.USERNAME,
                Session     = "test session",
                MessageId   = Guid.Empty.ToString(),
                MessageType = MessageTypeValues.ExecuteResult,
                Date        = DateTime.MinValue.ToString("yyyy-MM-ddTHH:mm:ssZ"),
                Version     = "5.3"
            };
            var replyMessage = new Message
            {
                Header  = header,
                Content = executeResult
            };

            sender.Send(replyMessage);

            var encoded = socket.GetEncodedMessage();

            this.Assent(encoded, _configuration);
        }
Ejemplo n.º 5
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
            {
                ProtocolVersion       = "5.3",
                Implementation        = ".NET",
                ImplementationVersion = "0.0.3",
                LanguageInfo          = new LanguageInfo
                {
                    Name          = "C#",
                    Version       = typeof(string).Assembly.ImageRuntimeVersion.Substring(1),
                    MimeType      = "text/x-csharp",
                    FileExtension = ".cs",
                    PygmentsLexer = "c#"
                }
            };
            var header = new Header
            {
                Username    = Constants.USERNAME,
                Session     = "test session",
                MessageId   = Guid.Empty.ToString(),
                MessageType = MessageTypeValues.KernelInfoReply,
                Date        = DateTime.MinValue.ToString("yyyy-MM-ddTHH:mm:ssZ"),
                Version     = "5.3"
            };
            var replyMessage = new Message
            {
                Header  = header,
                Content = kernelInfoReply
            };

            sender.Send(replyMessage);

            var encoded = socket.GetEncodedMessage();

            this.Assent(encoded, _configuration);
        }