Exemple #1
0
        private static void TestCanNotFix(string codeSnippet)
        {
            var expressionSyntax             = SyntaxFactory.ParseExpression(codeSnippet);
            var memberAccessExpressionSyntax = expressionSyntax.DescendantNodesAndSelf().OfType <MemberAccessExpressionSyntax>().First();
            var result = DefaulIfNullExpressionHelper.CanFix(memberAccessExpressionSyntax);

            Assert.IsFalse(result);
        }
Exemple #2
0
        private static void TestFix(string codeSnippet, string expectedResult)
        {
            var expressionSyntax             = SyntaxFactory.ParseExpression(codeSnippet);
            var memberAccessExpressionSyntax = expressionSyntax.DescendantNodesAndSelf().OfType <MemberAccessExpressionSyntax>().First();

            var canFix = DefaulIfNullExpressionHelper.CanFix(memberAccessExpressionSyntax);

            Assert.IsTrue(canFix);

            var resultSyntax = DefaulIfNullExpressionHelper.CreateRelacementNode((InvocationExpressionSyntax)expressionSyntax);
            var resultSTring = resultSyntax.ToFullString();

            Assert.AreEqual(expectedResult, resultSTring);
        }