Exemplo n.º 1
0
        public void Initialize()
        {
            _config          = new TextProcessorConfig();
            _numberingConfig = new NumberingConfig();
            _instance        = new TextProcessorPlugin(_config);
            _r = new Run(new Text("Some text."));
            _p = new Paragraph(new ParagraphProperties(), _r);
            _nestingHandler = Substitute.For <IContextNestingHandler>();
            _cssRegistrator = Substitute.For <ICssRegistrator>();
            _globalContext  = Substitute.For <IGlobalContext>();
            _globalContext.TryResolve(out ICssRegistrator val1).Returns(x => {
                x[0] = _cssRegistrator;
                return(true);
            });
            _globalContext.TryResolve(out NumberingConfig val2).Returns(x =>
            {
                x[0] = _numberingConfig;
                return(true);
            });
            _cssRegistrator.RegisterParagraph(null, null).ReturnsForAnyArgs(x => new CssClass());
            _cssRegistrator.RegisterRun(null, null, null).ReturnsForAnyArgs(x => new CssClass());

            _pContext = new RootElementContext(_globalContext, _p)
            {
                NestingHandler = _nestingHandler
            };
            _rContext = new ChildElementContext(_pContext)
            {
                Element = _r
            };
        }
Exemplo n.º 2
0
        public void ProcessParagraph_AddEmptyCharTest()
        {
            _p        = new Paragraph();
            _pContext = new RootElementContext(_globalContext, _p)
            {
                NestingHandler = _nestingHandler
            };

            _instance.ProcessParagraph(_pContext, _p);

            var firstNode = _pContext.Nodes.ElementAt(1);

            Assert.AreEqual("&#8203;", firstNode.TextPrefix);
        }
Exemplo n.º 3
0
        public void RemoveCrossRefs_Test()
        {
            var p        = new Paragraph(new Run(new Text(text)));
            var context  = new RootElementContext(null, p);
            var instance = new CrossReferencesCleanupPlugin();

            instance.RemoveCrossRefs(context, p);

            var mutations = context.Mutations
                            .Select(x => x as TextDeletion)
                            .Select(x => (x.Position, x.Offset))
                            .ToArray();

            Assert.AreEqual(3, mutations.Length);
            Assert.AreEqual((055, 39), mutations[0]);
            Assert.AreEqual((101, 39), mutations[1]);
            Assert.AreEqual((149, 39), mutations[2]);
        }
Exemplo n.º 4
0
 public void Initialize()
 {
     _rootElement   = BuildParagraph();
     _globalContext = Substitute.For <IGlobalContext>();
     _instance      = new RootElementContext(_globalContext, _rootElement);
 }