Example #1
0
        public async Task VerifyRefactoringAsync(
            string source,
            string sourceData,
            string expectedData,
            IEnumerable <string> additionalFiles = null,
            string equivalenceKey = null,
            TestOptions options   = null,
            CancellationToken cancellationToken = default)
        {
            var code = TestCode.Parse(source, sourceData, expectedData);

            Debug.Assert(code.Spans.Length > 0);

            var expected = ExpectedTestState.Parse(code.ExpectedValue);

            var data = new RefactoringTestData(
                code.Value,
                code.Spans.OrderByDescending(f => f.Start).ToImmutableArray(),
                AdditionalFile.CreateRange(additionalFiles),
                equivalenceKey: equivalenceKey);

            await VerifyRefactoringAsync(
                data,
                expected,
                options,
                cancellationToken : cancellationToken);
        }
Example #2
0
        public async Task VerifyNoRefactoringAsync(
            string source,
            string equivalenceKey = null,
            TestOptions options   = null,
            CancellationToken cancellationToken = default)
        {
            var code = TestCode.Parse(source);

            var data = new RefactoringTestData(
                code.Value,
                code.Spans,
                equivalenceKey: equivalenceKey);

            await VerifyNoRefactoringAsync(
                data,
                options,
                cancellationToken : cancellationToken);
        }
Example #3
0
        public static void TestExpressionChainEnumerator_WithSpan4()
        {
            const string s    = @"
class C
{
    void M(string a, string b)
    {
        string s = a + [|b|];
    }
}";
            var          code = TestCode.Parse(s);

            BinaryExpressionSyntax be = CSharpSyntaxTree.ParseText(code.Value).GetRoot().FirstDescendant <BinaryExpressionSyntax>();

            ExpressionChain.Enumerator en = new ExpressionChain(be, code.Spans[0]).GetEnumerator();

            Assert.True(en.MoveNext() && en.Current == be.Right);
            Assert.True(!en.MoveNext());
        }
Example #4
0
        public async Task VerifyDiagnosticAsync(
            string source,
            IEnumerable <string> additionalFiles = null,
            TestOptions options = null,
            CancellationToken cancellationToken = default)
        {
            var code = TestCode.Parse(source);

            var data = new DiagnosticTestData(
                Descriptor,
                code.Value,
                code.Spans,
                code.AdditionalSpans,
                additionalFiles: AdditionalFile.CreateRange(additionalFiles));

            await VerifyDiagnosticAsync(
                data,
                options : options,
                cancellationToken : cancellationToken);
        }
Example #5
0
        public static void TestExpressionChainReversedEnumerator_WithSpan()
        {
            const string s    = @"
class C
{
    void M(string a, string b, string c)
    {
        string s = [|a + b + c|];
    }
}";
            var          code = TestCode.Parse(s);

            BinaryExpressionSyntax be = CSharpSyntaxTree.ParseText(code.Value).GetRoot().FirstDescendant <BinaryExpressionSyntax>();
            var be2 = (BinaryExpressionSyntax)be.Left;

            ExpressionChain.Reversed.Enumerator en = new ExpressionChain(be, code.Spans[0]).Reverse().GetEnumerator();

            Assert.True(en.MoveNext() && en.Current == be.Right);
            Assert.True(en.MoveNext() && en.Current == be2.Right);
            Assert.True(en.MoveNext() && en.Current == be2.Left);
            Assert.True(!en.MoveNext());
        }
Example #6
0
        public async Task VerifyDiagnosticAsync(
            string source,
            string sourceData,
            IEnumerable <string> additionalFiles = null,
            TestOptions options = null,
            CancellationToken cancellationToken = default)
        {
            var code = TestCode.Parse(source, sourceData);

            Debug.Assert(code.Spans.Length > 0);

            var state = new DiagnosticTestState(
                Descriptor,
                source,
                code.Spans,
                code.AdditionalSpans,
                additionalFiles: AdditionalFile.CreateRange(additionalFiles));

            await VerifyDiagnosticAsync(
                state,
                options : options,
                cancellationToken : cancellationToken);
        }