public void can_alter_max_sending_count()
 {
     var choke = new SendingChoke();
     choke.AlterSendingCountMaximumTo(10);
     5.Times(x =>
     {
         choke.StartSend();
         choke.SuccessfullyConnected();
     });
     choke.ShouldBeginSend().ShouldBeTrue();
     5.Times(x =>
     {
         choke.StartSend();
         choke.SuccessfullyConnected();
     });
     choke.ShouldBeginSend().ShouldBeFalse();
 }
Пример #2
0
 private Sender createSender(Endpoint destination, PersistentMessage[] messages)
 {
     return(new Sender
     {
         Connected = () => _choke.SuccessfullyConnected(),
         Destination = destination,
         Messages = messages,
     });
 }
        public void can_alter_max_sending_count()
        {
            var choke = new SendingChoke();

            choke.AlterSendingCountMaximumTo(10);
            5.Times(x =>
            {
                choke.StartSend();
                choke.SuccessfullyConnected();
            });
            choke.ShouldBeginSend().ShouldBeTrue();
            5.Times(x =>
            {
                choke.StartSend();
                choke.SuccessfullyConnected();
            });
            choke.ShouldBeginSend().ShouldBeFalse();
        }
 public void available_sending_count_with_all_connected()
 {
     var choke = new SendingChoke();
     5.Times(x =>
     {
         choke.StartSend();
         choke.SuccessfullyConnected();
     });
     choke.AvailableSendingCount.ShouldEqual(0);
 }
 public void available_sending_count_some_connected_some_still_connecting()
 {
     var choke = new SendingChoke();
     4.Times(x =>
     {
         choke.StartSend();
         choke.SuccessfullyConnected();
     });
     25.Times(x => choke.StartSend());
     choke.AvailableSendingCount.ShouldEqual(1);
 }
        public void choke_returns_false_if_at_max_sending_count()
        {
            var choke = new SendingChoke();

            5.Times(x =>
            {
                choke.StartSend();
                choke.SuccessfullyConnected();
            });
            choke.ShouldBeginSend().ShouldBeFalse();
        }
        public void available_sending_count_with_all_connected()
        {
            var choke = new SendingChoke();

            5.Times(x =>
            {
                choke.StartSend();
                choke.SuccessfullyConnected();
            });
            choke.AvailableSendingCount.ShouldEqual(0);
        }
        public void choke_returns_false_if_max_sending_isnt_exceeded_but_max_connecting_is()
        {
            var choke = new SendingChoke();

            2.Times(x =>
            {
                choke.StartSend();
                choke.SuccessfullyConnected();
            });
            31.Times(x => choke.StartSend());
            choke.ShouldBeginSend().ShouldBeFalse();
        }
        public void available_sending_count_some_connected_some_still_connecting()
        {
            var choke = new SendingChoke();

            4.Times(x =>
            {
                choke.StartSend();
                choke.SuccessfullyConnected();
            });
            25.Times(x => choke.StartSend());
            choke.AvailableSendingCount.ShouldEqual(1);
        }
        public void choke_returns_true_if_several_connecting_but_not_connected_yet_up_to_maximum_connecting_count()
        {
            var choke = new SendingChoke();

            4.Times(x =>
            {
                choke.StartSend();
                choke.SuccessfullyConnected();
            });
            30.Times(x =>
            {
                choke.StartSend();
            });
            choke.ShouldBeginSend().ShouldBeTrue();
        }
 public void choke_returns_false_if_max_sending_isnt_exceeded_but_max_connecting_is()
 {
     var choke = new SendingChoke();
     2.Times(x =>
     {
         choke.StartSend();
         choke.SuccessfullyConnected();
     });
     31.Times(x => choke.StartSend());
     choke.ShouldBeginSend().ShouldBeFalse();
 }
 public void choke_returns_false_if_at_max_sending_count()
 {
     var choke = new SendingChoke();
     5.Times(x =>
     {
         choke.StartSend();
         choke.SuccessfullyConnected();
     });
     choke.ShouldBeginSend().ShouldBeFalse();
 }
 public void choke_returns_true_if_several_connecting_but_not_connected_yet_up_to_maximum_connecting_count()
 {
     var choke = new SendingChoke();
     4.Times(x =>
     {
         choke.StartSend();
         choke.SuccessfullyConnected();
     });
     30.Times(x =>
     {
         choke.StartSend();
     });
     choke.ShouldBeginSend().ShouldBeTrue();
 }