Ejemplo n.º 1
0
        public void RemoveMessageShouldDoIt()
        {
            // Arrange
            _messageQueueHandler.AppendMessage(_message);
            var initialSize     = _messageQueueHandler.MessagesCount;
            var messageToRemove = _message;

            // Act
            _messageQueueHandler.RemoveMessage(messageToRemove);
            var currentSize = _messageQueueHandler.MessagesCount;

            // Assert
            Assert.That(currentSize, Is.EqualTo(initialSize - 1));
        }
Ejemplo n.º 2
0
        private void ReplaceMessageInChannel(Channel channel, Message message,
                                             IMessageQueueHandler messageQueueHandler)
        {
            var isSuccess = TryMoveMessageToChannel(channel, message);

            messageQueueHandler.RemoveMessage(message);

            if (!isSuccess)
            {
                if (message.MessageType == MessageType.SendingRequest)
                {
                    var sender = _network.GetNodeById(message.LastTransferNodeId);
                    _messageReceiver.HandleReceivedMessage(sender, message);
                }
                else
                {
                    messageQueueHandler.AddMessageInStart(message);
                }
            }
            else
            {
                _handledMessagesInNode.Add(message);
            }
        }