Пример #1
0
        public void Context()
        {
            _persistEmail();

            var queryHandler = new GetEmailPartsQueryHandler(UnitOfWork);

            _result = queryHandler.Execute <EmailPartDto>(new GetEmailPartsQuery {
                EmailId = _email.Id
            });

            void _persistEmail()
            {
                var user = UserBuilder.New.Build();

                UnitOfWork.Save(user);
                var emailTemplate = EmailTemplateBuilder.New
                                    .WithInitialHtml("123")
                                    .WithName("template name")
                                    .WithUserId(user.Id)
                                    .Build();

                UnitOfWork.Save(emailTemplate);
                emailTemplate.CreateVariable(emailTemplate.Parts.First().Id, 1, 1);
                UnitOfWork.Save(emailTemplate);

                var anotherEmailTemplate = EmailTemplateBuilder.New
                                           .WithInitialHtml("another html")
                                           .WithName("template name")
                                           .WithUserId(user.Id)
                                           .Build();

                UnitOfWork.Save(anotherEmailTemplate);

                _email = new Email(emailTemplate);
                UnitOfWork.Save(_email);
            }
        }
 protected override void PersistenceQuery()
 {
     var query = new GetEmailPartsQueryHandler();
     _result = query.Execute<EmailPartDto>(new GetEmailPartsQuery { EmailId = _email.Id });
 }