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 override bool Equals(object obj) { WixDocumentLineSegment rhs = obj as WixDocumentLineSegment; if (rhs != null) { return((offset == rhs.offset) && (length == rhs.length)); } return(false); }
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 BeginLineOnSecondLine() { DomRegion region = new DomRegion(1, 0, 2, 0); DocumentFactory factory = new DocumentFactory(); IDocument document = factory.CreateDocument(); document.TextContent = "1234567890\r\n1234567890\r\n1234567890"; ISegment segment = WixDocument.ConvertRegionToSegment(document, region); WixDocumentLineSegment expectedSegment = new WixDocumentLineSegment(12, 13); Assert.AreEqual(expectedSegment, segment); }
public void ThreeLinesWithoutCarriageReturn() { DomRegion region = new DomRegion(0, 2, 2, 1); DocumentFactory factory = new DocumentFactory(); IDocument document = factory.CreateDocument(); document.TextContent = "1234567890\n1234567890\n1234567890"; ISegment segment = WixDocument.ConvertRegionToSegment(document, region); WixDocumentLineSegment expectedSegment = new WixDocumentLineSegment(2, 22); Assert.AreEqual(expectedSegment, segment); }
public void SingleLine() { DomRegion region = new DomRegion(0, 0, 0, 5); DocumentFactory factory = new DocumentFactory(); IDocument document = factory.CreateDocument(); document.TextContent = "1234567890"; ISegment segment = WixDocument.ConvertRegionToSegment(document, region); WixDocumentLineSegment expectedSegment = new WixDocumentLineSegment(0, 6); Assert.AreEqual(expectedSegment, segment); }
public override bool Equals(object obj) { WixDocumentLineSegment lineSegment = obj as WixDocumentLineSegment; if (lineSegment == null) { return(false); } if (this == lineSegment) { return(true); } return(offset == lineSegment.offset && length == lineSegment.length); }
/// <summary> /// Replaces the text at the given region with the specified xml. After replacing /// the inserted text is indented and then selected. /// </summary> public void Replace(DomRegion region, string xml) { WixDocumentLineSegment segment = WixDocumentLineSegment.ConvertRegionToSegment(document, region); using (textEditor.Document.OpenUndoGroup()) { // Replace the original xml with the new xml and indent it. int originalLineCount = document.TotalNumberOfLines; int initialIndent = GetIndent(region.BeginLine); document.Replace(segment.Offset, segment.Length, xml); int addedLineCount = document.TotalNumberOfLines - originalLineCount; // Indent the xml. int insertedCharacterCount = IndentAllLinesTheSame(region.BeginLine + 1, region.EndLine + addedLineCount, initialIndent); // Make sure the text inserted is visible. textEditor.JumpTo(region.BeginLine, 1); // Select the text just inserted. int textInsertedLength = insertedCharacterCount + xml.Length; textEditor.Select(segment.Offset, textInsertedLength); } }
public void NullSegmentIsNotEqualToSegment() { WixDocumentLineSegment lhs = new WixDocumentLineSegment(1, 4); Assert.IsFalse(lhs.Equals(null)); }
public void SegmentsWithSameLengthAndDifferentOffsetAreNotEqual() { WixDocumentLineSegment lhs = new WixDocumentLineSegment(3, 5); WixDocumentLineSegment rhs = new WixDocumentLineSegment(4, 5); Assert.IsFalse(lhs.Equals(rhs)); }
public void SegmentsWithSameOffsetAndLengthAreEqual() { WixDocumentLineSegment lhs = new WixDocumentLineSegment(4, 5); WixDocumentLineSegment rhs = new WixDocumentLineSegment(4, 5); Assert.IsTrue(lhs.Equals(rhs)); }