Ejemplo n.º 1
0
        public void AddOneMessagesToQueue_GivenManyMessages_OnlyOneReady()
        {
            var automatedMessagingSystem = new AutomatedMessagingSystem();

            automatedMessagingSystem.Publish(new NeverReadyMessage());
            automatedMessagingSystem.Publish(new AlwaysReadyMessage());
            automatedMessagingSystem.Publish(new NeverReadyMessage());

            automatedMessagingSystem.CheckMessages(DateTime.Now);

            Assert.Single(automatedMessagingSystem.QueuedMessages);
        }
Ejemplo n.º 2
0
        public void AddAutomatedMessageToManagedMessages()
        {
            var messagingSystem  = new AutomatedMessagingSystem();
            var automatedMessage = new IntervalTriggeredMessage(1, "Welcome! If you are enjoying the content, please follow DevChatter for more!");

            messagingSystem.Publish(automatedMessage);

            Assert.Contains(automatedMessage, messagingSystem.ManagedMessages);
        }
Ejemplo n.º 3
0
        // TODO: Fix this method's name

        private void PublishMessages()
        {
            var messages = _repository.List <IntervalMessage>();

            foreach (var message in messages)
            {
                _autoMsgSystem.Publish(message);
            }
        }
Ejemplo n.º 4
0
        // TODO: Fix this method's name
        private void PublishMessages()
        {
            var messages = _repository.List(DataItemPolicy <IntervalTriggeredMessage> .ActiveOnly());

            foreach (var message in messages)
            {
                _autoMsgSystem.Publish(message);
            }
        }
Ejemplo n.º 5
0
        public void AddOneMessagesToQueue_GivenOneReadyAutomatedMessage()
        {
            var automatedMessagingSystem = new AutomatedMessagingSystem();

            automatedMessagingSystem.Publish(new AlwaysReadyMessage());

            automatedMessagingSystem.CheckMessages();

            Assert.Single(automatedMessagingSystem.QueuedMessages);
        }
Ejemplo n.º 6
0
        public void ReturnTrueAndProvideMessage_GivenSingleQueuedMessage()
        {
            var automatedMessagingSystem = new AutomatedMessagingSystem();
            var message = new AlwaysReadyMessage();

            automatedMessagingSystem.Publish(message);
            automatedMessagingSystem.CheckMessages();

            bool result = automatedMessagingSystem.DequeueMessage(out string myMessage);

            Assert.True(result);
            Assert.Equal(message.GetMessageInstance(), myMessage);
        }
Ejemplo n.º 7
0
        public void AddAutomatedMessageToManagedMessages()
        {
            var messagingSystem          = new AutomatedMessagingSystem();
            var intervalTriggeredMessage = new IntervalTriggeredMessage
            {
                DelayInMinutes = 1,
                Message        = "Welcome! If you are enjoying the content, please follow for more!"
            };

            messagingSystem.Publish(intervalTriggeredMessage);

            Assert.Contains(intervalTriggeredMessage, messagingSystem.ManagedAutomatedMessages);
        }
Ejemplo n.º 8
0
        public void ReturnOnlyOneMessage_GivenSingleQueuedMessage()
        {
            var automatedMessagingSystem = new AutomatedMessagingSystem();
            var message = new AlwaysReadyMessage();

            automatedMessagingSystem.Publish(message);
            automatedMessagingSystem.CheckMessages();

            automatedMessagingSystem.DequeueMessage(out string myMessage);
            bool result = automatedMessagingSystem.DequeueMessage(out string throwawayMessage);

            Assert.False(result);
            Assert.Equal(message.GetMessageInstance(), myMessage);
            Assert.Null(throwawayMessage);
        }