public void Context()
 {
     var template = EmailTemplateBuilder.New
         .WithInitialHtml("12345")
         .WithVariable(1, 1)
         .WithVariable(1, 1)
         .Build();
     const int emailId = 78;
     _email = new EmailBuilder()
         .WithId(emailId)
         .WithEmailTemplate(template)
         .Build();
     var emailDto = new EmailDto
                                {
                                    EmailId = emailId,
                                    Parts = new[]
                                                {
                                                    new EmailPartDto
                                                        {
                                                            PartId = _email.Parts.ElementAt(1).Id,
                                                            PartType = PartType.Variable,
                                                            VariableValue = "A"
                                                        },
                                                    new EmailPartDto
                                                        {
                                                            PartId = _email.Parts.ElementAt(3).Id,
                                                            PartType = PartType.Variable,
                                                            VariableValue = "B"
                                                        },
                                                }
                                };
     _email.UpdateVariables(emailDto);
 }
 public void Context()
 {
     var template = EmailTemplateBuilder.New
         .WithInitialHtml("12345")
         .Build();
     const int emailId = 78;
     var email = new EmailBuilder()
         .WithId(56)
         .WithEmailTemplate(template)
         .Build();
     var emailDto = new EmailDto {EmailId = emailId};
     _exception = Should.Throw<CoreException>(() => email.UpdateVariables(emailDto));
 }
        public void Context()
        {
            _email = MockRepository.GenerateMock<Email>();

            const int emailId = 23;
            var emailRepository = MockRepository.GenerateStub<IRepository<Email>>();
            emailRepository.Stub(a => a.GetById(emailId)).Return(_email);

            _emailDto = new EmailDto
                                    {
                                        EmailId = emailId,
                                    };
            var command = new UpdateEmailVariablesCommand
                              {
                                  Email = _emailDto,
                              };
            var handler = new UpdateEmailVariablesCommandHandler(emailRepository);
            handler.Execute(command);
        }
Пример #4
0
 public virtual void UpdateVariables(EmailDto emailDto)
 {
     Guard.Hope(Id == emailDto.EmailId, "Invalid email id");
     emailDto.Parts.Each(part =>
     {
         if (part.PartType == PartType.Variable)
         {
             _SetVariableValue(part.PartId, part.VariableValue);
         }
         else
         {
             throw new EmailMakerException("Unknown email part type: " + part.PartType);
         }
     });
 }