public void Test_Deliver() { var node1 = new Node ("Node1"); var node2 = new Node ("Node2"); var mbox1 = new MailBox ("All"); var mbox2 = new MailBox ("All"); node1.Attach (mbox1); node2.Attach (mbox2); var received1 = false; var received2 = false; mbox1.Action += (from, to, args) => { received1 = true; }; mbox2.Action += (from, to, args) => { received2 = true; }; var wld = new World (); wld.AddChild (node1); wld.AddChild (node2); wld.PostOffice.Post (node1, "Node2", null); wld.PostOffice.Post (node2, "Node1", null); wld.Deliver (); Assert.AreEqual (true, received1); Assert.AreEqual (true, received2); }
public void Test_Deliverable() { var node = new Node ("Node"); var mbox = new MailBox ("Node"); node.Attach (mbox); var wld = new World (); wld.AddChild (node); var recved = false; mbox.Action += (from, address, letter) => { recved = true; }; node.Deliverable = true; wld.PostOffice.Post (node, "Node", "Hello World"); wld.Deliver (); Assert.AreEqual (true, recved); recved = false; node.Deliverable = false; wld.PostOffice.Post (node, "Node", "Hello World"); wld.Deliver (); Assert.AreEqual (false, recved); }