public void WriteTo_LeftOnlyWithLimitedContext() { DiffSet diffSet = new DiffSet(new Diff[] { new Diff(DiffKind.Change, new Range(0, 1), new Range(0, 1)), // change new Diff(DiffKind.NoChange, new Range(1, 20), new Range(1, 20)), // same new Diff(DiffKind.Change, new Range(21, 1), new Range(21, 0)), // deletion new Diff(DiffKind.NoChange, new Range(22, 20), new Range(21, 20)), // same new Diff(DiffKind.Change, new Range(42, 0), new Range(41, 1)), // addition }, "accccccccccccccccccccdeeeeeeeeeeeeeeeeeeee", "bcccccccccccccccccccceeeeeeeeeeeeeeeeeeeef"); StructuredTextWriter writer = new StructuredTextWriter(); diffSet.WriteTo(writer, DiffStyle.LeftOnly, 7); Assert.AreEqual(new StructuredText(new BodyTag() { Contents = { new MarkerTag(Marker.DiffChange) { Contents = { new TextTag("a") } }, new TextTag("ccc"), new MarkerTag(Marker.Ellipsis) { Contents = { new TextTag("...") } }, new TextTag("ccc"), new MarkerTag(Marker.DiffDeletion) { Contents = { new TextTag("d") } }, new TextTag("eee"), new MarkerTag(Marker.Ellipsis) { Contents = { new TextTag("...") } }, new TextTag("eee") } }), writer.ToStructuredText()); }
public void WriteToThrowsWhenMaxContextLengthIsNegative() { DiffSet diffSet = new DiffSet(new Diff[] { }, "", ""); StructuredTextWriter writer = new StructuredTextWriter(); Assert.Throws<ArgumentOutOfRangeException>(() => diffSet.WriteTo(writer, DiffStyle.Interleaved, -1)); }
public void WriteTo_RightOnlyStyle() { DiffSet diffSet = new DiffSet(new Diff[] { new Diff(DiffKind.Change, new Range(0, 1), new Range(0, 1)), // change new Diff(DiffKind.NoChange, new Range(1, 1), new Range(1, 1)), // same new Diff(DiffKind.Change, new Range(2, 1), new Range(2, 0)), // deletion new Diff(DiffKind.NoChange, new Range(3, 1), new Range(2, 1)), // same new Diff(DiffKind.Change, new Range(4, 0), new Range(3, 1)), // addition }, "acde", "bcef"); StructuredTextWriter writer = new StructuredTextWriter(); diffSet.WriteTo(writer, DiffStyle.RightOnly); TestLog.WriteLine(writer); Assert.AreEqual(new StructuredText(new BodyTag() { Contents = { new MarkerTag(Marker.DiffChange) { Contents = { new TextTag("b") } }, new TextTag("ce"), new MarkerTag(Marker.DiffDeletion) { Contents = { new TextTag("f") } } } }), writer.ToStructuredText()); }
public void WriteToThrowsWhenWriterIsNull() { DiffSet diffSet = new DiffSet(new Diff[] { }, "", ""); Assert.Throws<ArgumentNullException>(() => diffSet.WriteTo(null)); }