public void may_not_send_while_waiting_on_individual_ack() { var client = Substitute.For<IStompClient>(); var sut = new Subscription(client, "dkkdkd"); sut.AckType = "client-individual"; sut.Send(new BasicFrame("MESSAGE")); Action actual = () => sut.Send(new BasicFrame("MESSAGE")); actual.ShouldThrow<InvalidOperationException>(); }
public void throttle_auto_too() { var client = Substitute.For<IStompClient>(); var sut = new Subscription(client, "dkkdkd"); sut.MaxMessagesPerSecond = 2; sut.AckType = "auto"; sut.Send(new BasicFrame("MESSAGE")); sut.Send(new BasicFrame("MESSAGE")); Action actual = () => sut.Send(new BasicFrame("MESSAGE")); actual.ShouldThrow<InvalidOperationException>(); }
public void may_not_send_when_having_too_many_pending_messages() { var client = Substitute.For<IStompClient>(); var sut = new Subscription(client, "dkkdkd"); sut.MaxMessagesPerSecond = 30; sut.AckType = "client"; for (int i = 0; i < 20; i++) sut.Send(new BasicFrame("MESSAGE")); Action actual = () => sut.Send(new BasicFrame("MESSAGE")); actual.ShouldThrow<InvalidOperationException>(); }
public void just_ack_messages_up_to_the_given_one() { var client = Substitute.For<IStompClient>(); var frame1 = new BasicFrame("MESSAGE"); var frame2 = new BasicFrame("MESSAGE"); var frame3 = new BasicFrame("MESSAGE"); frame1.AddHeader("message-id", "kdkd1"); frame2.AddHeader("message-id", "kdkd2"); frame3.AddHeader("message-id", "kdkd3"); var sut = new Subscription(client, "abc"); sut.AckType = "client"; sut.Send(frame1); sut.Send(frame2); sut.Send(frame3); sut.Ack("kdkd2"); sut.IsMessagePending("kdkd1").Should().BeFalse(); sut.IsMessagePending("kdkd2").Should().BeFalse(); sut.IsMessagePending("kdkd3").Should().BeTrue(); }
public void get_existent_subscription() { var client = Substitute.For<IStompClient>(); var subscription = new Subscription(client, "abc"); var frame = new BasicFrame("MESSAGE"); frame.AddHeader("message-id", "kdkd"); subscription.AckType = "client-individual"; subscription.Send(frame); var actual = subscription.IsMessagePending("kdkd"); actual.Should().BeTrue(); }
public void ack_messages_can_ack_all_since_we_dont_allow_multiple_pending_messages_with_client_individual_ack_type() { var channel = Substitute.For<ITcpChannel>(); var transactionManager = Substitute.For<ITransactionManager>(); var client = Substitute.For<IStompClient>(); var subscription = new Subscription(client, "abc"); subscription.AckType = "client"; var frame1 = new BasicFrame("MESSAGE"); frame1.AddHeader("message-id", "kdkd1"); var frame2 = new BasicFrame("MESSAGE"); frame2.AddHeader("message-id", "kdkd2"); var frame3 = new BasicFrame("MESSAGE"); frame3.AddHeader("message-id", "kdkd3"); subscription.Send(frame1); subscription.Send(frame2); subscription.Send(frame3); var sut = new StompClient(channel, transactionManager); sut.AddSubscription(subscription); sut.AckMessages("kdkd2"); var actual1 = sut.IsFramePending("kdkd1"); var actual2 = sut.IsFramePending("kdkd2"); var actual3 = sut.IsFramePending("kdkd3"); actual1.Should().BeFalse(); actual2.Should().BeFalse(); actual3.Should().BeTrue(); }
public void sent_message_should_be_pending_using_client_ack_type() { var channel = Substitute.For<ITcpChannel>(); var transactionManager = Substitute.For<ITransactionManager>(); var client = Substitute.For<IStompClient>(); var subscription = new Subscription(client, "abc"); var frame = new BasicFrame("MESSAGE"); frame.AddHeader("message-id", "kdkd"); subscription.AckType = "client"; subscription.Send(frame); var sut = new StompClient(channel, transactionManager); sut.AddSubscription(subscription); var actual = sut.IsFramePending("kdkd"); actual.Should().BeTrue(); }
public void get_existent_subscription() { var channel = Substitute.For<ITcpChannel>(); var transactionManager = Substitute.For<ITransactionManager>(); var client = Substitute.For<IStompClient>(); var subscription = new Subscription(client, "abc"); var frame = new BasicFrame("SEND"); frame.AddHeader("message-id", "kdkd"); subscription.AckType = "client-individual"; subscription.Send(frame); var sut = new StompClient(channel, transactionManager); sut.AddSubscription(subscription); var actual = sut.GetSubscription("kdkd"); actual.Should().BeSameAs(subscription); }