Ejemplo n.º 1
0
        public void matching_texts_and_whitespaces()
        {
            FakeVirtualString v = new FakeVirtualString(" AB  \t\r C");
            var    m            = new VirtualStringMatcher(v);
            Action a;

            m.MatchText("A").Should().BeFalse();
            m.StartIndex.Should().Be(0);
            m.MatchWhiteSpaces().Should().BeTrue();
            m.StartIndex.Should().Be(1);
            m.MatchText("A").Should().BeTrue();
            m.MatchText("B").Should().BeTrue();
            m.StartIndex.Should().Be(3);
            m.MatchWhiteSpaces(6).Should().BeFalse();
            m.MatchWhiteSpaces(5).Should().BeTrue();
            m.StartIndex.Should().Be(8);
            m.MatchWhiteSpaces().Should().BeFalse();
            m.StartIndex.Should().Be(8);
            m.MatchText("c").Should().BeTrue();
            m.StartIndex.Should().Be(v.Length);
            m.IsEnd.Should().BeTrue();

            a = () => m.MatchText("c"); a.ShouldNotThrow();
            a = () => m.MatchWhiteSpaces(); a.ShouldNotThrow();
            m.MatchText("A").Should().BeFalse();
            m.MatchWhiteSpaces().Should().BeFalse();
        }
Ejemplo n.º 2
0
        public void virtualstring_matching()
        {
            FakeVirtualString v = new FakeVirtualString("Hello world!");
            var m = new VirtualStringMatcher(v);

            m.Text.GetText(0, (int)m.Length).Should().Be("Hello world!");
            m.Text.GetText(0, (int)m.Length - 1).Should().NotBe("Hello world!");
            m.Text[5].Should().Be(' ');
            m.Text[v.Length - 1].Should().Be('!');
            m.Text.GetText(0, 5).Should().Be("Hello");
            m.Text.GetText(6, 5).Should().Be("world");
        }
Ejemplo n.º 3
0
        public void matching_JSONQUotedString(string s, string parsed, string textAfter)
        {
            FakeVirtualString v = new FakeVirtualString(s);
            var m = new VirtualStringMatcher(v);

            m.TryMatchJSONQuotedString(out string result, true).Should().BeTrue();
            result.Should().Be(parsed);
            m.TryMatchText(textAfter).Should().BeTrue();

            m = new VirtualStringMatcher(v);
            m.TryMatchJSONQuotedString(true).Should().BeTrue();
            m.TryMatchText(textAfter).Should().BeTrue();
        }