public void Context()
        {
            _emailTemplate = A.Fake <EmailTemplate>();

            const int emailTemplateId         = 23;
            var       emailTemplateRepository = A.Fake <IRepository <EmailTemplate> >();

            A.CallTo(() => emailTemplateRepository.GetAsync(emailTemplateId)).Returns(_emailTemplate);

            _htmlTemplatePartId = 47;
            _htmlStartIndex     = 56;
            _length             = 65;
            _emailTemplateDto   = new EmailTemplateDto
            {
                EmailTemplateId = emailTemplateId,
            };
            var command = new CreateVariableCommand
            {
                EmailTemplate      = _emailTemplateDto,
                HtmlStartIndex     = _htmlStartIndex,
                HtmlTemplatePartId = _htmlTemplatePartId,
                Length             = _length
            };
            var handler = new CreateVariableCommandHandler(emailTemplateRepository);

            handler.ExecuteAsync(command).Wait();
        }
Exemplo n.º 2
0
        public void Evaluate(IEnumerable <object> statements)
        {
            BeginScope();

            foreach (var statement in statements)
            {
                if (statement is Branch)
                {
                    Branch branch = (Branch)statement;

                    var branchCommand = new BranchCommand(branch.Left, branch.Right);
                    branchCommand.Run(this);
                }
                else if (statement is EndBranch)
                {
                    var endBranchCommand = new EndBranchCommand();
                    endBranchCommand.Run(this);
                }

                /* Todo: This breaks the pattern because we can't roll
                 *  up these commands into a list before looping through to run them.
                 */
                else if (SkipLines)
                {
                    var doNothingCommand = new DoNothingCommand();
                    doNothingCommand.Run(this);
                }

                else if (statement is CreateVariable)
                {
                    var createVariable = (CreateVariable)statement;

                    var createVariableCommand = new CreateVariableCommand(createVariable.Name,
                                                                          createVariable.Value);

                    createVariableCommand.Run(this);
                }
                else if (statement is Assignment)
                {
                    var assignment = (Assignment)statement;

                    var assignmentCommand = new AssignmentCommand(assignment.Name,
                                                                  assignment.Value);

                    assignmentCommand.Run(this);
                }
                else if (statement is MethodCall)
                {
                    var methodCall = (MethodCall)statement;

                    var methodCallCommand = new MethodCallCommand("print",
                                                                  methodCall.Arguments);

                    methodCallCommand.Run(this);
                }
            }

            EndScope();
        }
Exemplo n.º 3
0
        public async Task CreateVariable(
#if NETCOREAPP
            [FromBody]
#endif
            CreateVariableCommand command)
        {
            await _commandExecutor.ExecuteAsync(command);
        }
Exemplo n.º 4
0
        public async Task Context()
        {
            _commandExecutor = A.Fake <ICommandExecutor>();
            _queryExecutor   = A.Fake <IQueryExecutor>();
            A.CallTo(() => _queryExecutor.ExecuteAsync <GetUserDetailsByEmailAddressQuery, UserDto>(A <GetUserDetailsByEmailAddressQuery> ._))
            .Returns(new[] { new UserDto() });
            var controller = new TemplateController(_commandExecutor, _queryExecutor);

            _createVariableCommand = new CreateVariableCommand();

            await controller.CreateVariable(_createVariableCommand);
        }