コード例 #1
0
        public void EmptyText_OnePosition()
        {
            var text = "$$";
            var markupText = new MarkupText(text);

            Assert.AreEqual(expected: string.Empty, actual: markupText.Text);
            Assert.AreEqual(expected: 1, actual: markupText.Positions.Length);
            Assert.AreEqual(expected: 0, actual: markupText.Spans.Length);

            Assert.AreEqual(expected: new LinePosition(0, 0), actual: markupText.Positions[0]);
        }
コード例 #2
0
        public void EmptyText_TwoSpans_Nested()
        {
            var text = "[|[||]|]";
            var markupText = new MarkupText(text);

            Assert.AreEqual(expected: string.Empty, actual: markupText.Text);
            Assert.AreEqual(expected: 0, actual: markupText.Positions.Length);
            Assert.AreEqual(expected: 2, actual: markupText.Spans.Length);

            var expectedSpan = new LinePositionSpan(new LinePosition(0, 0), new LinePosition(0, 0));
            Assert.AreEqual(expected: expectedSpan, actual: markupText.Spans[0]);
            Assert.AreEqual(expected: expectedSpan, actual: markupText.Spans[1]);
        }
コード例 #3
0
        public void TestMethod2()
        {
            var test = new MarkupText(@"
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;
            using System.Diagnostics;

            namespace ConsoleApplication1
            {
            class [|TypeName|]
            {
            }
            }");
            var expected = new DiagnosticResult
            {
                Id = "ArgumentNullAnalyzer",
                Message = String.Format("Type name '{0}' contains lowercase letters", "TypeName"),
                Severity = DiagnosticSeverity.Warning,
                Locations = new[]
                {
                    new DiagnosticResultLocation("Test0.cs", test.Spans[0])
                }
            };

            VerifyCSharpDiagnostic(test.Text, expected);

            var fixtest = @"
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;
            using System.Diagnostics;

            namespace ConsoleApplication1
            {
            class TYPENAME
            {
            }
            }";
            VerifyCSharpFix(test.Text, fixtest);
        }
コード例 #4
0
        public void NoMarks_EmptyString()
        {
            var markupText = new MarkupText(string.Empty);

            Assert.AreEqual(expected: string.Empty, actual: markupText.Text);
            Assert.AreEqual(expected: 0, actual: markupText.Positions.Length);
            Assert.AreEqual(expected: 0, actual: markupText.Spans.Length);
        }
コード例 #5
0
        public void NoMarks()
        {
            var text = "Foo";
            var markupText = new MarkupText(text);

            Assert.AreEqual(expected: text, actual: markupText.Text);
            Assert.AreEqual(expected: 0, actual: markupText.Positions.Length);
            Assert.AreEqual(expected: 0, actual: markupText.Spans.Length);
        }
コード例 #6
0
        public void TwoPositions_Start()
        {
            var text = "$$$$Alpha Beta Gamma Delta";
            var markupText = new MarkupText(text);

            Assert.AreEqual(expected: "Alpha Beta Gamma Delta", actual: markupText.Text);
            Assert.AreEqual(expected: 2, actual: markupText.Positions.Length);
            Assert.AreEqual(expected: 0, actual: markupText.Spans.Length);

            Assert.AreEqual(expected: new LinePosition(0, 0), actual: markupText.Positions[0]);
            Assert.AreEqual(expected: new LinePosition(0, 0), actual: markupText.Positions[1]);
        }
コード例 #7
0
        public void Span_WholeText()
        {
            var text = "[|Alpha Beta Gamma|]";
            var markupText = new MarkupText(text);

            Assert.AreEqual(expected: "Alpha Beta Gamma", actual: markupText.Text);
            Assert.AreEqual(expected: 0, actual: markupText.Positions.Length);
            Assert.AreEqual(expected: 1, actual: markupText.Spans.Length);

            var expectedSpan = new LinePositionSpan(new LinePosition(0, 0), new LinePosition(0, 16));
            Assert.AreEqual(expected: expectedSpan, actual: markupText.Spans[0]);
        }
コード例 #8
0
        public void Span_Multiline()
        {
            var text = @"Alpha [|Beta
            Gamma
            Delta|]
            Epsilon";
            var markupText = new MarkupText(text);

            var expectedText = @"Alpha Beta
            Gamma
            Delta
            Epsilon";

            Assert.AreEqual(expected: expectedText, actual: markupText.Text);
            Assert.AreEqual(expected: 0, actual: markupText.Positions.Length);
            Assert.AreEqual(expected: 1, actual: markupText.Spans.Length);

            var expectedSpan = new LinePositionSpan(new LinePosition(0, 6), new LinePosition(2, 5));
            Assert.AreEqual(expected: expectedSpan, actual: markupText.Spans[0]);
        }
コード例 #9
0
        public void Span_MissingOpeningMark()
        {
            var text = "Alpha Beta|] Gamma";
            var markupText = new MarkupText(text);

            Assert.Fail("An exception should have been thrown");
        }
コード例 #10
0
        public void Span_Middle()
        {
            var text = "Alpha [|Beta|] Gamma";
            var markupText = new MarkupText(text);

            Assert.AreEqual(expected: "Alpha Beta Gamma", actual: markupText.Text);
            Assert.AreEqual(expected: 0, actual: markupText.Positions.Length);
            Assert.AreEqual(expected: 1, actual: markupText.Spans.Length);

            var expectedSpan = new LinePositionSpan(new LinePosition(0, 6), new LinePosition(0, 10));
            Assert.AreEqual(expected: expectedSpan, actual: markupText.Spans[0]);
        }
コード例 #11
0
        public void Position_Middle()
        {
            var text = "Alpha Beta$$ Gamma Delta";
            var markupText = new MarkupText(text);

            Assert.AreEqual(expected: "Alpha Beta Gamma Delta", actual: markupText.Text);
            Assert.AreEqual(expected: 1, actual: markupText.Positions.Length);
            Assert.AreEqual(expected: 0, actual: markupText.Spans.Length);

            Assert.AreEqual(expected: new LinePosition(0, 10), actual: markupText.Positions[0]);
        }