Skip to content

Commit 987420a

Browse files
committed
Add tests for #3173
1 parent 2d87f14 commit 987420a

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1611UnitTests.cs

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,55 @@ public void TestMethod(string param1, string param2, string param3)
313313
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
314314
}
315315

316+
/// <summary>
317+
/// Verifies that included documentation with missing elements documented produces the expected diagnostics.
318+
/// </summary>
319+
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
320+
[Fact]
321+
public async Task VerifyIncludedPartialDocumentationMissingElementsAsync()
322+
{
323+
var testCode = @"
324+
/// <summary>
325+
/// Foo
326+
/// </summary>
327+
public class ClassName
328+
{
329+
/// <include file='WithPartialElementDocumentation.xml' path='/TestClass/TestMethod/*' />
330+
public void TestMethod(string param1, string param2, string param3)
331+
{
332+
}
333+
}";
334+
DiagnosticResult[] expected =
335+
{
336+
Diagnostic().WithLocation(8, 35).WithArguments("param1"),
337+
};
338+
339+
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
340+
}
341+
342+
/// <summary>
343+
/// Verifies that included documentation with missing elements documented produces the expected diagnostics.
344+
/// </summary>
345+
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
346+
[Fact]
347+
public async Task VerifyIncludedPartialDocumentationElementsAsync()
348+
{
349+
var testCode = @"
350+
/// <summary>
351+
/// Foo
352+
/// </summary>
353+
public class ClassName
354+
{
355+
/// <param name=""param1"">Param 1</param>
356+
/// <include file='WithPartialElementDocumentation.xml' path='/TestClass/TestMethod/*' />
357+
public void TestMethod(string param1, string param2, string param3)
358+
{
359+
}
360+
}";
361+
362+
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
363+
}
364+
316365
/// <summary>
317366
/// Verifies that included documentation with an <c>&lt;inheritdoc&gt;</c> tag is ignored.
318367
/// </summary>
@@ -356,6 +405,17 @@ private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[
356405
<param name=""param3"">Param 3</param>
357406
</TestMethod>
358407
</TestClass>
408+
";
409+
string contentWithPartialElementDocumentation = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
410+
<TestClass>
411+
<TestMethod>
412+
<summary>
413+
Foo
414+
</summary>
415+
<param name=""param2"">Param 2</param>
416+
<param name=""param3"">Param 3</param>
417+
</TestMethod>
418+
</TestClass>
359419
";
360420
string contentWithInheritedDocumentation = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
361421
<TestClass>
@@ -372,6 +432,7 @@ private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[
372432
{
373433
{ "MissingElementDocumentation.xml", contentWithoutElementDocumentation },
374434
{ "WithElementDocumentation.xml", contentWithElementDocumentation },
435+
{ "WithPartialElementDocumentation.xml", contentWithPartialElementDocumentation },
375436
{ "InheritedDocumentation.xml", contentWithInheritedDocumentation },
376437
},
377438
};

0 commit comments

Comments
 (0)