public void ParseMultipleContactsResponse()
{
Console.WriteLine("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
string sipMsg =
"SIP/2.0 200 OK" + m_CRLF +
"Via: SIP/2.0/UDP 192.168.1.32:64226;branch=z9hG4bK-d87543-ac7a6a75bc519655-1--d87543-;rport=64226;received=89.100.104.191" + m_CRLF +
"To: \"253989\"<sip:[email protected]>;tag=cb2000b247d89723001a836145f3b053.5b6c" + m_CRLF +
"From: \"253989\"<sip:[email protected]>;tag=9812dd2f" + m_CRLF +
"Call-ID: ODllYWY1NDJiNGMwYmQ1MjVmZmViMmEyMDViMGM0Y2Y." + m_CRLF +
"CSeq: 2 REGISTER" + m_CRLF +
"Date: Fri, 17 Nov 2006 17:15:35 GMT" + m_CRLF +
"Contact: <sip:[email protected]>;q=0.1;expires=3298, \"Joe Bloggs\"<sip:[email protected]:64226;rinstance=5720c5fed8cbcd34>;q=0.1;expires=3600" + m_CRLF +
"Content-Length: 0" + m_CRLF + m_CRLF;
SIPMessage sipMessage = SIPMessage.ParseSIPMessage(Encoding.UTF8.GetBytes(sipMsg), null, null);
SIPResponse okResp = SIPResponse.ParseSIPResponse(sipMessage);
Console.WriteLine("To: " + okResp.Header.To.ToString());
Assert.AreEqual(SIPResponseStatusCodesEnum.Ok, okResp.Status, "Response should have been ok.");
Assert.AreEqual(okResp.Header.Contact.Count, 2, "Response should have had two contacts.");
Assert.AreEqual(okResp.Header.Contact[0].ContactURI.ToString(), "sip:[email protected]", "The contact URI for the first contact header was incorrect.");
Assert.AreEqual(okResp.Header.Contact[0].Expires, 3298, "The expires value for the first contact header was incorrect.");
Assert.AreEqual(okResp.Header.Contact[0].Q, "0.1", "The q value for the first contact header was incorrect.");
Assert.AreEqual(okResp.Header.Contact[1].ContactName, "Joe Bloggs", "The contact name for the first contact header was incorrect.");
Assert.AreEqual(okResp.Header.Contact[1].ContactURI.ToString(), "sip:[email protected]:64226;rinstance=5720c5fed8cbcd34", "The contact URI for the first contact header was incorrect.");
Assert.AreEqual(okResp.Header.Contact[1].Expires, 3600, "The expires value for the second contact header was incorrect.");
Assert.AreEqual(okResp.Header.Contact[1].Q, "0.1", "The q value for the second contact header was incorrect.");
Console.WriteLine("-----------------------------------------");
}