コード例 #1
0
        public void CanAdvanceAheadNCharacters()
        {
            using (var empty = new LinedTextTestFixture(""))
            {
                empty.Advance(0);
                empty.ToString().ShouldBe("");
                empty.Advance(1);
                empty.ToString().ShouldBe("");
            }

            using (var abc = new LinedTextTestFixture("abc"))
            {
                abc.ReadLine().ShouldBeTrue();
                abc.ToString().ShouldBe("(1, 1)abc");
                abc.Advance(1);
                abc.ToString().ShouldBe("(1, 2)bc");
                abc.Advance(1);
                abc.ToString().ShouldBe("(1, 3)c");
                abc.Advance(1);
                abc.ToString().ShouldBe("(1, 4)");
                abc.Advance(1);
                abc.ToString().ShouldBe("(1, 4)");
                abc.Advance(100);
                abc.ToString().ShouldBe("(1, 4)");
            }
        }
コード例 #2
0
        public void TextToStringShowsEllipsisForLongInputs()
        {
            const string complex =
                @"{""numbers"" : [10, 20, 30], ""window"": { ""title"": ""Sample Widget"", ""parent"": null, ""maximized"": true, ""transparent"": false}}";

            using (var text = new LinedTextTestFixture(complex))
            {
                text.ReadLine();
                text.ToString().ShouldBe(@"(1, 1){""numbers"" : [10, 20, 30], ""window"": { ""title"": ""S...");
            }
        }