Beispiel #1
0
 public void Initialize()
 {
     _cssRegistrator = Substitute.For <ICssRegistrator>();
     _styleConveter  = Substitute.For <IStyleConverter>();
     _styleConveter.BuildRegistrator().Returns(_cssRegistrator);
     _config   = new StyleConfig();
     _instance = new StylePlugin(_styleConveter, _config);
     _css      = new StringBuilder();
     _state    = Substitute.For <IProcessingState>();
     _state.Css.Returns(_css);
     _state.Elements.Returns(_ => new ElementProcessingState[0]);
     _state.GetContext(out ICssRegistrator _)
     .Returns(x =>
     {
         x[0] = _cssRegistrator;
         return(true);
     });
     _parentVNode  = new VNode();
     _currentVNode = new VNode();
     _elemState    = Substitute.For <IElementProcessingState>();
     _elemState.ProcessingState.Returns(_state);
     _elemState
     .GetContext(out ParagraphContext _)
     .Returns(x =>
     {
         x[0] = new ParagraphContext {
             Parent = _parentVNode
         };
         return(true);
     });
     _elemState.CurrentVNode.Returns(_ => _currentVNode);
 }
            public override Paragraph VisitParagraph([NotNull] ParagraphContext context)
            {
                var lineVisitor = new TextAreasVisitor().Inherit(this);
                var lines       = new List <ITextArea>();
                var children    = context.lines();

                lines.AddRange(lineVisitor.VisitLines(children));
                return(new Paragraph(lines));
            }
Beispiel #3
0
        private void MockElemState(int index, int length)
        {
            var parent = new VNode("div", "", 0, length);
            var pVNode = new VNode("p", "", 0, length);

            _paragraphContext = new ParagraphContext {
                Parent = parent
            };
            _elementState.Index.Returns(index);
            _elementState
            .GetContext(out ParagraphContext _)
            .Returns(x =>
            {
                x[0] = _paragraphContext;
                return(true);
            });
        }
 public void Initialize()
 {
     _config           = new NumberingConfig();
     _numberingMapper  = Substitute.For <INumberingMapper>();
     _paragraphContext = new ParagraphContext
     {
         CustomCss = new CssData(),
         Parent    = new VNode()
     };
     _state = Substitute.For <IElementProcessingState>();
     _state.GetContext(out ParagraphContext _).Returns(x =>
     {
         x[0] = _paragraphContext;
         return(true);
     });
     _level    = new Level();
     _instance = new NumberingPlugin(_numberingMapper, _config);
 }
        public ArticleServiceTests()
        {
            var services = new ServiceCollection();

            services.AddDbContext <ParagraphContext>(opt =>
                                                     opt.UseInMemoryDatabase(Guid.NewGuid().ToString()));
            services.AddScoped(typeof(IRepository <>), typeof(DbRepository <>));
            services.AddScoped <ITagService, TagService>();
            services.AddScoped <IArticleService, ArticleService>();

            AutoMapperConfig.RegisterMappings(
                typeof(ArticleViewModel).Assembly,
                typeof(IndexArticleViewModel).Assembly
                );

            this.provider       = services.BuildServiceProvider();
            this.context        = provider.GetService <ParagraphContext>();
            this.articleService = provider.GetService <IArticleService>();
        }
        public RequestServiceTests()
        {
            var services = new ServiceCollection();

            services.AddDbContext <ParagraphContext>(opt =>
                                                     opt.UseInMemoryDatabase(Guid.NewGuid().ToString()));
            services.AddScoped(typeof(IRepository <>), typeof(DbRepository <>));
            services.AddScoped <IRequestService, RequestService>();
            services.AddScoped <UserManager <ParagraphUser> >();
            services.AddScoped <RequestService, RequestService>();
            services.AddIdentity <ParagraphUser, IdentityRole>(
                options =>
            {
                options.Password.RequireDigit           = true;
                options.Password.RequiredLength         = 6;
                options.Password.RequireLowercase       = true;
                options.Password.RequireNonAlphanumeric = true;
                options.User.RequireUniqueEmail         = true;
            })
            .AddEntityFrameworkStores <ParagraphContext>()
            .AddRoles <IdentityRole>()
            .AddDefaultTokenProviders();

            services.AddScoped <RoleManager <IdentityRole> >();

            AutoMapperConfig.RegisterMappings(
                typeof(ArticleViewModel).Assembly,
                typeof(IndexArticleViewModel).Assembly
                );


            this.provider       = services.BuildServiceProvider();
            this.context        = provider.GetService <ParagraphContext>();
            this.requestService = provider.GetService <IRequestService>();
            this.roleManager    = provider.GetService <RoleManager <IdentityRole> >();

            this.userManager = provider.GetService <UserManager <ParagraphUser> >();
        }
    public ParagraphContext paragraph()
    {
        ParagraphContext _localctx = new ParagraphContext(Context, State);

        EnterRule(_localctx, 2, RULE_paragraph);
        try {
            State = 34;
            ErrorHandler.Sync(this);
            switch (TokenStream.LA(1))
            {
            case TEMPLATE_NAME_LINE:
                EnterOuterAlt(_localctx, 1);
                {
                    State = 27; templateDefinition();
                }
                break;

            case IMPORT:
                EnterOuterAlt(_localctx, 2);
                {
                    State = 28; importDefinition();
                }
                break;

            case OPTION:
                EnterOuterAlt(_localctx, 3);
                {
                    State = 29; optionDefinition();
                }
                break;

            case INVALID_LINE:
                EnterOuterAlt(_localctx, 4);
                {
                    State = 30; errorDefinition();
                }
                break;

            case COMMENT:
                EnterOuterAlt(_localctx, 5);
                {
                    State = 31; commentDefinition();
                }
                break;

            case NEWLINE:
                EnterOuterAlt(_localctx, 6);
                {
                    State = 32; Match(NEWLINE);
                }
                break;

            case Eof:
                EnterOuterAlt(_localctx, 7);
                {
                    State = 33; Match(Eof);
                }
                break;

            default:
                throw new NoViableAltException(this);
            }
        }
        catch (RecognitionException re) {
            _localctx.exception = re;
            ErrorHandler.ReportError(this, re);
            ErrorHandler.Recover(this, re);
        }
        finally {
            ExitRule();
        }
        return(_localctx);
    }