-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #409 from Vannevelj/develop
release v1.9.3
- Loading branch information
Showing
139 changed files
with
26,962 additions
and
3,074 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
141 changes: 141 additions & 0 deletions
141
VSDiagnostics/VSDiagnostics/VSDiagnostics.Test/Tests/Async/SyncMethodWithAsyncSuffixTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
using Microsoft.CodeAnalysis.CodeFixes; | ||
using Microsoft.CodeAnalysis.Diagnostics; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using RoslynTester.Helpers.CSharp; | ||
using VSDiagnostics.Diagnostics.Async.SyncMethodWithSyncSuffix; | ||
|
||
namespace VSDiagnostics.Test.Tests.Async | ||
{ | ||
[TestClass] | ||
public class SyncMethodWithAsyncSuffixTests : CSharpCodeFixVerifier | ||
{ | ||
protected override CodeFixProvider CodeFixProvider => new SyncMethodWithAsyncSuffixCodeFix(); | ||
|
||
protected override DiagnosticAnalyzer DiagnosticAnalyzer => new SyncMethodWithAsyncSuffixAnalyzer(); | ||
|
||
[TestMethod] | ||
public void SyncMethodWithAsyncSuffix_WithSynchronousMethodAndNoSuffix() | ||
{ | ||
var original = @" | ||
using System; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
namespace ConsoleApplication1 | ||
{ | ||
class MyClass | ||
{ | ||
void Method() | ||
{ | ||
} | ||
} | ||
}"; | ||
|
||
VerifyDiagnostic(original); | ||
} | ||
|
||
[TestMethod] | ||
public void SyncMethodWithAsyncSuffix_WithSynchronousMethodAndSuffix() | ||
{ | ||
var original = @" | ||
using System; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
namespace ConsoleApplication1 | ||
{ | ||
class MyClass | ||
{ | ||
void MethodAsync() | ||
{ | ||
} | ||
} | ||
}"; | ||
|
||
var result = @" | ||
using System; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
namespace ConsoleApplication1 | ||
{ | ||
class MyClass | ||
{ | ||
void Method() | ||
{ | ||
} | ||
} | ||
}"; | ||
|
||
VerifyDiagnostic(original, string.Format(SyncMethodWithAsyncSuffixAnalyzer.Rule.MessageFormat.ToString(), "MethodAsync")); | ||
VerifyFix(original, result); | ||
} | ||
|
||
[TestMethod] | ||
public void SyncMethodWithAsyncSuffix_WithAsyncMethodAndSuffix() | ||
{ | ||
var original = @" | ||
using System; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
namespace ConsoleApplication1 | ||
{ | ||
class MyClass | ||
{ | ||
async Task MethodAsync() | ||
{ | ||
} | ||
} | ||
}"; | ||
VerifyDiagnostic(original); | ||
} | ||
|
||
[TestMethod] | ||
public void SyncMethodWithAsyncSuffix_WithInheritance() | ||
{ | ||
var original = @" | ||
using System; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
namespace ConsoleApplication1 | ||
{ | ||
interface IMyInterface | ||
{ | ||
void MyMethodAsync(); | ||
} | ||
class MyClass : IMyInterface | ||
{ | ||
public void MyMethodAsync() | ||
{ | ||
} | ||
} | ||
}"; | ||
|
||
var result = @" | ||
using System; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
namespace ConsoleApplication1 | ||
{ | ||
interface IMyInterface | ||
{ | ||
void MyMethod(); | ||
} | ||
class MyClass : IMyInterface | ||
{ | ||
public void MyMethod() | ||
{ | ||
} | ||
} | ||
}"; | ||
|
||
VerifyDiagnostic(original, string.Format(SyncMethodWithAsyncSuffixAnalyzer.Rule.MessageFormat.ToString(), "MyMethodAsync")); | ||
VerifyFix(original, result); | ||
} | ||
} | ||
} |
Oops, something went wrong.