Ejemplo n.º 1
0
 public void When_add_self_to_roster_should_throw()
 {
     XElement responseElement = XElement.Load("Roster\\RosterIqResult.xml");
     var rosterManager = new RosterManager(mockXmppService.Object);
     rosterManager.Initialize();
     rosterManager.HandleIQStanza(responseElement);
     Assert.Throws<InvalidOperationException>(() => rosterManager.Add(jid, "user", new[] {"none"}));
 }
Ejemplo n.º 2
0
 public void When_initializing_should_fire_RosterItemChanged_event()
 {
     XElement responseElement = XElement.Load(System.IO.Path.Combine(Path, "RosterIqResult.xml"));
     var rosterManager = new RosterManager(mockXmppService.Object);
     bool rosterChangedFired = false;
     rosterManager.RosterChanged += (sender, e) => rosterChangedFired = true;
     rosterManager.Initialize();
     rosterManager.HandleIQStanza(responseElement);
     Assert.True(rosterChangedFired);
 }
Ejemplo n.º 3
0
 public void When_add_to_roster_should_send_RosterSet()
 {
     XElement rosterSetExpected = XElement.Load("Roster\\RosterSet.xml");
     XElement rosterSetActual = null;
     mockXmppService.Setup(x => x.Send(It.IsAny<IStanzaHandler>(), It.IsAny<XElement>())).Callback((IStanzaHandler handler, XElement e) => rosterSetActual = e);
     var rosterManager = new RosterManager(mockXmppService.Object);
     rosterManager.Initialize();
     rosterManager.Add(new JId("user2", "domain"), "buddy", new[] {"Friends"});
     Assert.Equal(rosterSetExpected.ToString(SaveOptions.DisableFormatting), rosterSetActual.ToString(SaveOptions.DisableFormatting));
 }
Ejemplo n.º 4
0
 public void After_initialization_should_send_initial_presence()
 {
     ;
     XElement initialPresenceExpected = XElement.Load(System.IO.Path.Combine(Path, "InitialPresence.xml"));
     XElement initialPresenceActual = null;
     XElement responseElement = XElement.Load(System.IO.Path.Combine(Path, "RosterIqResult.xml"));
     mockXmppService.Setup(x => x.Send(It.IsAny<IStanzaHandler>(), It.IsAny<XElement>())).Callback((IStanzaHandler handler, XElement e) => initialPresenceActual = e);
     var rosterManager = new RosterManager(mockXmppService.Object);
     rosterManager.Initialize();
     rosterManager.HandleIQStanza(responseElement);
     Assert.Equal(initialPresenceExpected.ToString(SaveOptions.DisableFormatting), initialPresenceActual.ToString(SaveOptions.DisableFormatting));
 }
Ejemplo n.º 5
0
 public void When_initializing_should_send_RosterGet()
 {
     XElement rosterGetExpected = XElement.Load(System.IO.Path.Combine(Path, "RosterGet.xml"));
     XElement rosterGetActual = null;
     mockXmppService.Setup(x => x.Send(It.IsAny<IStanzaHandler>(), It.IsAny<XElement>())).Callback((IStanzaHandler handler, XElement x) => rosterGetActual = x);
     var rosterManager = new RosterManager(mockXmppService.Object);
     rosterManager.Initialize();
     mockXmppService.VerifyAll();
     Assert.Equal(rosterGetExpected.ToString(SaveOptions.DisableFormatting), rosterGetActual.ToString(SaveOptions.DisableFormatting));
 }