Exemplo n.º 1
0
        public void MucMessagesTest()
        {
            var room1 = new Jid("a.conf@s");
            var room2 = new Jid("b.conf@s");

            var m1 = new Message(new Jid("to1"), new Jid("from2"), "1");
            var m2 = new Message(new Jid("to2"), new Jid("from2"), "2");
            store.AddMucMessages(room1, new[] { m1, m2 });

            var mess = store.GetMucMessages(room2, 0);
            Assert.AreEqual(0, mess.Count);

            mess = store.GetMucMessages(room1, 0);
            Assert.AreEqual(2, mess.Count);
            Assert.AreEqual("1", mess[0].Body);
            Assert.AreEqual("2", mess[1].Body);

            mess = store.GetMucMessages(room1, 1);
            Assert.AreEqual(1, mess.Count);
            Assert.AreEqual("2", mess[0].Body);

            store.RemoveMucMessages(room1);
            mess = store.GetMucMessages(room1, 1);
            Assert.AreEqual(0, mess.Count);
        }
		public void OfflineMessagesTest()
		{
			store.RemoveAllOfflineMessages(jid);
			var messages = store.GetOfflineMessages(jid);
			CollectionAssert.IsEmpty(messages);

			var m = new Message()
			{
				To = jid,
				From = new Jid("y"),
				Body = "xy"
			};
			store.SaveOfflineMessages(m);

			messages = store.GetOfflineMessages(jid);
			Assert.AreEqual(1, messages.Count);
			Assert.AreEqual(m.To, messages[0].To);
			Assert.AreEqual(m.From, messages[0].From);
			Assert.AreEqual(m.Body, messages[0].Body);

			store.SaveOfflineMessages(m);
			messages = store.GetOfflineMessages(jid);
			Assert.AreEqual(2, messages.Count);

			messages = store.GetOfflineMessages(new Jid("y"));
			CollectionAssert.IsEmpty(messages);

			store.RemoveAllOfflineMessages(jid);

			store.SaveOfflineMessages(new Message());
			messages = store.GetOfflineMessages(jid);
			CollectionAssert.IsEmpty(messages);
		}
Exemplo n.º 3
0
		public void MessagesTest()
		{
			var from = new Jid("jid1", "s", "R1");
			var to = new Jid("jid2", "s", "R2");
			var m1 = new Message(to, from, "to --> from");
			var m2 = new Message(from, to, "from --> to");

			store.SaveMessages(new[] { m1, m2 });

			var messages = store.GetMessages(from, to, DateTime.MinValue, DateTime.MaxValue, 2);
			Assert.AreEqual(messages.Length, 2);
			Assert.AreEqual(m1.From, messages[0].From);
			Assert.AreEqual(m2.From, messages[1].From);

			messages = store.GetMessages(to, from, DateTime.MinValue, DateTime.MaxValue, 2);
			Assert.AreEqual(messages.Length, 2);
			Assert.AreEqual(m1.From, messages[0].From);
			Assert.AreEqual(m2.From, messages[1].From);
		}