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.IsInstanceOfType(fm[g], typeof(DiscoInfo)); Assert.AreEqual(1, fm.Count); // re-read, to reparse fm = new FileMap<DiscoInfo>("test.xml", ef); Assert.IsTrue(fm.Contains(g)); Assert.IsInstanceOfType(fm[g], typeof(DiscoInfo)); fm[g] = null; Assert.AreEqual(1, fm.Count); fm.Remove(g); Assert.AreEqual(0, fm.Count); }
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()); }
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); }
public void Test_Create() { ElementFactory pf = new ElementFactory(); pf.AddType(new Factory()); }