public void TestBuildSearchQuery() { string expectedXml = Resource.Get("Xmpp.Search.search_query4.xml"); var searchQuery = new IqQuery <Matrix.Xmpp.Search.Search>() { Type = Matrix.Xmpp.IqType.Result, From = "search.shakespeare.lit", Id = "search2" }; var first = new[] { "Juliet", "Tybalt" }; var jid = new[] { "*****@*****.**", "*****@*****.**" }; var last = new[] { "Capulet", "Capulet" }; var nick = new[] { "JuliC", "ty" }; var email = new[] { "*****@*****.**", "*****@*****.**" }; for (int i = 0; i < 2; i++) { searchQuery.Query.AddItem( new SearchItem { Jid = jid[i], First = first[i], Last = last[i], Nick = nick[i], Email = email[i] } ); } searchQuery.ShouldBe(expectedXml); }
public void Test2() { var expectedXml = Resource.Get("Xmpp.Client.rosteriq3.xml"); var rosterIq = new IqQuery <Matrix.Xmpp.Roster.Roster> { Id = "foo" }; rosterIq.ShouldBe(expectedXml); }
public void BuildRosterIq() { var expectedXml1 = Resource.Get("Xmpp.Client.rosteriq1.xml"); var expectedXml2 = Resource.Get("Xmpp.Client.rosteriq2.xml"); var rosterIq = new IqQuery <Matrix.Xmpp.Roster.Roster>(); rosterIq.RemoveAttribute("id"); rosterIq.ShouldBe(expectedXml1); Matrix.Xmpp.Roster.Roster roster = rosterIq.Query; roster.ShouldBe(expectedXml2); }
public void TestBuildMamQuery() { var mamQuery = new IqQuery <MessageArchive> { Type = Matrix.Xmpp.IqType.Set, Id = "juliet1", Query = { QueryId = "f27", Node = "fdp/submitted/capulet.lit/sonnets" } }; mamQuery.ShouldBe(MAM_QUERY); }
public void Test3() { var expectedXml = Resource.Get("Xmpp.Client.rosteriq4.xml"); var roster = new Matrix.Xmpp.Roster.Roster(); roster.AddRosterItem(new Matrix.Xmpp.Roster.RosterItem("*****@*****.**")); var rosterIq = new IqQuery <Matrix.Xmpp.Roster.Roster>(roster) { Id = "foo" }; rosterIq.ShouldBe(expectedXml); }
public void TestMatchPredicates() { var pIq = new IqQuery <PingIq> { Type = IqType.Get, Id = "foo" }; pIq.IsMatch(iq => iq.HasAttribute("id")).ShouldBeTrue(); pIq.IsMatch(iq => iq.HasAttribute("foo")).ShouldBeFalse(); pIq.IsMatch(el => el.OfType <Iq>()).ShouldBeTrue(); pIq.IsMatch(el => el.OfType <Iq>() && el.Cast <Iq>().Id == "foo").ShouldBeTrue(); pIq.IsMatch(el => el.OfType <Iq>() && el.Cast <Iq>().Id == "foo" && el.Cast <Iq>().Type == IqType.Get) .ShouldBeTrue(); pIq.IsMatch(el => el.OfType <Iq>() && el.Cast <Iq>().Id == "foo" && el.Cast <Iq>().Type == IqType.Result) .ShouldBeFalse(); Func <XmppXElement, bool> predicate1 = e => e.OfType <StreamFeatures>(); var elSf = XmppXElement.LoadXml("<stream:features xmlns:stream='http://etherx.jabber.org/streams'/>"); elSf.ShouldBeOfType <StreamFeatures>(); elSf.IsMatch(predicate1).ShouldBeTrue(); var iq2 = new Iq { Type = IqType.Get }; iq2.IsMatch(el => el.OfType <Iq>() && el.Cast <Iq>().Type == IqType.Get && el.Cast <Iq>().Query.OfType <Ping>() ).ShouldBeFalse(); iq2.IsMatch(el => el.OfType <Iq>() && el.Cast <Iq>().Type == IqType.Get ).ShouldBeTrue(); }