public void VerifyEmailUpdateTriggersUnsubscribeAndSubscribeEvent()
        {
            var eventPublisher = MockRepository.GenerateStub<IEventPublisher>();
            var repo = MockRepository.GenerateStub<IRepository<NewsLetterSubscription>>();
            var context = MockRepository.GenerateStub<IDbContext>();

            //Prepare the original result
            var originalSubscription = new NewsLetterSubscription { Active = true, Email = "*****@*****.**" };
            repo.Stub(m => m.GetById(Arg<object>.Is.Anything)).Return(originalSubscription);

            var subscription = new NewsLetterSubscription { Active = true, Email = "*****@*****.**" };

            var service = new NewsLetterSubscriptionService(context, repo, eventPublisher);
            service.UpdateNewsLetterSubscription(subscription, true);

            eventPublisher.AssertWasCalled(x => x.Publish(new EmailUnsubscribedEvent(originalSubscription.Email)));
            eventPublisher.AssertWasCalled(x => x.Publish(new EmailSubscribedEvent(subscription.Email)));
        }
        public void VerifyUpdateEventIsFired()
        {
            var eventPublisher = MockRepository.GenerateStub<IEventPublisher>();
            var repo = MockRepository.GenerateStub<IRepository<NewsLetterSubscription>>();
            var context = MockRepository.GenerateStub<IDbContext>();

            //Prepare the original result
            var originalSubscription = new NewsLetterSubscription { Active = false, Email = "*****@*****.**" };
            repo.Stub(m => m.GetById(Arg<object>.Is.Anything)).Return(originalSubscription);

            var service = new NewsLetterSubscriptionService(context, repo, eventPublisher);
            service.UpdateNewsLetterSubscription(new NewsLetterSubscription { Email = "*****@*****.**" });

            eventPublisher.AssertWasCalled(x => x.EntityUpdated(Arg<NewsLetterSubscription>.Is.Anything));
        }