예제 #1
0
파일: Tests.cs 프로젝트: tomlane/REstomp
        public void HandleValidIntStrings()
        {
            var bodyString  = "0123456789abcdefghijk1234567890abcd";
            var command     = StompParser.Command.MESSAGE;
            var header      = new KeyValuePair <string, string>("content-length", bodyString.Length.ToString());
            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(bodyString.Length, frame.GetContentLengthHeader().ContentLength);
        }
예제 #2
0
파일: Tests.cs 프로젝트: tomlane/REstomp
        public void EmptyIfNoLengthHeader()
        {
            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(ContentLengthHeader.Empty, frame.GetContentLengthHeader());
        }
예제 #3
0
파일: Tests.cs 프로젝트: tomlane/REstomp
        public void ThrowExceptionIfInvalid()
        {
            var bodyString  = "0123456789abcdefghijk1234567890abcd";
            var command     = StompParser.Command.MESSAGE;
            var header      = new KeyValuePair <string, string>("content-length", "thirty-five");
            var headerArray = new KeyValuePair <string, string> [1];

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

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

            Assert.Throws <ContentLengthException>(() =>
            {
                frame.GetContentLengthHeader();
            });
        }