Exemplo n.º 1
0
            public void EmptyValueParametersUnittest()
            {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                string        testParamStr1 = ";emptykey;Server=hippo;FTag=12345";
                SIPParameters testParam1    = new SIPParameters(testParamStr1, ';');

                Console.WriteLine("Parameter 1:" + testParam1.ToString());

                Assert.IsTrue(testParam1.Has("emptykey"), "The empty parameter \"emptykey\" was not correctly extracted from the paramter string.");
                Assert.IsTrue(Regex.Match(testParam1.ToString(), "emptykey").Success, "The emptykey name was not in the output parameter string.");
            }
Exemplo n.º 2
0
        public new string ToString()
        {
            try
            {
                string uriStr = Scheme.ToString() + SCHEME_ADDR_SEPARATOR;

                uriStr = (User != null) ? uriStr + User + USER_HOST_SEPARATOR + Host : uriStr + Host;

                if (Parameters != null && Parameters.Count > 0)
                {
                    uriStr += Parameters.ToString();
                }

                // If the URI's protocol is not implied already set the transport parameter.
                if (Scheme != SIPSchemesEnum.sips && Protocol != SIPProtocolsEnum.udp && !Parameters.Has(m_uriParamTransportKey))
                {
                    uriStr += PARAM_TAG_DELIMITER + m_uriParamTransportKey + TAG_NAME_VALUE_SEPERATOR + Protocol.ToString();
                }

                if (Headers != null && Headers.Count > 0)
                {
                    string headerStr = Headers.ToString();
                    uriStr += HEADER_START_DELIMITER + headerStr.Substring(1);
                }

                return(uriStr);
            }
            catch (Exception excp)
            {
                logger.Error("Exception SIPURI ToString. " + excp.Message);
                throw excp;
            }
        }
Exemplo n.º 3
0
        public override string ToString()
        {
            try
            {
                string userFieldStr = null;

                if (Name != null)
                {
                    /*if(Regex.Match(Name, @"\s").Success)
                     * {
                     *  userFieldStr = "\"" + Name + "\" ";
                     * }
                     * else
                     * {
                     *  userFieldStr = Name + " ";
                     * }*/

                    userFieldStr = "\"" + Name + "\" ";
                }

                userFieldStr += "<" + URI.ToString() + ">" + Parameters.ToString();

                return(userFieldStr);
            }
            catch (Exception excp)
            {
                logger.Error("Exception SIPUserField ToString. " + excp.Message);
                throw;
            }
        }
Exemplo n.º 4
0
            public void QuotedStringParamExtractTest()
            {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                string        methodsParam      = ";methods=\"INVITE, MESSAGE, INFO, SUBSCRIBE, OPTIONS, BYE, CANCEL, NOTIFY, ACK, REFER\"";
                SIPParameters serverParam       = new SIPParameters(methodsParam, ';');
                string        methodsParamValue = serverParam.Get("methods");

                Console.WriteLine("Parameter string=" + serverParam.ToString() + ".");
                Console.WriteLine("The methods parameter is=" + methodsParamValue + ".");

                Assert.IsTrue(methodsParamValue == "\"INVITE, MESSAGE, INFO, SUBSCRIBE, OPTIONS, BYE, CANCEL, NOTIFY, ACK, REFER\"", "The method parameter was not correctly extracted.");
            }
Exemplo n.º 5
0
            public void RouteParamExtractTest()
            {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                string        routeParam       = ";lr;server=hippo";
                SIPParameters serverParam      = new SIPParameters(routeParam, ';');
                string        serverParamValue = serverParam.Get("server");

                Console.WriteLine("Parameter string=" + serverParam.ToString() + ".");
                Console.WriteLine("The server parameter is=" + serverParamValue + ".");

                Assert.IsTrue(serverParamValue == "hippo", "The server parameter was not correctly extracted.");
            }
Exemplo n.º 6
0
            public void GetHashCodeDiffValueCaseEqualityUnittest()
            {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                string        testParamStr1 = ";LR;Server=hippo;FTag=12345";
                SIPParameters testParam1    = new SIPParameters(testParamStr1, ';');

                Console.WriteLine("Parameter 1:" + testParam1.ToString());

                string        testParamStr2 = "ftag=12345;lr;server=HiPPo;";
                SIPParameters testParam2    = new SIPParameters(testParamStr2, ';');

                Console.WriteLine("Parameter 2:" + testParam2.ToString());

                Assert.IsTrue(testParam1.GetHashCode() != testParam2.GetHashCode(), "The parameters had different hashcode values.");
            }