public void SupportedDiagnostics_ReturnsSymbolicExecutionRuleDescriptors() { var sut = new SymbolicExecutionAnalyzerFactory(); var supportedDiagnostics = sut.SupportedDiagnostics.Select(descriptor => descriptor.Id).ToList(); CollectionAssert.AreEquivalent(supportedDiagnostics, new[] { EmptyNullableValueAccess, ObjectsShouldNotBeDisposedMoreThanOnce, PublicMethodArgumentsShouldBeCheckedForNull, EmptyCollectionsShouldNotBeEnumerated }); }
public void SupportedDiagnostics_ReturnsSymbolicExecutionRuleDescriptors() { var sut = new SymbolicExecutionAnalyzerFactory(); var supportedDiagnostics = sut.SupportedDiagnostics.Select(descriptor => descriptor.Id).ToList(); CollectionAssert.AreEquivalent(supportedDiagnostics, new[] { EmptyNullableValueAccess, ObjectsShouldNotBeDisposedMoreThanOnce, PublicMethodArgumentsShouldBeCheckedForNull, EmptyCollectionsShouldNotBeEnumerated, ConditionEvaluatesToConstantBug, ConditionEvaluatesToConstantCodeSmell, InvalidCastToInterface, NullPointerDereference }); }
public void GetEnabledAnalyzers_ReturnsEmptyList_WhenDiagnosticsAreDisabled() { var sut = new SymbolicExecutionAnalyzerFactory(); var diagnostics = new Dictionary <string, ReportDiagnostic> { { EmptyNullableValueAccess, ReportDiagnostic.Suppress }, { ObjectsShouldNotBeDisposedMoreThanOnce, ReportDiagnostic.Suppress }, { EmptyCollectionsShouldNotBeEnumerated, ReportDiagnostic.Suppress } }.ToImmutableDictionary(); var context = CreateSyntaxNodeAnalysisContext(diagnostics); var analyzers = sut.GetEnabledAnalyzers(context).ToList(); var enabledAnalyzers = analyzers .SelectMany(analyzer => analyzer.SupportedDiagnostics.Select(descriptor => descriptor.Id)) .ToList(); CollectionAssert.AreEquivalent(new List <string>(), enabledAnalyzers); }
public void GetEnabledAnalyzers_ReturnsDiagnostic_WhenEnabled(ReportDiagnostic reportDiagnostic) { var sut = new SymbolicExecutionAnalyzerFactory(); var diagnostics = new Dictionary <string, ReportDiagnostic> { { EmptyNullableValueAccess, reportDiagnostic }, { ObjectsShouldNotBeDisposedMoreThanOnce, ReportDiagnostic.Suppress }, { EmptyCollectionsShouldNotBeEnumerated, ReportDiagnostic.Suppress }, { ConditionEvaluatesToConstantBug, ReportDiagnostic.Suppress }, { ConditionEvaluatesToConstantCodeSmell, ReportDiagnostic.Suppress }, { InvalidCastToInterface, ReportDiagnostic.Suppress }, { NullPointerDereference, ReportDiagnostic.Suppress } }.ToImmutableDictionary(); var context = CreateSyntaxNodeAnalysisContext(diagnostics); var analyzers = sut.GetEnabledAnalyzers(context).ToList(); var enabledAnalyzers = analyzers .SelectMany(analyzer => analyzer.SupportedDiagnostics.Select(descriptor => descriptor.Id)) .ToList(); CollectionAssert.AreEquivalent(enabledAnalyzers, new[] { EmptyNullableValueAccess }); }