Parse() public static method

public static Parse ( string presenceXMLStr ) : SIPEventPresence
presenceXMLStr string
return SIPEventPresence
Example #1
0
            public void ParseFromXMLStringUnitTest()
            {
                Console.WriteLine("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);

                string presenceXMLStr = "<?xml version='1.0' encoding='utf-16'?>" +
                                        "<presence entity='sip:[email protected]' xmlns='urn:ietf:params:xml:ns:pidf'>" +
                                        " <tuple id='as7d900as8'>" +
                                        "  <status>" +
                                        "   <basic>open</basic>" +
                                        "  </status>" +
                                        "  <contact priority='1.2'>sip:[email protected]</contact>" +
                                        " </tuple>" +
                                        "</presence>";

                SIPEventPresence presence = SIPEventPresence.Parse(presenceXMLStr);

                Assert.IsTrue(presence.Entity.ToString() == "sip:[email protected]", "The parsed presence event entity was incorrect.");
                Assert.IsTrue(presence.Tuples.Count == 1, "The parsed presence event tuple number was incorrect.");
                Assert.IsTrue(presence.Tuples[0].ID == "as7d900as8", "The parsed presence event first tuple ID was incorrect.");
                Assert.IsTrue(presence.Tuples[0].Status == SIPEventPresenceStateEnum.open, "The parsed presence event first tuple status was incorrect.");
                Assert.IsTrue(presence.Tuples[0].ContactURI.ToString() == "sip:[email protected]", "The parsed presence event first tuple Contact URI was incorrect.");
                Assert.IsTrue(presence.Tuples[0].ContactPriority == 1.2M, "The parsed presence event first tuple Contact priority was incorrect.");

                Console.WriteLine("-----------------------------------------");
            }