Пример #1
0
        public void unreg6()
        {
            PlainMailbox mb = new PlainMailbox(this, 1L);

            mb.RegisterNotify(notify, null, 30);
            mb.UnregisterNotify(notify);
        }
Пример #2
0
        public Mailbox TransportCall(Who recipient, Message msg)
        {
            if (msg.MessageId != null)
            {
                throw new Exception(" message has already been sent");
            }
            if (msg.InReplyTo != null)
            {
                throw new Exception(" message is marked as a reply");
            }

            long mid = idGen.Next();

            msg.MessageId = mid;
            Mailbox mb = new PlainMailbox(this, mid);

            Register(mb);
            try
            {
                transport.TransportMessage(recipient, msg);
            }
            catch (Exception e)
            {
                Unregister(mb);
                throw e;
            }
            return(mb);
        }
Пример #3
0
        public void reg2()
        {
            // maxDelay < 0
            PlainMailbox mb = new PlainMailbox(this, 1L);

            mb.RegisterNotify(notify, null, -1);
        }
Пример #4
0
        private void testConstruct(long messageId)
        {
            PlainMailbox mb = new PlainMailbox(this, messageId);

            Assert.AreEqual(this, mb.GetMailboxManager());
            Assert.AreEqual(messageId, mb.GetMessageId());
        }
Пример #5
0
        public void reg1()
        {
            // notify == null
            PlainMailbox mb = new PlainMailbox(this, 1L);

            mb.RegisterNotify(null, null, 0);
        }
Пример #6
0
        public void reg5()
        {
            // this.notify != null
            PlainMailbox mb = new PlainMailbox(this, 1L);

            mb.RegisterNotify(notify, null, 0);
            mb.RegisterNotify(notify1x, null, 0);
        }
Пример #7
0
        public void unreg5()
        {
            // notify != this.notify
            PlainMailbox mb = new PlainMailbox(this, 1L);

            mb.RegisterNotify(notify, null, 0);
            mb.UnregisterNotify(notify1x);
        }
Пример #8
0
        public void read8()
        {
            PlainMailbox mb = new PlainMailbox(this, 1L);

            checkMailbox(mb, true, false, false, false, 0);

            checkRead(mb, 1, false, null, null);
            checkMailbox(mb, true, false, false, false, 0);
        }
Пример #9
0
 private void checkMailbox(PlainMailbox mb, bool empty, bool full,
                           bool closed, bool unreg, int size)
 {
     Assert.AreEqual(empty, mb.IsEmpty());
     Assert.AreEqual(full, mb.IsFull());
     Assert.AreEqual(closed, mb.IsClosed());
     Assert.AreEqual(unreg, unregistered);
     Assert.AreEqual(size, redelivered.Count);
 }
Пример #10
0
        public void closeRead1()
        {
            // open mailbox and close it for reading while empty.

            PlainMailbox mb = new PlainMailbox(this, 1L);

            checkMailbox(mb, true, false, false, false, 0);

            checkCloseRead(mb, true);
            checkMailbox(mb, true, false, true, true, 0);
        }
Пример #11
0
        public void read5()
        {
            PlainMailbox mb = new PlainMailbox(this, 1L);

            checkMailbox(mb, true, false, false, false, 0);

            Thread.Sleep(1000);

            checkRead(mb, false, null, null);
            checkMailbox(mb, true, false, true, true, 0);
        }
Пример #12
0
        public void closeDelivery1()
        {
            // open mailbox and close it for delivery while empty.

            PlainMailbox mb = new PlainMailbox(this, 1L);

            checkMailbox(mb, true, false, false, false, 0);

            checkCloseDelivery(mb, true);
            checkMailbox(mb, true, false, true, true, 0);
        }
Пример #13
0
        public void full1()
        {
            PlainMailbox mb = new PlainMailbox(this, 1L);

            checkMailbox(mb, true, false, false, false, 0);

            checkDeliver(mb, true, fred_who, foo_msg);
            checkMailbox(mb, false, true, false, false, 0);

            checkDeliver(mb, false, alice_who, bar_msg);
            checkMailbox(mb, false, true, false, false, 0);
        }
Пример #14
0
        public void deliver1()
        {
            PlainMailbox mb = new PlainMailbox(this, 1L);

            checkMailbox(mb, true, false, false, false, 0);

            checkCloseDelivery(mb, true);
            checkMailbox(mb, true, false, true, true, 0);

            checkDeliver(mb, false, fred_who, bar_msg);
            checkMailbox(mb, true, false, true, true, 0);
        }
