Skip to content

Commit f6c5641

Browse files
committed
Added missing valid tests
1 parent 029ba95 commit f6c5641

1 file changed

Lines changed: 77 additions & 0 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1506UnitTests.cs

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,29 @@ public void TestMethod3() { }
617617
await this.VerifyCSharpFixAsync(testCode, fixedCode).ConfigureAwait(false);
618618
}
619619

620+
/// <summary>
621+
/// Verifies that enum member declarations with valid (or no) documentation will not produce diagnostics.
622+
/// </summary>
623+
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
624+
[Fact]
625+
public async Task TestValidEnumMemberDeclarationsAsync()
626+
{
627+
var testCode = @"namespace TestNamespace
628+
{
629+
public enum TestEnum
630+
{
631+
/// <summary>
632+
/// This is an enum member.
633+
/// </summary>
634+
Foo = 0,
635+
Bar = 1
636+
}
637+
}
638+
";
639+
640+
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
641+
}
642+
620643
/// <summary>
621644
/// Verifies that enum member declarations with invalid documentation will produce the expected diagnostics.
622645
/// </summary>
@@ -656,6 +679,33 @@ public enum TestEnum
656679
await this.VerifyCSharpFixAsync(testCode, fixedTestCode).ConfigureAwait(false);
657680
}
658681

682+
/// <summary>
683+
/// Verifies that operator declarations with valid (or no) documentation will not produce diagnostics.
684+
/// </summary>
685+
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
686+
[Fact]
687+
public async Task TestValidOperatorDeclarationsAsync()
688+
{
689+
var testCode = @"namespace TestNamespace
690+
{
691+
public struct Foo
692+
{
693+
/// <summary>
694+
/// This is an operator declaration.
695+
/// </summary>
696+
public static Foo operator +(Foo x, Foo y)
697+
{
698+
return new Foo();
699+
}
700+
701+
private int testField1;
702+
}
703+
}
704+
";
705+
706+
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
707+
}
708+
659709
/// <summary>
660710
/// Verifies that operator declarations with invalid documentation will produce the expected diagnostics.
661711
/// </summary>
@@ -701,6 +751,33 @@ public struct Foo
701751
await this.VerifyCSharpFixAsync(testCode, fixedTestCode).ConfigureAwait(false);
702752
}
703753

754+
/// <summary>
755+
/// Verifies that conversion operator declarations with valid (or no) documentation will not produce diagnostics.
756+
/// </summary>
757+
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
758+
[Fact]
759+
public async Task TestValidConversionOperatorDeclarationsAsync()
760+
{
761+
var testCode = @"namespace TestNamespace
762+
{
763+
public struct Foo
764+
{
765+
/// <summary>
766+
/// This is a conversion operator declaration.
767+
/// </summary>
768+
public static explicit operator Foo(string s)
769+
{
770+
return new Foo();
771+
}
772+
773+
private int testField1;
774+
}
775+
}
776+
";
777+
778+
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
779+
}
780+
704781
/// <summary>
705782
/// Verifies that conversion operator declarations with invalid documentation will produce the expected diagnostics.
706783
/// </summary>

0 commit comments

Comments
 (0)