public void Send_out_Test() { var l1 = new ManagedLink("A"); l1.Send(new TransportMessage("1")); Assert.That(l1.Out.Take().Payload, Is.EqualTo("1")); }
public void Connect_a_to_b_Test() { var l1 = new ManagedLink("A"); TransportMessage m = null; l1.Deliver += message => m = message; var l2 = new ManagedLink("B"); var ntw = new ManagedSwitch(); ntw.Connect(l1); ntw.Connect(l2); l2.Send(new TransportMessage("A", "1")); Assert.That(m.Payload, Is.EqualTo("1")); Assert.That(m.From, Is.EqualTo("B")); }
public void Send_b_to_a_Test() { TransportMessage m1 = null; var ntw = new ManagedSwitch(); var rec1 = new ManagedLink("A"); rec1.Deliver += message => m1 = message; ntw.Connect(rec1); var sender = new ManagedLink("B"); ntw.Connect(sender); sender.Send(new TransportMessage("A", "ping")); Assert.That(m1.Payload, Is.EqualTo("ping")); }
public void Partition_b_from_a_Test() { TransportMessage aGot = null; var ms = new ManagedSwitch(); ms.ApplyPartitionRule(new List<string>() { "A" }, new List<string>() { "B" }); var a = new ManagedLink("A"); a.Deliver += message => aGot = message; ms.Connect(a); var b = new ManagedLink("B"); ms.Connect(b); b.Send(new TransportMessage("A","ping")); Assert.That(aGot, Is.Null); }
public void Drop_from_b_to_a_Test() { TransportMessage aGot = null; var ms = new ManagedSwitch(); ms.Drop("B", "A"); var a = new ManagedLink("A"); a.Deliver += message => aGot = message; ms.Connect(a); var b = new ManagedLink("B"); ms.Connect(b); b.Send(new TransportMessage("A")); Assert.That(aGot, Is.Null); }