public void RegionWithBeginLineOnSecondLineConvertedToSegment()
        {
            DomRegion region = new DomRegion(2, 1, 3, 1);

            document.Text = "1234567890\r\n1234567890\r\n1234567890";
            WixDocumentLineSegment segment = WixDocumentLineSegment.ConvertRegionToSegment(document, region);

            WixDocumentLineSegment expectedSegment = new WixDocumentLineSegment(12, 13);

            Assert.AreEqual(expectedSegment, segment);
        }
        public void TwoLineRegionConvertedToSegment()
        {
            DomRegion region = new DomRegion(1, 2, 2, 1);

            document.Text = "1234567890\r\n1234567890";
            WixDocumentLineSegment segment = WixDocumentLineSegment.ConvertRegionToSegment(document, region);

            WixDocumentLineSegment expectedSegment = new WixDocumentLineSegment(1, 12);

            Assert.AreEqual(expectedSegment, segment);
        }
        public void ThreeLineRegionWithoutCarriageReturnConvertedToSegment()
        {
            DomRegion region = new DomRegion(1, 3, 3, 2);

            document.Text = "1234567890\n1234567890\n1234567890";
            WixDocumentLineSegment segment = WixDocumentLineSegment.ConvertRegionToSegment(document, region);

            WixDocumentLineSegment expectedSegment = new WixDocumentLineSegment(2, 22);

            Assert.AreEqual(expectedSegment, segment);
        }
        public void Init()
        {
            originalXml =
                "<root>\r\n" +
                "\t<child>\r\n" +
                "\t</child>\r\n" +
                "</root>";

            textEditor = new MockTextEditor();
            textEditor.OptionsConvertTabsToSpaces = false;
            textEditor.OptionsIndentationSize     = 4;
            textEditor.OptionsIndentationString   = "\t";

            document = textEditor.Document;

            textEditor.Document.Text = originalXml;

            // Replace the <child> element
            WixDocumentEditor editor = new WixDocumentEditor(textEditor);

            string xmlToInsert =
                "<new-child>\r\n" +
                "</new-child>";

            int line    = 2;
            int column  = 2;
            int endLine = 3;

            // End column is the column containing the '>' of the </child> element.
            int endColumn = 9;

            var region = new DomRegion(line, column, endLine, endColumn);

            WixDocumentLineSegment lineSegment = WixDocumentLineSegment.ConvertRegionToSegment(textEditor.Document, region);

            initialDocumentRegionText = textEditor.Document.GetText(lineSegment.Offset, lineSegment.Length);

            editor.Replace(region, xmlToInsert);
        }