|
| 1 | +using System.Text; |
1 | 2 | using FluentAssertions.Analyzers.TestUtils;
|
2 | 3 | using Microsoft.CodeAnalysis;
|
3 | 4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
|
@@ -320,6 +321,29 @@ public class CollectionTests
|
320 | 321 | [Implemented]
|
321 | 322 | public void CollectionShouldHaveCount_LengthShouldBe_TestAnalyzer(string assertion) => VerifyCSharpDiagnosticCodeBlock(assertion, DiagnosticMetadata.CollectionShouldHaveCount_LengthShouldBe);
|
322 | 323 |
|
| 324 | + [DataTestMethod] |
| 325 | + [AssertionDiagnostic(@"var array = new string[0, 0]; array.Length.Should().Be(0{0});")] |
| 326 | + [AssertionDiagnostic(@"var array = new string[0, 0, 0]; array.Length.Should().Be(0{0});")] |
| 327 | + [AssertionDiagnostic(@"var array = new string[0, 0, 0, 0]; array.Length.Should().Be(0{0});")] |
| 328 | + [AssertionDiagnostic(@"var array = new string[1, 1]; array.Length.Should().Be(0{0});")] |
| 329 | + [AssertionDiagnostic(@"var array = new string[2, 2]; array.Length.Should().Be(0{0});")] |
| 330 | + [AssertionDiagnostic(@"var array = new string[3, 3, 3]; array.Length.Should().Be(0{0});")] |
| 331 | + public void CollectionShouldHaveCount_LengthShouldBe_TestNoAnalyzer(string assertion) => DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(new StringBuilder() |
| 332 | + .AppendLine("using System;") |
| 333 | + .AppendLine("using FluentAssertions;") |
| 334 | + .AppendLine("using FluentAssertions.Extensions;") |
| 335 | + .AppendLine("namespace TestNamespace") |
| 336 | + .AppendLine("{") |
| 337 | + .AppendLine(" public class TestClass") |
| 338 | + .AppendLine(" {") |
| 339 | + .AppendLine(" public void TestMethod()") |
| 340 | + .AppendLine(" {") |
| 341 | + .AppendLine(assertion) |
| 342 | + .AppendLine(" }") |
| 343 | + .AppendLine(" }") |
| 344 | + .AppendLine("}") |
| 345 | + .ToString()); |
| 346 | + |
323 | 347 | [DataTestMethod]
|
324 | 348 | [AssertionDiagnostic("actual.Should().HaveCount(expected.Count() + 1{0});")]
|
325 | 349 | [AssertionDiagnostic("actual.Should().HaveCount(expected.Count() + unexpected.Count(){0});")]
|
|
0 commit comments