Ejemplo n.º 1
0
        public string  SubscribeToNewsletter(SubscriptionDTO subscriptionDTO)
        {
            if (SubscriptionRepository.Get(s => s.SubscriberEmail == subscriptionDTO.SubscriberEmail).Any(s => s.SubscriptionType == SubscriptionType.Newsletter))
            {
                throw new ApplicationValidationErrorsException(new List <string> {
                    Resources.AppMessages.Subscription_Exists
                });
            }
            Subscription subscription = SubscriptionFactory.CreateSubscription(subscriptionDTO.SubscriberName, subscriptionDTO.SubscriberEmail, subscriptionDTO.IsConfirmed);

            SubscriptionRepository.Insert(subscription);
            SubscriptionRepository.UnitOfWork.Commit();
            return(subscription.ConfirmationToken);
        }
Ejemplo n.º 2
0
        public void CreateSubscription_SenderExist_ShouldUseCorrectSender()
        {
            var queueName = "126_queue";
            var autoAck   = false;
            var model     = new Mock <IModel>();

            var factory = new SubscriptionFactory();

            var subscription = factory.CreateSubscription(model.Object, queueName, autoAck);

            Assert.AreEqual(subscription.AutoAck, autoAck);
            Assert.AreEqual(subscription.QueueName, queueName);
            Assert.AreEqual(subscription.Model, model.Object);
        }