Skip to content

Commit

Permalink
fixed #77 (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
Meir017 authored Aug 17, 2018
1 parent 686a33b commit 476f0d3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
35 changes: 30 additions & 5 deletions src/FluentAssertions.Analyzers.Tests/Tips/SanityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ public static void Main()
System.Console.WriteLine();
}
}";

DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source);
}
}

[TestMethod]
[Implemented(Reason = "https://github.com/fluentassertions/fluentassertions.analyzers/issues/63")]
Expand All @@ -147,7 +147,7 @@ public static void Main()
}
}
}";

DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source);
}

Expand Down Expand Up @@ -193,7 +193,7 @@ public static void Main()
[TestMethod]
[Implemented(Reason = "https://github.com/fluentassertions/fluentassertions.analyzers/issues/64")]
public void CollectionShouldNotContainProperty_WhenAssertionIsIdiomatic_ShouldNotTrigger()
{
{
const string source = @"
using FluentAssertions;
using FluentAssertions.Extensions;
Expand All @@ -205,7 +205,7 @@ public static void Main()
var list = new[] { string.Empty };
list.Should().OnlyContain(e => e.Contains(string.Empty));
}
}";
}";

DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source);
}
Expand Down Expand Up @@ -233,5 +233,30 @@ public static void Main()

DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source);
}

[TestMethod]
[Implemented(Reason = "https://github.com/fluentassertions/fluentassertions.analyzers/issues/77")]
public void DictionaryShouldHaveCount1_ShouldNotReport()
{
const string source = @"
using System.Linq;
using System.Collections.Generic;
using FluentAssertions;
using FluentAssertions.Extensions;
namespace TestNamespace
{
public class Program
{
public static void Main()
{
var dict = new Dictionary<string, object>();
dict.Should().HaveCount(1);
}
}
}";

DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ public abstract class CollectionAnalyzer : FluentAssertionsAnalyzer
protected override bool ShouldAnalyzeVariableType(ITypeSymbol type)
{
return type.Name != "String"
&& type.AllInterfaces.Any(@interface => @interface.Name == "IEnumerable");
&& type.AllInterfaces.Any(@interface => @interface.Name == "IEnumerable")
&& !type.AllInterfaces.Any(@interface => @interface.Name == "IDictionary");
}
}
}

0 comments on commit 476f0d3

Please sign in to comment.