Skip to content

Commit aa0dae2

Browse files
committed
chore: update dependencies
1 parent 0db321a commit aa0dae2

File tree

2 files changed

+40
-26
lines changed

2 files changed

+40
-26
lines changed

src/FluentAssertions.Analyzers.Tests/TestAttributes.cs

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,10 @@ public class AssertionDiagnosticAttribute : Attribute, ITestDataSource
2626
{
2727
public string Assertion { get; }
2828

29-
public bool Ignore { get; }
30-
31-
public AssertionDiagnosticAttribute(string assertion, bool ignore = false) => (Assertion, Ignore) = (assertion, ignore);
29+
public AssertionDiagnosticAttribute(string assertion) => Assertion = assertion;
3230

3331
public IEnumerable<object[]> GetData(MethodInfo methodInfo)
3432
{
35-
if (Ignore) yield break;
36-
3733
foreach (var assertion in TestCasesInputUtils.GetTestCases(Assertion))
3834
{
3935
yield return new object[] { assertion };
@@ -43,20 +39,24 @@ public IEnumerable<object[]> GetData(MethodInfo methodInfo)
4339
public string GetDisplayName(MethodInfo methodInfo, object[] data) => $"{methodInfo.Name}(\"{data[0]}\")";
4440
}
4541

42+
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
43+
public class IgnoreAssertionDiagnosticAttribute : Attribute
44+
{
45+
public string Assertion { get; }
46+
47+
public IgnoreAssertionDiagnosticAttribute(string assertion) => Assertion = assertion;
48+
}
49+
4650
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
4751
public class AssertionCodeFixAttribute : Attribute, ITestDataSource
4852
{
4953
public string OldAssertion { get; }
5054
public string NewAssertion { get; }
5155

52-
public bool Ignore { get; }
53-
54-
public AssertionCodeFixAttribute(string oldAssertion, string newAssertion, bool ignore = false) => (OldAssertion, NewAssertion, Ignore) = (oldAssertion, newAssertion, ignore);
56+
public AssertionCodeFixAttribute(string oldAssertion, string newAssertion) => (OldAssertion, NewAssertion) = (oldAssertion, newAssertion);
5557

5658
public IEnumerable<object[]> GetData(MethodInfo methodInfo)
5759
{
58-
if (Ignore) yield break;
59-
6060
foreach (var (oldAssertion, newAssertion) in TestCasesInputUtils.GetTestCases(OldAssertion, NewAssertion))
6161
{
6262
yield return new object[] { oldAssertion, newAssertion };
@@ -66,22 +66,27 @@ public IEnumerable<object[]> GetData(MethodInfo methodInfo)
6666
public string GetDisplayName(MethodInfo methodInfo, object[] data) => $"{methodInfo.Name}(\"old: {data[0]}\", new: {data[1]}\")";
6767
}
6868

69+
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
70+
public class IgnoreAssertionCodeFixAttribute : Attribute
71+
{
72+
public string OldAssertion { get; }
73+
public string NewAssertion { get; }
74+
75+
public IgnoreAssertionCodeFixAttribute(string oldAssertion, string newAssertion) => (OldAssertion, NewAssertion) = (oldAssertion, newAssertion);
76+
}
77+
6978
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
7079
public class AssertionMethodCodeFixAttribute : Attribute, ITestDataSource
7180
{
7281
public string MethodArguments { get; }
7382
public string OldAssertion { get; }
7483
public string NewAssertion { get; }
7584

76-
public bool Ignore { get; }
77-
78-
public AssertionMethodCodeFixAttribute(string methodArguments, string oldAssertion, string newAssertion, bool ignore = false)
79-
=> (MethodArguments, OldAssertion, NewAssertion, Ignore) = (methodArguments, oldAssertion, newAssertion, ignore);
85+
public AssertionMethodCodeFixAttribute(string methodArguments, string oldAssertion, string newAssertion)
86+
=> (MethodArguments, OldAssertion, NewAssertion) = (methodArguments, oldAssertion, newAssertion);
8087

8188
public IEnumerable<object[]> GetData(MethodInfo methodInfo)
8289
{
83-
if (Ignore) yield break;
84-
8590
foreach (var (oldAssertion, newAssertion) in TestCasesInputUtils.GetTestCases(OldAssertion, NewAssertion))
8691
{
8792
yield return new object[] { MethodArguments, oldAssertion, newAssertion };
@@ -91,6 +96,17 @@ public IEnumerable<object[]> GetData(MethodInfo methodInfo)
9196
public string GetDisplayName(MethodInfo methodInfo, object[] data) => $"{methodInfo.Name}(\"arguments\":{data[0]}, \"old: {data[1]}\", new: {data[2]}\")";
9297
}
9398

99+
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
100+
public class IgnoreAssertionMethodCodeFixAttribute : Attribute
101+
{
102+
public string MethodArguments { get; }
103+
public string OldAssertion { get; }
104+
public string NewAssertion { get; }
105+
106+
public IgnoreAssertionMethodCodeFixAttribute(string methodArguments, string oldAssertion, string newAssertion)
107+
=> (MethodArguments, OldAssertion, NewAssertion) = (methodArguments, oldAssertion, newAssertion);
108+
}
109+
94110
public static class TestCasesInputUtils
95111
{
96112
private static readonly string Empty = string.Empty;

src/FluentAssertions.Analyzers.Tests/Tips/CollectionTests.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,10 @@ public class CollectionTests
185185
public void CollectionShouldNotContainProperty_WhereShouldBeEmpty_TestAnalyzer(string assertion) => VerifyCSharpDiagnosticCodeBlock(assertion, DiagnosticMetadata.CollectionShouldNotContainProperty_WhereShouldBeEmpty);
186186

187187
[DataTestMethod]
188-
[AssertionDiagnostic("actual.Should().OnlyContain(x => !x.BooleanProperty{0});", ignore: true)]
189-
[AssertionDiagnostic("actual.AsEnumerable().Should().OnlyContain(x => !x.BooleanProperty{0}).And.ToString();", ignore: true)]
190-
[AssertionDiagnostic("actual.ToArray().Should().OnlyContain(x => !x.BooleanProperty{0}).And.ToString();", ignore: true)]
191-
[AssertionDiagnostic("actual.ToList().Should().OnlyContain(x => !x.BooleanProperty{0}).And.ToString();", ignore: true)]
188+
[IgnoreAssertionDiagnostic("actual.Should().OnlyContain(x => !x.BooleanProperty{0});")]
189+
[IgnoreAssertionDiagnostic("actual.AsEnumerable().Should().OnlyContain(x => !x.BooleanProperty{0}).And.ToString();")]
190+
[IgnoreAssertionDiagnostic("actual.ToArray().Should().OnlyContain(x => !x.BooleanProperty{0}).And.ToString();")]
191+
[IgnoreAssertionDiagnostic("actual.ToList().Should().OnlyContain(x => !x.BooleanProperty{0}).And.ToString();")]
192192
[Implemented]
193193
public void CollectionShouldNotContainProperty_ShouldOnlyContainNot_TestAnalyzer(string assertion) => VerifyCSharpDiagnosticCodeBlock(assertion, DiagnosticMetadata.CollectionShouldNotContainProperty_ShouldOnlyContainNot);
194194

@@ -199,20 +199,18 @@ public class CollectionTests
199199
[AssertionCodeFix(
200200
oldAssertion: "actual.Where(x => x.BooleanProperty).Should().BeEmpty({0});",
201201
newAssertion: "actual.Should().NotContain(x => x.BooleanProperty{0});")]
202-
[AssertionCodeFix(
202+
[IgnoreAssertionCodeFix(
203203
oldAssertion: "actual.Should().OnlyContain(x => !x.BooleanProperty{0});",
204-
newAssertion: "actual.Should().NotContain(x => x.BooleanProperty{0});",
205-
ignore: true)]
204+
newAssertion: "actual.Should().NotContain(x => x.BooleanProperty{0});")]
206205
[AssertionCodeFix(
207206
oldAssertion: "actual.AsEnumerable().Any(x => x.BooleanProperty).Should().BeFalse({0}).And.ToString();",
208207
newAssertion: "actual.AsEnumerable().Should().NotContain(x => x.BooleanProperty{0}).And.ToString();")]
209208
[AssertionCodeFix(
210209
oldAssertion: "actual.AsEnumerable().Where(x => x.BooleanProperty).Should().BeEmpty({0}).And.ToString();",
211210
newAssertion: "actual.AsEnumerable().Should().NotContain(x => x.BooleanProperty{0}).And.ToString();")]
212-
[AssertionCodeFix(
211+
[IgnoreAssertionCodeFix(
213212
oldAssertion: "actual.AsEnumerable().Should().OnlyContain(x => !x.BooleanProperty{0}).And.ToString();",
214-
newAssertion: "actual.AsEnumerable().Should().NotContain(x => x.BooleanProperty{0}).And.ToString();",
215-
ignore: true)]
213+
newAssertion: "actual.AsEnumerable().Should().NotContain(x => x.BooleanProperty{0}).And.ToString();")]
216214
[Implemented]
217215
public void CollectionShouldNotContainProperty_TestCodeFix(string oldAssertion, string newAssertion) => VerifyCSharpFixCodeBlock(oldAssertion, newAssertion);
218216

0 commit comments

Comments
 (0)