示例#1
0
        public void SetValue_ShouldSetSelectedTextBySpanToGivenValueAndUpdateTextRangesInTheSameLine_WhenSpanStartAndStopAreInDifferentLinesAndColumnsAndThereAreMultipleSpansWithoutConflict()
        {
            // Given
            var text = multiLineText("Hello World!",
                                     "How is it going?",
                                     "We are working on a very exciting project.",
                                     "Come and join us!");

            var underTest = new DefaultTextManager(text);

            var firstSpan  = underTest.CreateOrGetTextSpan(new TextPosition(0, 0), new TextPosition(1, 3));
            var secondSpan = underTest.CreateOrGetTextSpan(new TextPosition(1, 4), new TextPosition(1, 6));

            // When
            underTest.SetValue("Where", firstSpan);
            var result = new {
                Spans = new[] { underTest.GetValue(firstSpan), underTest.GetValue(secondSpan) },
                Text  = underTest.GetText()
            };

            // Then
            Assert.That(result.Spans, Is.EquivalentTo(new[] { "Where", "is" }));

            var expectedText = multiLineText("Where is it going?",
                                             "We are working on a very exciting project.",
                                             "Come and join us!");

            Assert.That(result.Text, Is.EqualTo(expectedText));
        }
示例#2
0
        public void SetValue_ShouldSetSelectedTextBySpanToGivenValue_WhenSpanStartAndStopAreInSameLinesAndThereIsNoConflictBetweenSpans()
        {
            // Given
            var text = multiLineText("Hello World!",
                                     "How is it going?",
                                     "We are working on a very exciting project.",
                                     "Come and join us!");

            var underTest = new DefaultTextManager(text);
            var start     = new TextPosition(0, 0);
            var stop      = new TextPosition(0, 5);
            var textSpan  = underTest.CreateOrGetTextSpan(start, stop);

            // When
            underTest.SetValue("Hi", textSpan);
            var result = new
            {
                Span = underTest.GetValue(textSpan),
                Text = underTest.GetText()
            };

            // Then
            Assert.That(result, Is.EqualTo(new
            {
                Span = "Hi",
                Text = multiLineText("Hi World!",
                                     "How is it going?",
                                     "We are working on a very exciting project.",
                                     "Come and join us!")
            }));
        }
示例#3
0
        public void SetValue_ShouldSetSelectedTextBySpanToGivenValue_WhenSpanStartAndStopAreInSameLinesAndColumnsAndThereAreMultipleSpansWithoutConflict()
        {
            // Given
            var text = multiLineText("Hello World!",
                                     "How is it going?",
                                     "We are working on a very exciting project.",
                                     "Come and join us!");

            var underTest = new DefaultTextManager(text);

            var helloSpan = underTest.CreateOrGetTextSpan(new TextPosition(0, 0), new TextPosition(0, 5));
            var worldSpan = underTest.CreateOrGetTextSpan(new TextPosition(0, 6), new TextPosition(0, 11));

            // When
            underTest.SetValue("WORLD", worldSpan);
            var result = new
            {
                Spans = new[] { underTest.GetValue(helloSpan), underTest.GetValue(worldSpan) },
                Text  = underTest.GetText()
            };

            // Then
            Assert.That(result.Spans, Is.EquivalentTo(new[] { "Hello", "WORLD" }));

            var expectedText = multiLineText("Hello WORLD!",
                                             "How is it going?",
                                             "We are working on a very exciting project.",
                                             "Come and join us!");

            Assert.That(result.Text, Is.EqualTo(expectedText));
        }