-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDirectoryInfoAnalyzerTests.cs
More file actions
51 lines (45 loc) · 1.48 KB
/
DirectoryInfoAnalyzerTests.cs
File metadata and controls
51 lines (45 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System.Collections.Generic;
using System.IO.Abstractions.Analyzers.Analyzers.FileSystemTypeAnalyzers;
using Microsoft.CodeAnalysis;
using Roslyn.Testing.Analyzer;
using Roslyn.Testing.Model;
using Xunit;
namespace System.IO.Abstractions.Analyzers.Tests.Analyzers
{
public class DirectoryInfoAnalyzerTests: CSharpDiagnosticAnalyzerTest<DirectoryInfoAnalyzer>
{
[Theory]
[InlineData("Valid.txt")]
[InlineData("ModelObjectFalsePositive.txt")]
public void Analyzer_is_not_triggered(string filename)
{
var source = ReadFile(filename);
VerifyNoDiagnosticTriggered(source);
}
[Theory]
[InlineData("WithOutFileSystem.txt", 15, 28)]
[InlineData("StaticInvocation.txt", 15, 40)]
public void Analyzer_is_triggered(string filename, int diagnosticLine, int diagnosticColumn)
{
var source = ReadFile(filename);
var expectedDiagnostic = new DiagnosticResult
{
Id = DirectoryInfoAnalyzer.DiagnosticId,
Message = DirectoryInfoAnalyzer.MessageFormat,
Severity = DiagnosticSeverity.Warning,
Locations = new[] { new DiagnosticResultLocation("Test0.cs", diagnosticLine, diagnosticColumn) }
};
VerifyDiagnostic(source, expectedDiagnostic);
}
[Fact]
public void Empty_source_code_does_not_trigger_analyzer()
{
var source = string.Empty;
VerifyNoDiagnosticTriggered(source);
}
protected override IEnumerable<MetadataReference> GetAdditionalReferences() => new[]
{
MetadataReference.CreateFromFile(typeof(IFileSystem).Assembly.Location)
};
}
}