Esempio n. 1
0
        public void AddAndTakeTwoMessages()
        {
            Mailbox box = new Mailbox();

            box.Add(1);
            box.Add(2);

            Assert.AreEqual(1, box.Take());
            Assert.AreEqual(2, box.Take());
        }
Esempio n. 2
0
        public void AddAndTakeMessagesWithReject()
        {
            Mailbox box = new Mailbox();

            box.Add(1);
            box.Add(2);
            box.Add(3);

            Assert.AreEqual(1, box.Take());
            Assert.AreEqual(2, box.Take());
            box.Reject(2);
            Assert.AreEqual(3, box.Take());
            Assert.AreEqual(2, box.Take());
        }
Esempio n. 3
0
        public void AddAndTakeMessagesWithReject()
        {
            Mailbox box = new Mailbox();

            box.Add(1);
            box.Add(2);
            box.Add(3);

            Assert.AreEqual(1, box.Take());
            Assert.AreEqual(2, box.Take());
            box.Reject(2);
            Assert.AreEqual(3, box.Take());
            Assert.AreEqual(2, box.Take());
        }
Esempio n. 4
0
        public void AddAndTakeMessage()
        {
            Mailbox box = new Mailbox();

            box.Add(1);

            Assert.AreEqual(1, box.Take());
        }
Esempio n. 5
0
        public void TakeADelayedAddedMessage()
        {
            Mailbox box = new Mailbox();

            ThreadStart ts = new ThreadStart(() => { Thread.Sleep(100); box.Add(1); });
            Thread      th = new Thread(ts);

            th.Start();

            Assert.AreEqual(1, box.Take());
        }
Esempio n. 6
0
        public void AddAndTakeMessagesWithThreeNonConsecutiveRejects()
        {
            Mailbox box = new Mailbox();

            box.Add(1);
            box.Add(2);
            box.Add(3);
            box.Add(4);
            box.Add(5);

            Assert.AreEqual(1, box.Take());
            Assert.AreEqual(2, box.Take());
            box.Reject(2);
            Assert.AreEqual(3, box.Take());
            box.Reject(3);
            Assert.AreEqual(4, box.Take());
            Assert.AreEqual(2, box.Take());
            box.Reject(2);
            Assert.AreEqual(3, box.Take());
            Assert.AreEqual(2, box.Take());
            Assert.AreEqual(5, box.Take());
        }
Esempio n. 7
0
        public void AddAndTakeMessagesWithThreeNonConsecutiveRejects()
        {
            Mailbox box = new Mailbox();

            box.Add(1);
            box.Add(2);
            box.Add(3);
            box.Add(4);
            box.Add(5);

            Assert.AreEqual(1, box.Take());
            Assert.AreEqual(2, box.Take());
            box.Reject(2);
            Assert.AreEqual(3, box.Take());
            box.Reject(3);
            Assert.AreEqual(4, box.Take());
            Assert.AreEqual(2, box.Take());
            box.Reject(2);
            Assert.AreEqual(3, box.Take());
            Assert.AreEqual(2, box.Take());
            Assert.AreEqual(5, box.Take());
        }
Esempio n. 8
0
        public void TakeADelayedAddedMessage()
        {
            Mailbox box = new Mailbox();

            ThreadStart ts = new ThreadStart(() => { Thread.Sleep(100); box.Add(1); });
            Thread th = new Thread(ts);
            th.Start();

            Assert.AreEqual(1, box.Take());
        }