public void Should_hold_sent_packets_until_receiving_ports_accept_them_or_close() { var c = new ComponentWithPublicData(""); (c.OutputPortsForTesting["Out2"] as MockOutputPort).ResponseToUseForTrySend = false; // receiving port accepts them c.AddPendingPacket("Out2", new InformationPacket(null)); c.AddPendingPacket("Out2", new InformationPacket(null)); c.PendingPacketCount.ShouldEqual(2); c.Tick(); c.PendingPacketCount.ShouldEqual(2); (c.OutputPortsForTesting["Out2"] as MockOutputPort).ResponseToUseForTrySend = true; c.Tick(); c.PendingPacketCount.ShouldEqual(0); // receiving port closes c.AddPendingPacket("Out2", new InformationPacket(null)); c.AddPendingPacket("Out2", new InformationPacket(null)); (c.OutputPortsForTesting["Out2"] as MockOutputPort).ResponseToUseForTrySend = false; (c.OutputPortsForTesting["Out2"] as MockOutputPort).ConnectedPortClosed = true; c.PendingPacketCount.ShouldEqual(2); c.Tick(); c.PendingPacketCount.ShouldEqual(0); }
public void Should_not_Tick_ports_if_outgoing_packets_are_queued() { var c = new ComponentWithPublicData(""); (c.OutputPortsForTesting["Out2"] as MockOutputPort).ResponseToUseForTrySend = false; c.InputPortsForTesting["In2"].TrySend(new InformationPacket(null)); c.AddPendingPacket("Out2", new InformationPacket(null)); (c.InputPortsForTesting["In2"] as MockInputPort).TickCalled.ShouldBeFalse(); c.Tick(); (c.InputPortsForTesting["In2"] as MockInputPort).TickCalled.ShouldBeFalse(); c.ClearPendingPackets(); c.Tick(); (c.InputPortsForTesting["In2"] as MockInputPort).TickCalled.ShouldBeTrue(); }