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