public void ShouldHandleHugeAmountTextSpans_WhenBatchModeIsActive(Int32 lines) { // Given var textBuilder = new StringBuilder(); var line = "one,two,three,four"; for (var i = 0; i < lines; i++) { textBuilder.AppendLine(line); } var underTest = new TextDocument(textBuilder.ToString()); var ranges = new List <TextRange>(); for (var i = 0; i < lines; i++) { var offset = (line.Length + Environment.NewLine.Length) * i; ranges.Add(underTest.CreateOrGetTextRange(offset + 0, offset + 3)); underTest.CreateOrGetTextRange(offset + 4, offset + 7); } // When var watch = Stopwatch.StartNew(); underTest.BeginTransaction(); foreach (var range in ranges) { underTest.ChangeText(range, "onetwo"); } underTest.EndTransaction(); watch.Stop(); // Then Console.WriteLine(watch.Elapsed); }