public void WhenSameMessageLikeReviewIsSentMultipleTimesInRow_ThenThrottleThemAndOnlyEmitLatestMessage()
        {
            var testScheduler = new TestScheduler();
            var listener      = new List <string>();
            var throttler     = new MessageThrottler(testScheduler);

            throttler.Messages().Subscribe(x => listener.Add(x.model.Title));

            throttler.Emit("same_channel", new SlackMessageModel("same_title", "_"));
            throttler.Emit("same_channel", new SlackMessageModel("same_title", "_"));
            throttler.Emit("same_channel", new SlackMessageModel("same_title", "_"));

            testScheduler.AdvanceBy(TimeSpan.FromSeconds(20).Ticks);

            listener.Should().HaveCount(1);
        }
Esempio n. 2
0
 public void Send(string slackChannel, SlackMessageModel model)
 {
     throttler.Emit(slackChannel, model);
 }