public static void BookmarksManagerSendsThePasswordToJoin() { using var stream = new MemoryStream(); using var connection = new MockedXmppTcpConnection(null, stream); var elements = new List <XElement>(); connection.Element += (_, element) => elements.Add(element.Stanza); var conference = new BookmarkedConference { JID = new JID("*****@*****.**"), Password = "******" }; var bookmarksManager = new BookmarksManager(connection, false); bookmarksManager.Join(conference); Thread.MemoryBarrier(); var joinElement = Stanza.Parse <XMPPPresence>(elements.Single()); var password = joinElement .Element(XNamespace.Get(Namespaces.MUC) + "x") ! .Element(XNamespace.Get(Namespaces.MUC) + "password") ! .Value; Assert.AreEqual("12345", password); }
public void ConnectionShouldStopAfterStreamClosed() { using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(EmptyXmppStream))) using (var connection = new MockedXmppTcpConnection(stream)) { Assert.Throws <XmppConnectionTerminatedException>(() => connection.NextElement()); } }