Skip to content

Commit c14257a

Browse files
authored
tests: reproduce issue #276 (#277)
1 parent b19982c commit c14257a

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

src/FluentAssertions.Analyzers.Tests/Tips/SanityTests.cs

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ public class TestType3
372372

373373
[TestMethod]
374374
[Implemented(Reason = "https://github.com/fluentassertions/fluentassertions.analyzers/issues/215")]
375-
public void ShouldNotFailToAnalyze()
375+
public void ShouldNotFailToAnalyze1()
376376
{
377377
const string source = @"
378378
#nullable enable
@@ -408,5 +408,61 @@ public class OtherComponent
408408
.WithPackageReferences(PackageReference.FluentAssertions_6_12_0)
409409
);
410410
}
411+
412+
[TestMethod]
413+
[NotImplemented(Reason = "https://github.com/fluentassertions/fluentassertions.analyzers/issues/276")]
414+
public void ShouldNotFailToAnalyze2()
415+
{
416+
const string source = @"
417+
#nullable enable
418+
using FluentAssertions;
419+
using FluentAssertions.Extensions;
420+
using System.Linq;
421+
using System.Collections.Generic;
422+
423+
public class TestClass
424+
{
425+
public static void Main()
426+
{
427+
var response = new MyResponse();
428+
response.MyCollection?.Count().Should().Be(2);
429+
}
430+
}
431+
432+
public class MyResponse
433+
{
434+
public IEnumerable<MyCollectionType>? MyCollection { get; set; }
435+
}
436+
public class MyCollectionType { }";
437+
const string fixedSource = @"
438+
#nullable enable
439+
using FluentAssertions;
440+
using FluentAssertions.Extensions;
441+
using System.Linq;
442+
using System.Collections.Generic;
443+
444+
public class TestClass
445+
{
446+
public static void Main()
447+
{
448+
var response = new MyResponse();
449+
response.MyCollection?.Should().HaveCount(2);
450+
}
451+
}
452+
453+
public class MyResponse
454+
{
455+
public IEnumerable<MyCollectionType>? MyCollection { get; set; }
456+
}
457+
public class MyCollectionType { }";
458+
459+
DiagnosticVerifier.VerifyFix(new CodeFixVerifierArguments()
460+
.WithSources(source)
461+
.WithFixedSources(fixedSource)
462+
.WithDiagnosticAnalyzer<FluentAssertionsOperationAnalyzer>()
463+
.WithCodeFixProvider<FluentAssertionsCodeFix>()
464+
.WithPackageReferences(PackageReference.FluentAssertions_6_12_0)
465+
);
466+
}
411467
}
412468
}

0 commit comments

Comments
 (0)