public void ShouldAddNewNotificationToQueue()
        {
            _target.Publish(_notification);

            _notificationValidator.Verify(_ => _.Validate(_notification), Times.Once);
            _messageQueue.Verify(_ => _.BeginWrite(MessageQueueKeys.Notifications), Times.Once);
            _queueWriter.Verify(_ => _.Send(SerializedNotification), Times.Once);
        }
        private void CreateAndSendNotification(NotificationRuleBundle bundle, Users targetUser)
        {
            var userAddress = _userDataProvider.GetDeliveryContacts(bundle.NotificationRule.DeliveryProtocol, targetUser);

            if (string.IsNullOrEmpty(userAddress))
            {
                _logger.Warning(Resources.Resources.UserHasntContacts.FormatWith(
                                    targetUser.Login,
                                    bundle.NotificationRule.DeliveryProtocol));

                return;
            }

            var notificationParameters = new ConcurrentDictionary <string, object>();

            foreach (var attachmentParameter in bundle.NotificationNotificationParameters)
            {
                notificationParameters.AddOrUpdate(attachmentParameter.Key,
                                                   attachmentParameter.Value,
                                                   (s, o) => attachmentParameter.Value);
            }

            notificationParameters.AddOrUpdate(DefaultReportParameters.ContainerUseTable, true, (s, o) => true);

            var notificationReport = _reportBuilder.Build(
                bundle.NotificationRule.Expression.ReportId,
                targetUser.Id,
                notificationParameters,
                ReportFileType.Html);

            var notification = new Notification
            {
                Attachments = GetAttachments(bundle, targetUser),
                Message     = notificationReport.RawHtml,
                Protocol    = bundle.NotificationRule.DeliveryProtocol,
                Targets     = new[] { userAddress },
                Title       = notificationReport.Title
            };

            _notificationProvider.Publish(notification);
        }