Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions NEventSocket.Tests/Sockets/MessageParsingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,27 @@ public void it_should_parse_Command_Reply_ERR()
Console.WriteLine(reply);
}

[Fact]
public void it_should_parse_empty_string_when_empty_Command_Reply_ERR()
{
var parser = new Parser();
var rawInput = "Content-Type: command/reply\nReply-Text: -ERR\n\n";

foreach (char c in rawInput)
{
parser.Append(c);
}

Assert.True(parser.Completed);

var reply = new CommandReply(parser.ExtractMessage());
Assert.NotNull(reply);
Assert.False(reply.Success);
Assert.Equal(string.Empty, reply.ErrorMessage);

Console.WriteLine(reply);
}

[Fact]
public void it_should_parse_Api_Response_OK()
{
Expand Down Expand Up @@ -216,6 +237,26 @@ public void it_should_parse_Api_Response_ERR()
Console.WriteLine(response);
}

[Fact]
public void it_should_parse_empty_string_when_empty_Api_Response_ERR()
{
var parser = new Parser();
var rawInput = "Content-Type: api/response\nContent-Length: 4\n\n-ERR";

foreach (char c in rawInput)
{
parser.Append(c);
}

Assert.True(parser.Completed);

var response = new ApiResponse(parser.ExtractMessage());
Assert.False(response.Success);
Assert.Equal(string.Empty, response.ErrorMessage);

Console.WriteLine(response);
}

[Fact]
public void it_should_treat_Api_Response_ERR_no_reply_as_Success()
{
Expand Down
2 changes: 1 addition & 1 deletion NEventSocket/FreeSwitch/ApiResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public string ErrorMessage
{
get
{
return BodyText != null && BodyText.StartsWith("-ERR")
return BodyText != null && BodyText.StartsWith("-ERR ")
? BodyText.Substring(5, BodyText.Length - 5)
: string.Empty;
}
Expand Down
2 changes: 1 addition & 1 deletion NEventSocket/FreeSwitch/CommandReply.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public string ErrorMessage
{
get
{
return ReplyText != null && ReplyText.StartsWith("-ERR")
return ReplyText != null && ReplyText.StartsWith("-ERR ")
? ReplyText.Substring(5, ReplyText.Length - 5)
: string.Empty;
}
Expand Down