private EmailNotificationDispatcher CreateEmailNotificationDispatcher()
 {
     var dispatcher = new EmailNotificationDispatcher(
         new NetEmailService {Configuration = ObjectFactory.GetInstance<IConfiguration>()},
         CreateTemplateService(), CreateDataSource());
     // TODO: move to config
     return dispatcher;
 }
        public void DispatchShouldSendCorrectSubjectAndMessage()
        {
            var emailService = new Mock<IEmailService>();
            var emailNotificationDispatcher = new EmailNotificationDispatcher(
                emailService.Object, CreateTemplateServiceStub().Object, CreateLocalizedDataSourceStub().Object);

            emailNotificationDispatcher.Dispatch(CreateNotifiableStub().Object, CreateNotificationStub().Object);

            emailService.Verify(x => x.Send(EmailAddress, Subject, Body, UseHtmlEmail));
        }
        public void DispatchShouldInvokeTemplateService()
        {
            var templateService = new Mock<ITemplateService>();
            var emailNotificationDispatcher = new EmailNotificationDispatcher(
                new Mock<IEmailService>().Object, templateService.Object, CreateLocalizedDataSourceStub().Object);

            emailNotificationDispatcher.Dispatch(CreateNotifiableStub().Object, CreateNotificationStub().Object);

            templateService.Verify(x => x.Parse(TemplateText, Parameter));
        }
        public void DispatchShouldInvokeLocalizedDataSource()
        {
            var localizedDataSource = new Mock<ILocalizedDataSource>();
            var emailNotificationDispatcher = new EmailNotificationDispatcher(
                new Mock<IEmailService>().Object, new Mock<ITemplateService>().Object, localizedDataSource.Object);

            emailNotificationDispatcher.Dispatch(CreateNotifiableStub().Object, CreateNotificationStub().Object);

            localizedDataSource.Verify(x => x.GetContent(MessageType, LanguageCode));
        }
        public void DispatchShouldInvokeEmailService()
        {
            var emailService = new Mock<IEmailService>();
            var emailNotificationDispatcher = new EmailNotificationDispatcher(
                emailService.Object, new Mock<ITemplateService>().Object, new Mock<ILocalizedDataSource>().Object);

            emailNotificationDispatcher.Dispatch(CreateNotifiableStub().Object, CreateNotificationStub().Object);

            emailService.Verify(x => x.Send(EmailAddress, It.IsAny<string>(), It.IsAny<string>(), UseHtmlEmail));
        }