protected override ExpressionSyntax GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties)
        {
            if (properties.VisitorName == nameof(DictionaryShouldContainPairAnalyzer.ShouldContainKeyAndContainValueSyntaxVisitor))
            {
                var remove        = NodeReplacement.RemoveAndExtractArguments("ContainValue");
                var newExpression = GetNewExpression(expression, remove);

                var newArguments = GetArgumentsWithFirstAsPairIdentifierArgument(remove.Arguments);

                newExpression = GetNewExpression(newExpression, NodeReplacement.RenameAndRemoveFirstArgument("ContainKey", "Contain"));

                newExpression = GetNewExpression(newExpression, NodeReplacement.PrependArguments("Contain", newArguments));

                return(newExpression);
            }
            else if (properties.VisitorName == nameof(DictionaryShouldContainPairAnalyzer.ShouldContainValueAndContainKeySyntaxVisitor))
            {
                var remove        = NodeReplacement.RemoveAndExtractArguments("ContainKey");
                var newExpression = GetNewExpression(expression, remove);

                var newArguments = GetArgumentsWithFirstAsPairIdentifierArgument(remove.Arguments);

                newExpression = GetNewExpression(newExpression, NodeReplacement.RenameAndRemoveFirstArgument("ContainValue", "Contain"));

                newExpression = GetNewExpression(newExpression, NodeReplacement.PrependArguments("Contain", newArguments));

                return(newExpression);
            }
            else
            {
                throw new InvalidOperationException($"Invalid visitor name - {properties.VisitorName}");
            }
        }
Exemplo n.º 2
0
        protected override ExpressionSyntax GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties)
        {
            var remove        = NodeReplacement.RemoveAndExtractArguments("OrderByDescending");
            var newExpression = GetNewExpression(expression, remove);

            newExpression = GetNewExpression(newExpression, NodeReplacement.RenameAndRemoveFirstArgument("Equal", "BeInDescendingOrder"));

            return(GetNewExpression(newExpression, NodeReplacement.PrependArguments("BeInDescendingOrder", remove.Arguments)));
        }
 protected override ExpressionSyntax GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties)
 {
     if (properties.VisitorName == nameof(CollectionShouldHaveCountAnalyzer.CountShouldBe0SyntaxVisitor))
     {
         return(GetNewExpression(expression, NodeReplacement.Remove("Count"), NodeReplacement.RenameAndRemoveFirstArgument("Be", "BeEmpty")));
     }
     else if (properties.VisitorName == nameof(CollectionShouldHaveCountAnalyzer.CountShouldBe1SyntaxVisitor))
     {
         return(GetNewExpression(expression, NodeReplacement.Remove("Count"), NodeReplacement.RenameAndRemoveFirstArgument("Be", "ContainSingle")));
     }
     else if (properties.VisitorName == nameof(CollectionShouldHaveCountAnalyzer.CountShouldBeSyntaxVisitor))
     {
         return(GetNewExpression(expression, NodeReplacement.Remove("Count"), NodeReplacement.Rename("Be", "HaveCount")));
     }
     throw new System.InvalidOperationException($"Invalid visitor name - {properties.VisitorName}");
 }
        protected override ExpressionSyntax GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties)
        {
            var newExpression = GetNewExpression(expression, NodeReplacement.RenameAndRemoveFirstArgument("HaveCount", "ContainSingle"));

            if (properties.VisitorName == nameof(CollectionShouldContainSingleAnalyzer.ShouldHaveCount1SyntaxVisitor))
            {
                return(newExpression);
            }
            else if (properties.VisitorName == nameof(CollectionShouldContainSingleAnalyzer.WhereShouldHaveCount1SyntaxVisitor))
            {
                var remove = NodeReplacement.RemoveAndExtractArguments("Where");
                newExpression = GetNewExpression(newExpression, remove);

                return(GetNewExpression(newExpression, NodeReplacement.PrependArguments("ContainSingle", remove.Arguments)));
            }
            throw new System.InvalidOperationException($"Invalid visitor name - {properties.VisitorName}");
        }
 protected override ExpressionSyntax GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties)
 {
     return(GetNewExpression(expression, NodeReplacement.RenameAndRemoveFirstArgument("BeGreaterThan", "BePositive")));
 }
 protected override ExpressionSyntax GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties)
 {
     return(GetNewExpression(expression, NodeReplacement.RenameAndRemoveFirstArgument("HaveSameCount", "OnlyHaveUniqueItems")));
 }