-
-
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
7a9c1ca
commit 5557ad2
Showing
5 changed files
with
263 additions
and
48 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
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
117 changes: 117 additions & 0 deletions
117
src/Tests/CodeFixes.Tests/CS0246TypeOrNamespaceNameCouldNotBeFoundTests.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,117 @@ | ||
// Copyright (c) Josef Pihrt. All rights reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Threading.Tasks; | ||
using Roslynator.Testing.CSharp; | ||
using Xunit; | ||
|
||
namespace Roslynator.CSharp.CodeFixes.Tests | ||
{ | ||
public class CS0246TypeOrNamespaceNameCouldNotBeFoundTests : AbstractCSharpCompilerDiagnosticFixVerifier<SimpleNameCodeFixProvider> | ||
{ | ||
public override string DiagnosticId { get; } = CompilerDiagnosticIdentifiers.TypeOrNamespaceNameCouldNotBeFound; | ||
|
||
[Fact, Trait(Traits.CodeFix, CompilerDiagnosticIdentifiers.TypeOrNamespaceNameCouldNotBeFound)] | ||
public async Task Test_ChangeType_Field() | ||
{ | ||
await VerifyFixAsync(@" | ||
class C | ||
{ | ||
private x F = default(C); | ||
} | ||
", @" | ||
class C | ||
{ | ||
private C F = default(C); | ||
} | ||
", equivalenceKey: EquivalenceKey.Create(DiagnosticId, CodeFixIdentifiers.ChangeMemberTypeAccordingToReturnExpression)); | ||
} | ||
|
||
[Fact, Trait(Traits.CodeFix, CompilerDiagnosticIdentifiers.TypeOrNamespaceNameCouldNotBeFound)] | ||
public async Task Test_ChangeType_Method() | ||
{ | ||
await VerifyFixAsync(@" | ||
class C | ||
{ | ||
x M() | ||
{ | ||
return default(C); | ||
} | ||
} | ||
", @" | ||
class C | ||
{ | ||
C M() | ||
{ | ||
return default(C); | ||
} | ||
} | ||
", equivalenceKey: EquivalenceKey.Create(DiagnosticId, CodeFixIdentifiers.ChangeMemberTypeAccordingToReturnExpression)); | ||
} | ||
|
||
[Fact, Trait(Traits.CodeFix, CompilerDiagnosticIdentifiers.TypeOrNamespaceNameCouldNotBeFound)] | ||
public async Task Test_ChangeType_Method_ExpressionBody() | ||
{ | ||
await VerifyFixAsync(@" | ||
class C | ||
{ | ||
x M() => default(C); | ||
} | ||
", @" | ||
class C | ||
{ | ||
C M() => default(C); | ||
} | ||
", equivalenceKey: EquivalenceKey.Create(DiagnosticId, CodeFixIdentifiers.ChangeMemberTypeAccordingToReturnExpression)); | ||
} | ||
|
||
[Fact, Trait(Traits.CodeFix, CompilerDiagnosticIdentifiers.TypeOrNamespaceNameCouldNotBeFound)] | ||
public async Task Test_ChangeType_LocalFunction() | ||
{ | ||
await VerifyFixAsync(@" | ||
class C | ||
{ | ||
void M() | ||
{ | ||
x LocalFunction() | ||
{ | ||
return default(C); | ||
} | ||
} | ||
} | ||
", @" | ||
class C | ||
{ | ||
void M() | ||
{ | ||
C LocalFunction() | ||
{ | ||
return default(C); | ||
} | ||
} | ||
} | ||
", equivalenceKey: EquivalenceKey.Create(DiagnosticId, CodeFixIdentifiers.ChangeMemberTypeAccordingToReturnExpression)); | ||
} | ||
|
||
[Fact, Trait(Traits.CodeFix, CompilerDiagnosticIdentifiers.TypeOrNamespaceNameCouldNotBeFound)] | ||
public async Task Test_ChangeType_LocalFunction_ExpressionBody() | ||
{ | ||
await VerifyFixAsync(@" | ||
class C | ||
{ | ||
void M() | ||
{ | ||
x LocalFunction() => default(C); | ||
} | ||
} | ||
", @" | ||
class C | ||
{ | ||
void M() | ||
{ | ||
C LocalFunction() => default(C); | ||
} | ||
} | ||
", equivalenceKey: EquivalenceKey.Create(DiagnosticId, CodeFixIdentifiers.ChangeMemberTypeAccordingToReturnExpression)); | ||
} | ||
} | ||
} |