public void testerGetXml() { int destId = 2; string resultXml = "<?xml version='1.0'?>" + "<message>" + "<destid>" + destId +"</destid>" + "<authid>10</authid>" + "<authuser>Olivier</authuser>" + "<msgtext>Bonjour</msgtext>" + "</message>"; Message expected = new Message(destId,10, "Olivier", "Bonjour"); Assert.AreEqual(expected.getXml(), resultXml); }
public void testerCreationMessageAPartirDunStringXml() { int destId = 2; string xml = "<?xml version='1.0'?>" + "<message>" + "<destid>" + destId + "</destid>" + "<authid>10</authid>" + "<authuser>Olivier</authuser>" + "<msgtext>Bonjour</msgtext>" + "</message>"; Message expected = new Message(destId, 10, "Olivier", "Bonjour"); Message result = new Message(xml); Assert.AreEqual(10, result.AuthorId); Assert.AreEqual("Olivier", result.AuthorUsername); Assert.AreEqual("Bonjour", result.Content); }
private void Reading() { string line = ""; Message message = null; try { while (tcpClient.Connected && isReading) { line = reader.ReadLine(); if (!String.IsNullOrEmpty(line) && line.StartsWith("<?xml version='1.0'?>")) { message = new Message(line); membreCourant.AddMessageInStack(message, message.AuthorId); } } } catch (IOException e) { isReading = false; tcpClient.Close(); } }
internal void AddMessageInStack(Message message, int id) { MessageStacks[id].Add(message); }
public void EnvoyerMessage(string messageText, int amisId) { Message message = new Message(amisId, membreCourant.id, membreCourant.username, messageText); membreCourant.AddMessageInStack(message,amisId); gestionnaireCommunication.EcrireMessage(message); }
public void EcrireMessage(Message message) { writer.WriteLine(message.getXml()); }