Exemplo n.º 1
0
        public void TestCreate()
        {
            ElementFactory ef = new ElementFactory();

            ef.AddType(new global::Jabber.protocol.iq.Factory());

            string g = new Guid().ToString();
            FileMap <DiscoInfo> fm = new FileMap <DiscoInfo>("test.xml", ef);

            fm.Clear();
            Assert.AreEqual(0, fm.Count);

            fm[g] = Element;
            Assert.IsTrue(fm.Contains(g));
            Assert.IsFalse(fm.Contains("foo"));
            Assert.IsInstanceOf <DiscoInfo>(fm[g]);
            Assert.AreEqual(1, fm.Count);

            // re-read, to reparse
            fm = new FileMap <DiscoInfo>("test.xml", ef);
            Assert.IsTrue(fm.Contains(g));
            Assert.IsInstanceOf <DiscoInfo>(fm[g]);

            fm[g] = null;
            Assert.AreEqual(1, fm.Count);

            fm.Remove(g);
            Assert.AreEqual(0, fm.Count);
        }
Exemplo n.º 2
0
        public void Test_Error()
        {
            Error err = new Error(doc);

            err.Message = "foo";
            Assert.AreEqual("<stream:error " +
                            "xmlns:stream=\"http://etherx.jabber.org/streams\">foo</stream:error>", err.ToString());
            ElementFactory sf = new ElementFactory();

            sf.AddType(new Factory());
            XmlQualifiedName qname = new XmlQualifiedName(err.LocalName, err.NamespaceURI);
            Element          p     = (Element)sf.GetElement(err.Prefix, qname, doc);

            Assert.AreEqual(typeof(Error), p.GetType());
        }
Exemplo n.º 3
0
        public void Test_Convert()
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(tstring);

            ElementFactory f = new ElementFactory();

            f.AddType(new global::jabber.protocol.x.Factory());

            Element stream = Element.AddTypes(doc.DocumentElement, f);
            Data    d      = stream.GetChildElement <global::jabber.protocol.x.Data>();

            Assert.IsNotNull(d);
        }
Exemplo n.º 4
0
        [Test] public void Test_Create()
        {
            ElementFactory pf = new ElementFactory();

            pf.AddType(new fact());
        }