Skip to content

Commit 476f0d3

Browse files
authored
fixed #77 (#79)
1 parent 686a33b commit 476f0d3

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

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

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ public static void Main()
119119
System.Console.WriteLine();
120120
}
121121
}";
122-
122+
123123
DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source);
124-
}
124+
}
125125

126126
[TestMethod]
127127
[Implemented(Reason = "https://github.com/fluentassertions/fluentassertions.analyzers/issues/63")]
@@ -147,7 +147,7 @@ public static void Main()
147147
}
148148
}
149149
}";
150-
150+
151151
DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source);
152152
}
153153

@@ -193,7 +193,7 @@ public static void Main()
193193
[TestMethod]
194194
[Implemented(Reason = "https://github.com/fluentassertions/fluentassertions.analyzers/issues/64")]
195195
public void CollectionShouldNotContainProperty_WhenAssertionIsIdiomatic_ShouldNotTrigger()
196-
{
196+
{
197197
const string source = @"
198198
using FluentAssertions;
199199
using FluentAssertions.Extensions;
@@ -205,7 +205,7 @@ public static void Main()
205205
var list = new[] { string.Empty };
206206
list.Should().OnlyContain(e => e.Contains(string.Empty));
207207
}
208-
}";
208+
}";
209209

210210
DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source);
211211
}
@@ -233,5 +233,30 @@ public static void Main()
233233

234234
DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source);
235235
}
236+
237+
[TestMethod]
238+
[Implemented(Reason = "https://github.com/fluentassertions/fluentassertions.analyzers/issues/77")]
239+
public void DictionaryShouldHaveCount1_ShouldNotReport()
240+
{
241+
const string source = @"
242+
using System.Linq;
243+
using System.Collections.Generic;
244+
using FluentAssertions;
245+
using FluentAssertions.Extensions;
246+
247+
namespace TestNamespace
248+
{
249+
public class Program
250+
{
251+
public static void Main()
252+
{
253+
var dict = new Dictionary<string, object>();
254+
dict.Should().HaveCount(1);
255+
}
256+
}
257+
}";
258+
259+
DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source);
260+
}
236261
}
237262
}

src/FluentAssertions.Analyzers/Tips/Collections/CollectionAnalyzer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ public abstract class CollectionAnalyzer : FluentAssertionsAnalyzer
88
protected override bool ShouldAnalyzeVariableType(ITypeSymbol type)
99
{
1010
return type.Name != "String"
11-
&& type.AllInterfaces.Any(@interface => @interface.Name == "IEnumerable");
11+
&& type.AllInterfaces.Any(@interface => @interface.Name == "IEnumerable")
12+
&& !type.AllInterfaces.Any(@interface => @interface.Name == "IDictionary");
1213
}
1314
}
1415
}

0 commit comments

Comments
 (0)