Пример #15
0
        public void read4()
        {
            PlainMailbox mb = new PlainMailbox(this, 1L);

            checkMailbox(mb, true, false, false, false, 0);

            checkCloseDelivery(mb, true);
            checkMailbox(mb, true, false, true, true, 0);

            checkRead(mb, false, null, null);
            checkMailbox(mb, true, false, true, true, 0);
        }
Пример #16
0
        private void checkRead(PlainMailbox mb, bool present, Who who, Message msg)
        {
            Element e = mb.Read();

            if (present)
            {
                checkElement(e, who, msg);
            }
            else
            {
                Assert.IsNull(e);
            }
        }
Пример #17
0
        public void notify4()
        {
            PlainMailbox mb = new PlainMailbox(this, 1L);

            notify.checkMailboxStatus(false, null, null, false);

            Object state = new Object();

            mb.RegisterNotify(notify, state, 0);
            notify.checkMailboxStatus(false, null, null, false);

            mb.Message(alice_who, foo_msg);
            notify.checkMailboxStatus(true, mb, state, false);
        }
Пример #18
0
        public void notify1()
        {
            PlainMailbox mb = new PlainMailbox(this, 1L);

            notify.checkMailboxStatus(false, null, null, false);

            Object state = new Object();

            mb.RegisterNotify(notify, state, 0);
            notify.checkMailboxStatus(false, null, null, false);

            checkCloseDelivery(mb, true);
            notify.checkMailboxStatus(true, mb, state, true);
        }
Пример #19
0
        public void notify3()
        {
            PlainMailbox mb = new PlainMailbox(this, 1L);

            notify.checkMailboxStatus(false, null, null, false);

            Object state = new Object();

            mb.RegisterNotify(notify, state, 0);
            notify.checkMailboxStatus(false, null, null, false);

            Thread.Sleep(2000);
            notify.checkMailboxStatus(false, null, null, false);
        }
Пример #20
0
        public void closeDelivery3()
        {
            // open mailbox and close it for delivery twice.

            PlainMailbox mb = new PlainMailbox(this, 1L);

            checkMailbox(mb, true, false, false, false, 0);

            checkCloseDelivery(mb, true);
            checkMailbox(mb, true, false, true, true, 0);

            checkCloseDelivery(mb, false);
            checkMailbox(mb, true, false, true, true, 0);
        }
Пример #21
0
        public void closeDelivery2()
        {
            // open mailbox and close it for delivery while not empty.

            PlainMailbox mb = new PlainMailbox(this, 1L);

            checkMailbox(mb, true, false, false, false, 0);

            checkDeliver(mb, true, alice_who, foo_msg);
            checkMailbox(mb, false, true, false, false, 0);

            checkCloseDelivery(mb, true);
            checkMailbox(mb, false, true, true, true, 0);
        }
Пример #22
0
        public void closeRead2()
        {
            // open mailbox and close it for reading while not empty.

            PlainMailbox mb = new PlainMailbox(this, 1L);

            checkMailbox(mb, true, false, false, false, 0);

            checkDeliver(mb, true, alice_who, foo_msg);
            checkMailbox(mb, false, true, false, false, 0);

            checkCloseRead(mb, true);
            checkMailbox(mb, true, false, true, true, 1);
            checkRedelivered(0, alice_who, foo_msg);
        }
Пример #23
0
        public void read3()
        {
            PlainMailbox mb = new PlainMailbox(this, 1L);

            checkMailbox(mb, true, false, false, false, 0);

            checkDeliver(mb, true, alice_who, bar_msg);
            checkMailbox(mb, false, true, false, false, 0);

            checkCloseDelivery(mb, true);
            checkMailbox(mb, false, true, true, true, 0);

            checkRead(mb, true, alice_who, bar_msg);
            checkMailbox(mb, true, false, true, true, 0);
        }
Пример #24
0
        public void reg3()
        {
            PlainMailbox mb = new PlainMailbox(this, 1L);

            mb.RegisterNotify(notify, null, 0);
        }
Пример #25
0
 private void checkCloseDelivery(PlainMailbox mb, bool closed)
 {
     Assert.AreEqual(closed, mb.CloseDelivery());
 }
Пример #26
0
 private void checkCloseRead(PlainMailbox mb, bool closed)
 {
     Assert.AreEqual(closed, mb.CloseRead());
 }
Пример #27
0
        public void unreg1()
        {
            PlainMailbox mb = new PlainMailbox(this, 1L);

            mb.UnregisterNotify(notify);
        }
Пример #28
0
 private void checkDeliver(PlainMailbox mb, bool handled, Who who,
                           Message msg)
 {
     Assert.AreEqual(handled, mb.Message(who, msg));
 }