mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-12-22 01:35:47 +08:00
Add global usings (#668)
* Use global usings * Fix namespace declarations for test projects
This commit is contained in:
@@ -1,20 +1,15 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.Testing;
|
||||
using Xunit;
|
||||
namespace Spectre.Console.Analyzer.Tests.Unit.Fixes;
|
||||
|
||||
namespace Spectre.Console.Analyzer.Tests.Unit.Fixes
|
||||
public class UseSpectreInsteadOfSystemConsoleFixTests
|
||||
{
|
||||
public class UseSpectreInsteadOfSystemConsoleFixTests
|
||||
{
|
||||
private static readonly DiagnosticResult _expectedDiagnostic = new(
|
||||
Descriptors.S1000_UseAnsiConsoleOverSystemConsole.Id,
|
||||
DiagnosticSeverity.Warning);
|
||||
private static readonly DiagnosticResult _expectedDiagnostic = new(
|
||||
Descriptors.S1000_UseAnsiConsoleOverSystemConsole.Id,
|
||||
DiagnosticSeverity.Warning);
|
||||
|
||||
[Fact]
|
||||
public async Task SystemConsole_replaced_with_AnsiConsole()
|
||||
{
|
||||
const string Source = @"
|
||||
[Fact]
|
||||
public async Task SystemConsole_replaced_with_AnsiConsole()
|
||||
{
|
||||
const string Source = @"
|
||||
using System;
|
||||
|
||||
class TestClass
|
||||
@@ -25,7 +20,7 @@ class TestClass
|
||||
}
|
||||
}";
|
||||
|
||||
const string FixedSource = @"
|
||||
const string FixedSource = @"
|
||||
using System;
|
||||
using Spectre.Console;
|
||||
|
||||
@@ -37,15 +32,15 @@ class TestClass
|
||||
}
|
||||
}";
|
||||
|
||||
await SpectreAnalyzerVerifier<UseSpectreInsteadOfSystemConsoleAnalyzer>
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(8, 9), FixedSource)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
await SpectreAnalyzerVerifier<UseSpectreInsteadOfSystemConsoleAnalyzer>
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(8, 9), FixedSource)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SystemConsole_replaced_with_imported_AnsiConsole()
|
||||
{
|
||||
const string Source = @"
|
||||
[Fact]
|
||||
public async Task SystemConsole_replaced_with_imported_AnsiConsole()
|
||||
{
|
||||
const string Source = @"
|
||||
using System;
|
||||
|
||||
class TestClass
|
||||
@@ -56,7 +51,7 @@ class TestClass
|
||||
}
|
||||
}";
|
||||
|
||||
const string FixedSource = @"
|
||||
const string FixedSource = @"
|
||||
using System;
|
||||
using Spectre.Console;
|
||||
|
||||
@@ -68,15 +63,15 @@ class TestClass
|
||||
}
|
||||
}";
|
||||
|
||||
await SpectreAnalyzerVerifier<UseSpectreInsteadOfSystemConsoleAnalyzer>
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(8, 9), FixedSource)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
await SpectreAnalyzerVerifier<UseSpectreInsteadOfSystemConsoleAnalyzer>
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(8, 9), FixedSource)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SystemConsole_replaced_with_field_AnsiConsole()
|
||||
{
|
||||
const string Source = @"
|
||||
[Fact]
|
||||
public async Task SystemConsole_replaced_with_field_AnsiConsole()
|
||||
{
|
||||
const string Source = @"
|
||||
using System;
|
||||
using Spectre.Console;
|
||||
|
||||
@@ -90,7 +85,7 @@ class TestClass
|
||||
}
|
||||
}";
|
||||
|
||||
const string FixedSource = @"
|
||||
const string FixedSource = @"
|
||||
using System;
|
||||
using Spectre.Console;
|
||||
|
||||
@@ -104,15 +99,15 @@ class TestClass
|
||||
}
|
||||
}";
|
||||
|
||||
await SpectreAnalyzerVerifier<UseSpectreInsteadOfSystemConsoleAnalyzer>
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(11, 9), FixedSource)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
await SpectreAnalyzerVerifier<UseSpectreInsteadOfSystemConsoleAnalyzer>
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(11, 9), FixedSource)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SystemConsole_replaced_with_static_field_AnsiConsole()
|
||||
{
|
||||
const string Source = @"
|
||||
[Fact]
|
||||
public async Task SystemConsole_replaced_with_static_field_AnsiConsole()
|
||||
{
|
||||
const string Source = @"
|
||||
using System;
|
||||
using Spectre.Console;
|
||||
|
||||
@@ -126,7 +121,7 @@ class TestClass
|
||||
}
|
||||
}";
|
||||
|
||||
const string FixedSource = @"
|
||||
const string FixedSource = @"
|
||||
using System;
|
||||
using Spectre.Console;
|
||||
|
||||
@@ -140,9 +135,8 @@ class TestClass
|
||||
}
|
||||
}";
|
||||
|
||||
await SpectreAnalyzerVerifier<UseSpectreInsteadOfSystemConsoleAnalyzer>
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(11, 9), FixedSource)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
await SpectreAnalyzerVerifier<UseSpectreInsteadOfSystemConsoleAnalyzer>
|
||||
.VerifyCodeFixAsync(Source, _expectedDiagnostic.WithLocation(11, 9), FixedSource)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user