Esempio n. 1
0
        public void TestCreate()
        {
            ElementFactory ef = new ElementFactory();
            ef.AddType(new global::Kixeye.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.IsInstanceOfType(typeof(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.IsInstanceOfType(typeof(DiscoInfo), fm[g]);

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

            fm.Remove(g);
            Assert.AreEqual(0, fm.Count);
        }
Esempio n. 2
0
 [Test] public void Test_Error()
 {
     Error err = new Error(doc);
     err.Message = "foo";
     Assert.AreEqual("<stream:error " +
         "xmlns:stream=\"http://etherx.kixeye.jabber.org/streams\">foo</stream:error>", err.ToString());
     ElementFactory sf = new ElementFactory();
     sf.AddType(new fact());
     XmlQualifiedName qname = new XmlQualifiedName(err.LocalName, err.NamespaceURI);
     Element p = (Element) sf.GetElement(err.Prefix, qname, doc);
     Assert.AreEqual(typeof(Error), p.GetType());
 }
Esempio n. 3
0
 [Test] public void Test_Create()
 {
     ElementFactory pf = new ElementFactory();
     pf.AddType(new fact());
 }
Esempio n. 4
0
        public void Test_Convert()
        {
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(tstring);

            ElementFactory f = new ElementFactory();
            f.AddType(new global::Kixeye.Jabber.Protocol.X.Factory());

            Element stream = Element.AddTypes(doc.DocumentElement, f);
            Data d = stream.GetChildElement<global::Kixeye.Jabber.Protocol.X.Data>();
            Assert.IsNotNull(d);
        }