Exemplo n.º 1
0
        public void TestNewPrimaryAlgorithm()
        {
            PresenceManager pp = new PresenceManager();

            Presence pres = new Presence(doc);
            pres.From = baz;
            pres.IntPriority = 1;
            pp.AddPresence(pres);
            Assert.AreEqual(1, pp[bare].IntPriority);
            Assert.AreEqual(baz, pp[bare].From);

            pres = new Presence(doc);
            pres.From = boo;
            pres.IntPriority = 2;
            pp.AddPresence(pres);
            // duh.
            Assert.AreEqual(2, pp[bare].IntPriority);
            Assert.AreEqual(boo, pp[bare].From);

            pres = new Presence(doc);
            pres.From = boo;
            pres.IntPriority = 0;
            pp.AddPresence(pres);
            Assert.AreEqual(1, pp[bare].IntPriority);
            Assert.AreEqual(baz, pp[bare].From); // ooo

            pres = new Presence(doc);
            pres.From = boo;
            pres.Type = PresenceType.unavailable;
            pp.AddPresence(pres);
            Assert.AreEqual(1, pp[bare].IntPriority);
            Assert.AreEqual(baz, pp[bare].From);

            pres = new Presence(doc);
            pres.From = baz;
            pres.IntPriority = -1;
            pp.AddPresence(pres);
            Assert.AreEqual(null, pp[bare]);

            pres = new Presence(doc);
            pres.From = baz;
            pres.Type = PresenceType.unavailable;
            pp.AddPresence(pres);
            Assert.AreEqual(0, pp.GetAll(bare).Length);
        }
Exemplo n.º 2
0
        public void TestGetAll()
        {
            PresenceManager pp = new PresenceManager();

            Presence pres = new Presence(doc);
            pres.From = baz;
            pp.AddPresence(pres);

            pres = new Presence(doc);
            pres.From = boo;
            pp.AddPresence(pres);

            Presence[] pa = pp.GetAll(bare);
            Assert.AreEqual(2, pa.Length);
            Assert.AreEqual(pa[0].GetType(), typeof(Presence));
        }