public void AddAndTakeTwoMessages() { Mailbox box = new Mailbox(); box.Add(1); box.Add(2); Assert.AreEqual(1, box.Take()); Assert.AreEqual(2, box.Take()); }
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()); }
public void AddAndTakeMessage() { Mailbox box = new Mailbox(); box.Add(1); Assert.AreEqual(1, box.Take()); }
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()); }
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()); }