Beispiel #1
0
        public void SipHeader_MultiValue()
        {
            SipHeader     h;
            StringBuilder sb;

            h = new SipHeader("Test", new string[] { "Hello", "World", "Now" });
            Assert.IsFalse(h.IsSpecial);
            Assert.AreEqual("Test", h.Name);
            Assert.AreEqual("Hello", h.Text);
            Assert.AreEqual("Hello, World, Now", h.FullText);
            CollectionAssert.AreEqual(new string[] { "Hello", "World", "Now" }, h.Values);

            Assert.AreEqual("Test: Hello, World, Now\r\n", h.ToString());

            sb = new StringBuilder();
            h.Serialize(sb, false);
            Assert.AreEqual("Test: Hello, World, Now\r\n", sb.ToString());

            h.Values[0] = "Goodbye";
            Assert.AreEqual("Goodbye", h.Text);
            Assert.AreEqual("Goodbye, World, Now", h.FullText);

            Assert.AreEqual("Test: Goodbye, World, Now\r\n", h.ToString());

            h.Append("Foo");
            Assert.AreEqual("Test: Goodbye, World, Now, Foo\r\n", h.ToString());

            h.Prepend("xxx");
            Assert.AreEqual("Test: xxx, Goodbye, World, Now, Foo\r\n", h.ToString());
        }
Beispiel #2
0
        public void SipHeader_SingleValue()
        {
            SipHeader     h;
            StringBuilder sb;

            h = new SipHeader("Test", "Hello");
            Assert.IsFalse(h.IsSpecial);
            Assert.AreEqual("Test", h.Name);
            Assert.AreEqual("Hello", h.Text);
            Assert.AreEqual("Hello", h.FullText);
            CollectionAssert.AreEqual(new string[] { "Hello" }, h.Values);

            h.Text = "World";
            Assert.IsFalse(h.IsSpecial);
            Assert.AreEqual("Test", h.Name);
            Assert.AreEqual("World", h.Text);
            Assert.AreEqual("World", h.FullText);
            CollectionAssert.AreEqual(new string[] { "World" }, h.Values);

            Assert.AreEqual("Test: World\r\n", h.ToString());

            sb = new StringBuilder();
            h.Serialize(sb, false);
            Assert.AreEqual("Test: World\r\n", sb.ToString());
        }
Beispiel #3
0
        public void SipHeader_Special()
        {
            SipHeader h;

            h = new SipHeader("Test", "v0=1,v1=2", true);
            Assert.IsTrue(h.IsSpecial);
            CollectionAssert.AreEqual(new string[] { "v0=1,v1=2" }, h.Values);
            Assert.AreEqual("v0=1,v1=2", h.Text);
            Assert.AreEqual("v0=1,v1=2", h.FullText);

            Assert.AreEqual("Test: v0=1,v1=2\r\n", h.ToString());
        }
Beispiel #4
0
        public void SipHeader_CompactNames()
        {
            SipHeader     h;
            StringBuilder sb;

            h = new SipHeader(SipHeader.CallID, "test");

            sb = new StringBuilder();
            h.Serialize(sb, false);
            Assert.AreEqual("Call-ID: test\r\n", sb.ToString());

            sb = new StringBuilder();
            h.Serialize(sb, true);
            Assert.AreEqual("i: test\r\n", sb.ToString());
        }
Beispiel #5
0
        public void SipHeader_RemoveLast()
        {
            SipHeader h;

            h = new SipHeader("Test", new string[] { "Hello", "World", "Now" });
            CollectionAssert.AreEqual(new string[] { "Hello", "World", "Now" }, h.Values);

            h.RemoveLast();
            CollectionAssert.AreEqual(new string[] { "Hello", "World" }, h.Values);
            Assert.AreEqual("Test: Hello, World\r\n", h.ToString());

            h.RemoveLast();
            h.RemoveLast();
            Assert.AreEqual("", h.ToString());
        }
Beispiel #6
0
        public void SipHeaderCollection_CompactNames()
        {
            SipHeaderCollection headers;

            headers = new SipHeaderCollection();
            headers.Add(SipHeader.CallID, "10");
            Assert.IsFalse(headers.HasCompactHeaders);
            Assert.AreEqual("Call-ID: 10\r\n\r\n", Serialize(headers));

            headers = new SipHeaderCollection();
            headers.Add("i", "10");
            Assert.IsTrue(headers.HasCompactHeaders);
            Assert.AreEqual("i: 10\r\n\r\n", Serialize(headers));
            Assert.AreEqual("10", headers["i"].Text);
            Assert.AreEqual("10", headers[SipHeader.CallID].Text);

            headers = new SipHeaderCollection();
            headers[SipHeader.CallID] = new SipHeader(SipHeader.CallID, "10");
            Assert.IsFalse(headers.HasCompactHeaders);
            Assert.AreEqual("Call-ID: 10\r\n\r\n", Serialize(headers));

            headers      = new SipHeaderCollection();
            headers["i"] = new SipHeader("i", "10");
            Assert.IsTrue(headers.HasCompactHeaders);
            Assert.AreEqual("i: 10\r\n\r\n", Serialize(headers));
            Assert.AreEqual("10", headers["i"].Text);
            Assert.AreEqual("10", headers[SipHeader.CallID].Text);

            headers = new SipHeaderCollection();
            headers.Add(SipHeader.CallID, new SipHeader(SipHeader.CallID, "10"));
            Assert.IsFalse(headers.HasCompactHeaders);
            Assert.AreEqual("Call-ID: 10\r\n\r\n", Serialize(headers));

            headers = new SipHeaderCollection();
            headers.Add("i", new SipHeader("i", "10"));
            Assert.IsTrue(headers.HasCompactHeaders);
            Assert.AreEqual("i: 10\r\n\r\n", Serialize(headers));
            Assert.AreEqual("10", headers["i"].Text);
            Assert.AreEqual("10", headers[SipHeader.CallID].Text);
        }
Beispiel #7
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SipHeader obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Beispiel #8
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SipHeader obj)
 {
     return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
 }