Exemplo n.º 1
0
        public void Should_return_false_from_Tick_when_no_receiver_is_registered()
        {
            var port = new StandardInputPort(1, null);

            port.TrySend(new InformationPacket(null));
            port.Tick().ShouldBeFalse();
        }
Exemplo n.º 2
0
        public void Should_return_true_from_Tick_when_at_least_one_packet_is_accepted()
        {
            var port = new StandardInputPort(1, null);

            port.Receive = data => data.Accept();
            port.TrySend(new InformationPacket(null));
            port.Tick().ShouldBeTrue();
        }
Exemplo n.º 3
0
        public void Should_offer_one_IPs_if_queued_when_Tick_is_called()
        {
            var port        = new StandardInputPort(1, null);
            var timesCalled = 0;

            port.TrySend(new InformationPacket(null));
            port.Receive = data => ++ timesCalled;
            port.Tick();
            timesCalled.ShouldEqual(1);
        }
Exemplo n.º 4
0
        public void Should_offer_all_IPs_if_queued_when_Tick_is_called_and_greedy_is_true()
        {
            var port = new StandardInputPort(4, null);

            port.Greedy = true;
            var timesCalled = 0;

            port.TrySend(new InformationPacket(null));
            port.TrySend(new InformationPacket(null));
            port.TrySend(new InformationPacket(null));
            port.TrySend(new InformationPacket(null));
            port.Receive = data => {
                ++timesCalled;
                data.Accept();
            };
            port.Tick();
            timesCalled.ShouldEqual(4);
        }
Exemplo n.º 5
0
        public void Should_return_false_from_Tick_when_no_packets_are_sent()
        {
            var port = new StandardInputPort(1, null);

            port.Tick().ShouldBeFalse();
        }