Skip to content

Commit

Permalink
renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
Meir017 committed Oct 25, 2017
1 parent 9d9d685 commit 4b48c83
Show file tree
Hide file tree
Showing 22 changed files with 65 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public class CollectionTests
[NotImplemented]
public void NoDiagnostics(string assertion) => VerifyCSharpNoDiagnosticsCodeBlock(assertion);


[AssertionDataTestMethod]
[AssertionDiagnostic("actual.Any().Should().BeTrue({0});")]
[AssertionDiagnostic("actual.AsEnumerable().Any().Should().BeTrue({0}).And.ToString();")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ public class CollectionShouldBeInAscendingOrderCodeFix : FluentAssertionsCodeFix
protected override ExpressionSyntax GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties)
{
var remove = NodeReplacement.RemoveAndExtractArguments("OrderBy");
var newStatement = GetNewExpression(expression, remove);
var newExpression = GetNewExpression(expression, remove);

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

return GetNewExpression(newStatement, NodeReplacement.PrependArguments("BeInAscendingOrder", remove.Arguments));
return GetNewExpression(newExpression, NodeReplacement.PrependArguments("BeInAscendingOrder", remove.Arguments));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ public class CollectionShouldBeInDescendingOrderCodeFix : FluentAssertionsCodeFi
protected override ExpressionSyntax GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties)
{
var remove = NodeReplacement.RemoveAndExtractArguments("OrderByDescending");
var newStatement = GetNewExpression(expression, remove);
var newExpression = GetNewExpression(expression, remove);

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

return GetNewExpression(newStatement, NodeReplacement.PrependArguments("BeInDescendingOrder", remove.Arguments));
return GetNewExpression(newExpression, NodeReplacement.PrependArguments("BeInDescendingOrder", remove.Arguments));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public class CollectionShouldContainItemCodeFix : FluentAssertionsCodeFixProvide
protected override ExpressionSyntax GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties)
{
var remove = new NodeReplacement.RemoveAndExtractArgumentsNodeReplacement("Contains");
var newStatement = GetNewExpression(expression, remove);
var newExpression = GetNewExpression(expression, remove);

return GetNewExpression(newStatement, new NodeReplacement.RenameAndPrependArgumentsNodeReplacement("BeTrue", "Contain", remove.Arguments));
return GetNewExpression(newExpression, new NodeReplacement.RenameAndPrependArgumentsNodeReplacement("BeTrue", "Contain", remove.Arguments));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ protected override ExpressionSyntax GetNewExpression(ExpressionSyntax expression
if (properties.VisitorName == nameof(CollectionShouldContainPropertyAnalyzer.AnyShouldBeTrueSyntaxVisitor))
{
var remove = new NodeReplacement.RemoveAndExtractArgumentsNodeReplacement("Any");
var newStatement = GetNewExpression(expression, remove);
var newExpression = GetNewExpression(expression, remove);

return GetNewExpression(newStatement, new NodeReplacement.RenameAndPrependArgumentsNodeReplacement("BeTrue", "Contain", remove.Arguments));
return GetNewExpression(newExpression, new NodeReplacement.RenameAndPrependArgumentsNodeReplacement("BeTrue", "Contain", remove.Arguments));
}
else if (properties.VisitorName == nameof(CollectionShouldContainPropertyAnalyzer.WhereShouldNotBeEmptySyntaxVisitor))
{
var remove = new NodeReplacement.RemoveAndExtractArgumentsNodeReplacement("Where");
var newStatement = GetNewExpression(expression, remove);
var newExpression = GetNewExpression(expression, remove);

return GetNewExpression(newStatement, new NodeReplacement.RenameAndPrependArgumentsNodeReplacement("NotBeEmpty", "Contain", remove.Arguments));
return GetNewExpression(newExpression, new NodeReplacement.RenameAndPrependArgumentsNodeReplacement("NotBeEmpty", "Contain", remove.Arguments));
}
throw new System.InvalidOperationException($"Invalid visitor name - {properties.VisitorName}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ public class CollectionShouldContainSingleCodeFix : FluentAssertionsCodeFixProvi

protected override ExpressionSyntax GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties)
{
var newStatement = GetNewExpression(expression, NodeReplacement.RenameAndRemoveFirstArgument("HaveCount", "ContainSingle"));
var newExpression = GetNewExpression(expression, NodeReplacement.RenameAndRemoveFirstArgument("HaveCount", "ContainSingle"));
if (properties.VisitorName == nameof(CollectionShouldContainSingleAnalyzer.ShouldHaveCount1SyntaxVisitor))
{
return newStatement;
return newExpression;
}
else if (properties.VisitorName == nameof(CollectionShouldContainSingleAnalyzer.WhereShouldHaveCount1SyntaxVisitor))
{
var remove = NodeReplacement.RemoveAndExtractArguments("Where");
newStatement = GetNewExpression(newStatement, remove);
newExpression = GetNewExpression(newExpression, remove);

return GetNewExpression(newStatement, NodeReplacement.PrependArguments("ContainSingle", remove.Arguments));
return GetNewExpression(newExpression, NodeReplacement.PrependArguments("ContainSingle", remove.Arguments));
}
throw new System.InvalidOperationException($"Invalid visitor name - {properties.VisitorName}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ public class CollectionShouldEqualOtherCollectionByComparerCodeFix : FluentAsser
protected override ExpressionSyntax GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties)
{
var removeMethodContainingFirstLambda = NodeReplacement.RemoveAndExtractArguments("Select");
var newStatement = GetNewExpression(expression, removeMethodContainingFirstLambda);
var newExpression = GetNewExpression(expression, removeMethodContainingFirstLambda);

var removeArgument = NodeReplacement.RemoveFirstArgument("Equal");
newStatement = GetNewExpression(newStatement, removeArgument);
newExpression = GetNewExpression(newExpression, removeArgument);

var argumentInvocation = (InvocationExpressionSyntax)removeArgument.Argument.Expression;
var identifier = ((MemberAccessExpressionSyntax)argumentInvocation.Expression).Expression;
Expand All @@ -68,7 +68,7 @@ protected override ExpressionSyntax GetNewExpression(ExpressionSyntax expression
.Add(removeArgument.Argument.WithExpression(CombineLambdas(firstLambda, secondLambda).NormalizeWhitespace()
));

return GetNewExpression(newStatement, NodeReplacement.PrependArguments("Equal", newArguments));
return GetNewExpression(newExpression, NodeReplacement.PrependArguments("Equal", newArguments));
}

private ParenthesizedLambdaExpressionSyntax CombineLambdas(SimpleLambdaExpressionSyntax left, SimpleLambdaExpressionSyntax right) => SyntaxFactory.ParenthesizedLambdaExpression(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,23 @@ protected override ExpressionSyntax GetNewExpression(ExpressionSyntax expression
if (properties.VisitorName == nameof(CollectionShouldHaveElementAtAnalyzer.ElementAtIndexShouldBeSyntaxVisitor))
{
var remove = NodeReplacement.RemoveAndExtractArguments("ElementAt");
var newStatement = GetNewExpression(expression, remove);
var newExpression = GetNewExpression(expression, remove);

return GetNewExpression(newStatement, NodeReplacement.RenameAndPrependArguments("Be", "HaveElementAt", remove.Arguments));
return GetNewExpression(newExpression, NodeReplacement.RenameAndPrependArguments("Be", "HaveElementAt", remove.Arguments));
}
else if (properties.VisitorName == nameof(CollectionShouldHaveElementAtAnalyzer.IndexerShouldBeSyntaxVisitor))
{
var remove = NodeReplacement.RemoveAndRetrieveIndexerArguments("Should");
var newStatement = GetNewExpression(expression, remove);
var newExpression = GetNewExpression(expression, remove);

return GetNewExpression(newStatement, NodeReplacement.RenameAndPrependArguments("Be", "HaveElementAt", remove.Arguments));
return GetNewExpression(newExpression, NodeReplacement.RenameAndPrependArguments("Be", "HaveElementAt", remove.Arguments));
}
else if (properties.VisitorName == nameof(CollectionShouldHaveElementAtAnalyzer.SkipFirstShouldBeSyntaxVisitor))
{
var remove = NodeReplacement.RemoveAndExtractArguments("Skip");
var newStatement = GetNewExpression(expression, remove, NodeReplacement.Remove("First"));
var newExpression = GetNewExpression(expression, remove, NodeReplacement.Remove("First"));

return GetNewExpression(newStatement, NodeReplacement.RenameAndPrependArguments("Be", "HaveElementAt", remove.Arguments));
return GetNewExpression(newExpression, NodeReplacement.RenameAndPrependArguments("Be", "HaveElementAt", remove.Arguments));
}
throw new System.InvalidOperationException($"Invalid visitor name - {properties.VisitorName}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public class CollectionShouldIntersectWithCodeFix : FluentAssertionsCodeFixProvi
protected override ExpressionSyntax GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties)
{
var remove = NodeReplacement.RemoveAndExtractArguments("Intersect");
var newStatement = GetNewExpression(expression, remove);
var newExpression = GetNewExpression(expression, remove);

return GetNewExpression(newStatement, NodeReplacement.RenameAndPrependArguments("NotBeEmpty", "IntersectWith", remove.Arguments));
return GetNewExpression(newExpression, NodeReplacement.RenameAndPrependArguments("NotBeEmpty", "IntersectWith", remove.Arguments));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@ protected override ExpressionSyntax GetNewExpression(ExpressionSyntax expression
if (properties.VisitorName == nameof(CollectionShouldNotBeNullOrEmptyAnalyzer.ShouldNotBeNullAndNotBeEmptySyntaxVisitor))
{
var remove = NodeReplacement.RemoveAndExtractArguments("NotBeEmpty");
var newStatement = GetNewExpression(expression, remove);
var newExpression = GetNewExpression(expression, remove);

return GetNewExpression(newStatement, NodeReplacement.RenameAndPrependArguments("NotBeNull", "NotBeNullOrEmpty", remove.Arguments));
return GetNewExpression(newExpression, NodeReplacement.RenameAndPrependArguments("NotBeNull", "NotBeNullOrEmpty", remove.Arguments));
}
else if (properties.VisitorName == nameof(CollectionShouldNotBeNullOrEmptyAnalyzer.ShouldNotBeEmptyAndNotBeNullSyntaxVisitor))
{
var remove = NodeReplacement.RemoveAndExtractArguments("NotBeNull");
var newStatement = GetNewExpression(expression, remove);
var newExpression = GetNewExpression(expression, remove);

return GetNewExpression(newStatement, NodeReplacement.RenameAndPrependArguments("NotBeEmpty", "NotBeNullOrEmpty", remove.Arguments));
return GetNewExpression(newExpression, NodeReplacement.RenameAndPrependArguments("NotBeEmpty", "NotBeNullOrEmpty", remove.Arguments));
}
throw new System.InvalidOperationException($"Invalid visitor name - {properties.VisitorName}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public class CollectionShouldNotContainItemCodeFix : FluentAssertionsCodeFixProv
protected override ExpressionSyntax GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties)
{
var remove = new NodeReplacement.RemoveAndExtractArgumentsNodeReplacement("Contains");
var newStatement = GetNewExpression(expression, remove);
var newExpression = GetNewExpression(expression, remove);

return GetNewExpression(newStatement, new NodeReplacement.RenameAndPrependArgumentsNodeReplacement("BeFalse", "NotContain", remove.Arguments));
return GetNewExpression(newExpression, new NodeReplacement.RenameAndPrependArgumentsNodeReplacement("BeFalse", "NotContain", remove.Arguments));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public class CollectionShouldNotContainNullsCodeFix : FluentAssertionsCodeFixPro
protected override ExpressionSyntax GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties)
{
var remove = NodeReplacement.RemoveAndExtractArguments("Select");
var newStatement = GetNewExpression(expression, remove);
var newExpression = GetNewExpression(expression, remove);

return GetNewExpression(newStatement, NodeReplacement.PrependArguments("NotContainNulls", remove.Arguments));
return GetNewExpression(newExpression, NodeReplacement.PrependArguments("NotContainNulls", remove.Arguments));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,16 @@ protected override ExpressionSyntax GetNewExpression(ExpressionSyntax expression
if (properties.VisitorName == nameof(CollectionShouldNotContainPropertyAnalyzer.AnyShouldBeFalseSyntaxVisitor))
{
var remove = new NodeReplacement.RemoveAndExtractArgumentsNodeReplacement("Any");
var newStatement = GetNewExpression(expression, remove);
var newExpression = GetNewExpression(expression, remove);

return GetNewExpression(newStatement, NodeReplacement.RenameAndPrependArguments("BeFalse", "NotContain", remove.Arguments));
return GetNewExpression(newExpression, NodeReplacement.RenameAndPrependArguments("BeFalse", "NotContain", remove.Arguments));
}
else if (properties.VisitorName == nameof(CollectionShouldNotContainPropertyAnalyzer.WhereShouldBeEmptySyntaxVisitor))
{
var remove = new NodeReplacement.RemoveAndExtractArgumentsNodeReplacement("Where");
var newStatement = GetNewExpression(expression, remove);
var newExpression = GetNewExpression(expression, remove);

return GetNewExpression(newStatement, NodeReplacement.RenameAndPrependArguments("BeEmpty", "NotContain", remove.Arguments));
return GetNewExpression(newExpression, NodeReplacement.RenameAndPrependArguments("BeEmpty", "NotContain", remove.Arguments));
}
else if (properties.VisitorName == nameof(CollectionShouldNotContainPropertyAnalyzer.ShouldOnlyContainNotSyntaxVisitor))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public class CollectionShouldNotIntersectWithCodeFix : FluentAssertionsCodeFixPr
protected override ExpressionSyntax GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties)
{
var remove = NodeReplacement.RemoveAndExtractArguments("Intersect");
var newStatement = GetNewExpression(expression, remove);
var newExpression = GetNewExpression(expression, remove);

return GetNewExpression(newStatement, NodeReplacement.RenameAndPrependArguments("BeEmpty", "NotIntersectWith", remove.Arguments));
return GetNewExpression(newExpression, NodeReplacement.RenameAndPrependArguments("BeEmpty", "NotIntersectWith", remove.Arguments));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public class CollectionShouldOnlyContainPropertyCodeFix : FluentAssertionsCodeFi
protected override ExpressionSyntax GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties)
{
var remove = new NodeReplacement.RemoveAndExtractArgumentsNodeReplacement("All");
var newStatement = GetNewExpression(expression, remove);
var newExpression = GetNewExpression(expression, remove);

return GetNewExpression(newStatement, new NodeReplacement.RenameAndPrependArgumentsNodeReplacement("BeTrue", "OnlyContain", remove.Arguments));
return GetNewExpression(newExpression, new NodeReplacement.RenameAndPrependArgumentsNodeReplacement("BeTrue", "OnlyContain", remove.Arguments));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public class CollectionShouldOnlyHaveUniqueItemsByComparerCodeFix : FluentAssert
protected override ExpressionSyntax GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties)
{
var remove = NodeReplacement.RemoveAndExtractArguments("Select");
var newStatement = GetNewExpression(expression, remove);
var newExpression = GetNewExpression(expression, remove);

return GetNewExpression(newStatement, NodeReplacement.PrependArguments("OnlyHaveUniqueItems", remove.Arguments));
return GetNewExpression(newExpression, NodeReplacement.PrependArguments("OnlyHaveUniqueItems", remove.Arguments));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public class DictionaryShouldContainKeyCodeFix : FluentAssertionsCodeFixProvider
protected override ExpressionSyntax GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties)
{
var remove = NodeReplacement.RemoveAndExtractArguments("ContainsKey");
var newStatement = GetNewExpression(expression, remove);
var newExpression = GetNewExpression(expression, remove);

return GetNewExpression(newStatement, NodeReplacement.RenameAndPrependArguments("BeTrue", "ContainKey", remove.Arguments));
return GetNewExpression(newExpression, NodeReplacement.RenameAndPrependArguments("BeTrue", "ContainKey", remove.Arguments));
}
}
}
Loading

0 comments on commit 4b48c83

Please sign in to comment.