This commit is contained in:
Tyrrrz
2021-12-08 23:43:35 +02:00
parent 9990387cfa
commit 2feeb21270
132 changed files with 8021 additions and 8154 deletions

View File

@@ -2,18 +2,18 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Xunit;
namespace CliFx.Analyzers.Tests
{
public class OptionMustHaveUniqueNameAnalyzerSpecs
{
private static DiagnosticAnalyzer Analyzer { get; } = new OptionMustHaveUniqueNameAnalyzer();
namespace CliFx.Analyzers.Tests;
[Fact]
public void Analyzer_reports_an_error_if_an_option_has_the_same_name_as_another_option()
{
// Arrange
// language=cs
const string code = @"
public class OptionMustHaveUniqueNameAnalyzerSpecs
{
private static DiagnosticAnalyzer Analyzer { get; } = new OptionMustHaveUniqueNameAnalyzer();
[Fact]
public void Analyzer_reports_an_error_if_an_option_has_the_same_name_as_another_option()
{
// Arrange
// language=cs
const string code = @"
[Command]
public class MyCommand : ICommand
{
@@ -26,16 +26,16 @@ public class MyCommand : ICommand
public ValueTask ExecuteAsync(IConsole console) => default;
}";
// Act & assert
Analyzer.Should().ProduceDiagnostics(code);
}
// Act & assert
Analyzer.Should().ProduceDiagnostics(code);
}
[Fact]
public void Analyzer_does_not_report_an_error_if_an_option_has_a_unique_name()
{
// Arrange
// language=cs
const string code = @"
[Fact]
public void Analyzer_does_not_report_an_error_if_an_option_has_a_unique_name()
{
// Arrange
// language=cs
const string code = @"
[Command]
public class MyCommand : ICommand
{
@@ -48,16 +48,16 @@ public class MyCommand : ICommand
public ValueTask ExecuteAsync(IConsole console) => default;
}";
// Act & assert
Analyzer.Should().NotProduceDiagnostics(code);
}
// Act & assert
Analyzer.Should().NotProduceDiagnostics(code);
}
[Fact]
public void Analyzer_does_not_report_an_error_if_an_option_does_not_have_a_name()
{
// Arrange
// language=cs
const string code = @"
[Fact]
public void Analyzer_does_not_report_an_error_if_an_option_does_not_have_a_name()
{
// Arrange
// language=cs
const string code = @"
[Command]
public class MyCommand : ICommand
{
@@ -67,16 +67,16 @@ public class MyCommand : ICommand
public ValueTask ExecuteAsync(IConsole console) => default;
}";
// Act & assert
Analyzer.Should().NotProduceDiagnostics(code);
}
// Act & assert
Analyzer.Should().NotProduceDiagnostics(code);
}
[Fact]
public void Analyzer_does_not_report_an_error_on_a_property_that_is_not_an_option()
{
// Arrange
// language=cs
const string code = @"
[Fact]
public void Analyzer_does_not_report_an_error_on_a_property_that_is_not_an_option()
{
// Arrange
// language=cs
const string code = @"
[Command]
public class MyCommand : ICommand
{
@@ -85,8 +85,7 @@ public class MyCommand : ICommand
public ValueTask ExecuteAsync(IConsole console) => default;
}";
// Act & assert
Analyzer.Should().NotProduceDiagnostics(code);
}
// Act & assert
Analyzer.Should().NotProduceDiagnostics(code);
}
}