@@ -372,7 +372,7 @@ public class TestType3
372
372
373
373
[ TestMethod ]
374
374
[ Implemented ( Reason = "https://github.com/fluentassertions/fluentassertions.analyzers/issues/215" ) ]
375
- public void ShouldNotFailToAnalyze ( )
375
+ public void ShouldNotFailToAnalyze1 ( )
376
376
{
377
377
const string source = @"
378
378
#nullable enable
@@ -408,5 +408,61 @@ public class OtherComponent
408
408
. WithPackageReferences ( PackageReference . FluentAssertions_6_12_0 )
409
409
) ;
410
410
}
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
+ }
411
467
}
412
468
}
0 commit comments