-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathAsyncVoidTests.cs
65 lines (58 loc) · 2.69 KB
/
AsyncVoidTests.cs
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using FluentAssertions.Analyzers.TestUtils;
using Microsoft.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace FluentAssertions.Analyzers.Tests
{
[TestClass]
public class AsyncVoidTests
{
[TestMethod]
[Implemented]
public void AssignAsyncVoidMethodToAction_TestAnalyzer()
{
const string statement = "Action action = AsyncVoidMethod;";
var source = GenerateCode.AsyncFunctionStatement(statement);
DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source);
}
[TestMethod]
[Implemented]
public void AssignVoidLambdaToAction_TestAnalyzer()
{
const string statement = "Action action = () => {};";
var source = GenerateCode.AsyncFunctionStatement(statement);
DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source);
}
[DataRow("Action action = async () => { await Task.CompletedTask; };")]
[DataRow("Action action1 = async () => { await Task.CompletedTask; }, action2 = async () => { await Task.CompletedTask; };")]
[DataRow("Action action1 = () => { }, action2 = async () => { await Task.CompletedTask; };")]
[DataRow("Action action1 = async () => { await Task.CompletedTask; }, action2 = () => { };")]
[DataTestMethod]
[Implemented]
public void AssignAsyncVoidLambdaToAction_TestAnalyzer(string assertion)
{
var source = GenerateCode.AsyncFunctionStatement(assertion);
DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source, new LegacyDiagnosticResult
{
Id = AsyncVoidAnalyzer.DiagnosticId,
Message = AsyncVoidAnalyzer.Message,
Locations = new DiagnosticResultLocation[]
{
new DiagnosticResultLocation("Test0.cs", 10,13)
},
Severity = DiagnosticSeverity.Warning
});
}
[AssertionCodeFix(
oldAssertion: "Action action = async () => { await Task.CompletedTask; };",
newAssertion: "Func<Task> action = async () => { await Task.CompletedTask; };")]
[AssertionCodeFix(
oldAssertion: "Action action1 = async () => { await Task.CompletedTask; }, action2 = async () => { await Task.CompletedTask; };",
newAssertion: "Func<Task> action1 = async () => { await Task.CompletedTask; }, action2 = async () => { await Task.CompletedTask; };")]
[DataTestMethod]
[NotImplemented]
public void AssignAsyncVoidLambdaToAction_TestCodeFix(string oldAssertion, string newAssertion)
{
// no-op
}
}
}