Beispiel #1
0
        private void MockElementContext(int numberingId, int levelId, string verbose)
        {
            _p     = new Paragraph();
            _pData = Substitute.For <IParagraphData>();
            _pData.NumberingId.Returns(numberingId);
            _pData.LevelIndex.Returns(levelId);
            _pData.Verbose.Returns(verbose);
            _pData.LevelXmlElement.Returns(_level);
            _nMapper = Substitute.For <INumberingMapper>();
            _nMapper.IsValid.Returns(true);
            _nMapper.GetNumbering(_p).Returns(_pData);
            _cssRegistrator = Substitute.For <ICssRegistrator>();
            _cssRegistrator
            .RegisterRun(Arg.Any <ParagraphProperties>(), Arg.Any <RunProperties>(), (numberingId, levelId))
            .Returns(new CssClass {
                Name = $"dynamic-cls"
            });

            _elementContext = Substitute.For <IElementContext>();
            _elementContext.Resolve <INumberingMapper>().Returns(_nMapper);
            _elementContext.TryResolve(out ICssRegistrator z).Returns(x =>
            {
                x[0] = _cssRegistrator;
                return(true);
            });
            _elementContext.Element.Returns(_p);
            _elementContext.RootElement.Returns(_p);
            _elementContext
            .When(x => x.AddNode(Arg.Any <HtmlNode>()))
            .Do(x => _nodes.Add(x.ArgAt <HtmlNode>(0)));
            _elementContext
            .When(x => x.AddMutation(Arg.Any <Mutation>()))
            .Do(x => _mutations.Add(x.ArgAt <Mutation>(0)));
        }
Beispiel #2
0
 public NumberingPlugin(
     INumberingMapper numberingMapper,
     NumberingConfig config = null)
 {
     if (config == null)
     {
         _config = new NumberingConfig();
     }
     else
     {
         _config = config;
     }
     _numberingMapper = numberingMapper;
 }
 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);
 }
Beispiel #4
0
 public NumberingPlugin(INumberingMapper numberingMapper, NumberingConfig config)
 {
     _numberingMapper = numberingMapper;
     _config          = config;
 }
Beispiel #5
0
 public NumberingPlugin(INumberingMapper numberingMapper) : this(numberingMapper, new NumberingConfig())
 {
 }