-
-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e882b7
commit 09a4f2a
Showing
2 changed files
with
54 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (c) Josef Pihrt and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Threading.Tasks; | ||
using Microsoft.CodeAnalysis; | ||
using Roslynator.CSharp.CodeFixes; | ||
using Roslynator.Testing.CSharp; | ||
using Xunit; | ||
|
||
namespace Roslynator.CSharp.Analysis.Tests | ||
{ | ||
public class RCS1208ReduceIfNestingTests : AbstractCSharpDiagnosticVerifier<ReduceIfNestingAnalyzer, IfStatementCodeFixProvider> | ||
{ | ||
public override DiagnosticDescriptor Descriptor { get; } = DiagnosticRules.ReduceIfNesting; | ||
|
||
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.ReduceIfNesting)] | ||
public async Task Test() | ||
{ | ||
await VerifyDiagnosticAndFixAsync(@" | ||
class C | ||
{ | ||
void M(bool p) | ||
{ | ||
[|if|] (p) | ||
{ | ||
M2(); | ||
} | ||
} | ||
void M2() | ||
{ | ||
} | ||
} | ||
", @" | ||
class C | ||
{ | ||
void M(bool p) | ||
{ | ||
if (!p) | ||
{ | ||
return; | ||
} | ||
M2(); | ||
} | ||
void M2() | ||
{ | ||
} | ||
} | ||
"); | ||
} | ||
} | ||
} |
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