Example #1
0
        public void NoCharsetProvided(string contentTypeValue)
        {
            var bodyString  = "0123456789abcdefghijk1234567890abcd";
            var command     = StompParser.Command.MESSAGE;
            var header      = new KeyValuePair <string, string>("content-type", contentTypeValue);
            var headerArray = new KeyValuePair <string, string> [1];

            headerArray[0] = header;
            var body = Encoding.UTF8.GetBytes(bodyString);

            var frame = new StompFrame(command, headerArray, body);

            var resultHeader = frame.GetContentTypeHeader();

            Assert.Equal("application/json", resultHeader.ContentType);
            Assert.Equal(Encoding.UTF8, frame.GetContentTypeHeader().GetEncoding());
        }
Example #2
0
        public void SupportEncoding(string charset, Encoding encoding)
        {
            var bodyString  = "0123456789abcdefghijk1234567890abcd";
            var command     = StompParser.Command.MESSAGE;
            var header      = new KeyValuePair <string, string>("content-type", $"application/json;charset={charset}");
            var headerArray = new KeyValuePair <string, string> [1];

            headerArray[0] = header;
            var body = Encoding.UTF8.GetBytes(bodyString);

            var frame = new StompFrame(command, headerArray, body);

            Assert.Equal(encoding, frame.GetContentTypeHeader().GetEncoding());
        }
Example #3
0
        public void EmptyIfNoTypeHeader()
        {
            var bodyString  = "0123456789abcdefghijk1234567890abcd";
            var command     = StompParser.Command.MESSAGE;
            var header      = new KeyValuePair <string, string>("key", "value");
            var headerArray = new KeyValuePair <string, string> [1];

            headerArray[0] = header;
            var body = Encoding.UTF8.GetBytes(bodyString);

            var frame = new StompFrame(command, headerArray, body);

            Assert.Equal(ContentTypeHeader.Empty, frame.GetContentTypeHeader());
        }