@@ -429,7 +429,7 @@ public void Nunit4_AssertEqualDouble_TestCodeFix(string oldAssertion, string new
429
429
[ Implemented ]
430
430
public void Nunit3_AssertEqualObject_TestAnalyzer ( string assertion )
431
431
=> Nunit3VerifyDiagnostic ( "object expected, object actual" , assertion ) ;
432
-
432
+
433
433
[ DataTestMethod ]
434
434
[ AssertionDiagnostic ( "ClassicAssert.AreEqual(expected, actual{0});" ) ]
435
435
[ Implemented ]
@@ -479,7 +479,7 @@ public void Nunit3_AssertNotEqualObject_TestCodeFix(string oldAssertion, string
479
479
[ Implemented ]
480
480
public void Nunit4_AssertNotEqualObject_TestCodeFix ( string oldAssertion , string newAssertion )
481
481
=> Nunit4VerifyFix ( "object expected, object actual" , oldAssertion , newAssertion ) ;
482
-
482
+
483
483
[ DataTestMethod ]
484
484
[ AssertionDiagnostic ( "Assert.AreSame(expected, actual{0});" ) ]
485
485
[ Implemented ]
@@ -510,6 +510,163 @@ public void Nunit4_AssertSame_TestCodeFix(string oldAssertion, string newAsserti
510
510
511
511
#endregion
512
512
513
+ #region Assert.Types.cs
514
+
515
+ [ DataTestMethod ]
516
+ [ AssertionDiagnostic ( "Assert.IsAssignableFrom(typeof(string), actual{0});" ) ]
517
+ [ AssertionDiagnostic ( "Assert.IsAssignableFrom(expected, actual{0});" ) ]
518
+ [ AssertionDiagnostic ( "Assert.IsAssignableFrom<string>(actual{0});" ) ]
519
+ [ Implemented ]
520
+ public void Nunit3_AssertIsAssignableFrom_TestAnalyzer ( string assertion )
521
+ => Nunit3VerifyDiagnostic ( "object actual, Type expected" , assertion ) ;
522
+
523
+ [ DataTestMethod ]
524
+ [ AssertionDiagnostic ( "ClassicAssert.IsAssignableFrom(typeof(string), actual{0});" ) ]
525
+ [ AssertionDiagnostic ( "ClassicAssert.IsAssignableFrom(expected, actual{0});" ) ]
526
+ [ AssertionDiagnostic ( "ClassicAssert.IsAssignableFrom<string>(actual{0});" ) ]
527
+ [ Implemented ]
528
+ public void Nunit4_AssertIsAssignableFrom_TestAnalyzer ( string assertion )
529
+ => Nunit4VerifyDiagnostic ( "object actual, Type expected" , assertion ) ;
530
+
531
+ [ DataTestMethod ]
532
+ [ AssertionCodeFix (
533
+ oldAssertion : "Assert.IsAssignableFrom(typeof(string), actual{0});" ,
534
+ newAssertion : "actual.Should().BeAssignableTo<string>({0});" ) ]
535
+ [ AssertionCodeFix (
536
+ oldAssertion : "Assert.IsAssignableFrom(expected, actual{0});" ,
537
+ newAssertion : "actual.Should().BeAssignableTo(expected{0});" ) ]
538
+ [ Implemented ]
539
+ public void Nunit3_AssertIsAssignableFrom_TestCodeFix ( string oldAssertion , string newAssertion )
540
+ => Nunit3VerifyFix ( "object actual, Type expected" , oldAssertion , newAssertion ) ;
541
+
542
+ [ DataTestMethod ]
543
+ [ AssertionCodeFix (
544
+ oldAssertion : "ClassicAssert.IsAssignableFrom(typeof(string), actual{0});" ,
545
+ newAssertion : "actual.Should().BeAssignableTo<string>({0});" ) ]
546
+ [ AssertionCodeFix (
547
+ oldAssertion : "ClassicAssert.IsAssignableFrom(expected, actual{0});" ,
548
+ newAssertion : "actual.Should().BeAssignableTo(expected{0});" ) ]
549
+ [ Implemented ]
550
+ public void Nunit4_AssertIsAssignableFrom_TestCodeFix ( string oldAssertion , string newAssertion )
551
+ => Nunit4VerifyFix ( "object actual, Type expected" , oldAssertion , newAssertion ) ;
552
+
553
+ [ DataTestMethod ]
554
+ [ AssertionDiagnostic ( "Assert.IsNotAssignableFrom(typeof(string), actual{0});" ) ]
555
+ [ AssertionDiagnostic ( "Assert.IsNotAssignableFrom(expected, actual{0});" ) ]
556
+ [ AssertionDiagnostic ( "Assert.IsNotAssignableFrom<string>(actual{0});" ) ]
557
+ [ Implemented ]
558
+ public void Nunit3_AssertIsNotAssignableFrom_TestAnalyzer ( string assertion )
559
+ => Nunit3VerifyDiagnostic ( "object actual, Type expected" , assertion ) ;
560
+
561
+ [ DataTestMethod ]
562
+ [ AssertionDiagnostic ( "ClassicAssert.IsNotAssignableFrom(typeof(string), actual{0});" ) ]
563
+ [ AssertionDiagnostic ( "ClassicAssert.IsNotAssignableFrom(expected, actual{0});" ) ]
564
+ [ AssertionDiagnostic ( "ClassicAssert.IsNotAssignableFrom<string>(actual{0});" ) ]
565
+ [ Implemented ]
566
+ public void Nunit4_AssertIsNotAssignableFrom_TestAnalyzer ( string assertion )
567
+ => Nunit4VerifyDiagnostic ( "object actual, Type expected" , assertion ) ;
568
+
569
+ [ DataTestMethod ]
570
+ [ AssertionCodeFix (
571
+ oldAssertion : "Assert.IsNotAssignableFrom(typeof(string), actual{0});" ,
572
+ newAssertion : "actual.Should().NotBeAssignableTo<string>({0});" ) ]
573
+ [ AssertionCodeFix (
574
+ oldAssertion : "Assert.IsNotAssignableFrom(expected, actual{0});" ,
575
+ newAssertion : "actual.Should().NotBeAssignableTo(expected{0});" ) ]
576
+ [ Implemented ]
577
+ public void Nunit3_AssertIsNotAssignableFrom_TestCodeFix ( string oldAssertion , string newAssertion )
578
+ => Nunit3VerifyFix ( "object actual, Type expected" , oldAssertion , newAssertion ) ;
579
+
580
+ [ DataTestMethod ]
581
+ [ AssertionCodeFix (
582
+ oldAssertion : "ClassicAssert.IsNotAssignableFrom(typeof(string), actual{0});" ,
583
+ newAssertion : "actual.Should().NotBeAssignableTo<string>({0});" ) ]
584
+ [ AssertionCodeFix (
585
+ oldAssertion : "ClassicAssert.IsNotAssignableFrom(expected, actual{0});" ,
586
+ newAssertion : "actual.Should().NotBeAssignableTo(expected{0});" ) ]
587
+ [ Implemented ]
588
+ public void Nunit4_AssertIsNotAssignableFrom_TestCodeFix ( string oldAssertion , string newAssertion )
589
+ => Nunit4VerifyFix ( "object actual, Type expected" , oldAssertion , newAssertion ) ;
590
+
591
+ // void IsInstanceOf(Type expected, object? actual, string message, params object?[]? args)
592
+ [ DataTestMethod ]
593
+ [ AssertionDiagnostic ( "Assert.IsInstanceOf(typeof(string), actual{0});" ) ]
594
+ [ AssertionDiagnostic ( "Assert.IsInstanceOf(expected, actual{0});" ) ]
595
+ [ AssertionDiagnostic ( "Assert.IsInstanceOf<string>(actual{0});" ) ]
596
+ [ Implemented ]
597
+ public void Nunit3_AssertIsInstanceOf_TestAnalyzer ( string assertion )
598
+ => Nunit3VerifyDiagnostic ( "object actual, Type expected" , assertion ) ;
599
+
600
+ [ DataTestMethod ]
601
+ [ AssertionDiagnostic ( "ClassicAssert.IsInstanceOf(typeof(string), actual{0});" ) ]
602
+ [ AssertionDiagnostic ( "ClassicAssert.IsInstanceOf(expected, actual{0});" ) ]
603
+ [ AssertionDiagnostic ( "ClassicAssert.IsInstanceOf<string>(actual{0});" ) ]
604
+ [ Implemented ]
605
+ public void Nunit4_AssertIsInstanceOf_TestAnalyzer ( string assertion )
606
+ => Nunit4VerifyDiagnostic ( "object actual, Type expected" , assertion ) ;
607
+
608
+ [ DataTestMethod ]
609
+ [ AssertionCodeFix (
610
+ oldAssertion : "Assert.IsInstanceOf(typeof(string), actual{0});" ,
611
+ newAssertion : "actual.Should().BeOfType<string>({0});" ) ]
612
+ [ AssertionCodeFix (
613
+ oldAssertion : "Assert.IsInstanceOf(expected, actual{0});" ,
614
+ newAssertion : "actual.Should().BeOfType(expected{0});" ) ]
615
+ [ Implemented ]
616
+ public void Nunit3_AssertIsInstanceOf_TestCodeFix ( string oldAssertion , string newAssertion )
617
+ => Nunit3VerifyFix ( "object actual, Type expected" , oldAssertion , newAssertion ) ;
618
+
619
+ [ DataTestMethod ]
620
+ [ AssertionCodeFix (
621
+ oldAssertion : "ClassicAssert.IsInstanceOf(typeof(string), actual{0});" ,
622
+ newAssertion : "actual.Should().BeOfType<string>({0});" ) ]
623
+ [ AssertionCodeFix (
624
+ oldAssertion : "ClassicAssert.IsInstanceOf(expected, actual{0});" ,
625
+ newAssertion : "actual.Should().BeOfType(expected{0});" ) ]
626
+ [ Implemented ]
627
+ public void Nunit4_AssertIsInstanceOf_TestCodeFix ( string oldAssertion , string newAssertion )
628
+ => Nunit4VerifyFix ( "object actual, Type expected" , oldAssertion , newAssertion ) ;
629
+
630
+ [ DataTestMethod ]
631
+ [ AssertionDiagnostic ( "Assert.IsNotInstanceOf(typeof(string), actual{0});" ) ]
632
+ [ AssertionDiagnostic ( "Assert.IsNotInstanceOf(expected, actual{0});" ) ]
633
+ [ AssertionDiagnostic ( "Assert.IsNotInstanceOf<string>(actual{0});" ) ]
634
+ [ Implemented ]
635
+ public void Nunit3_AssertIsNotInstanceOf_TestAnalyzer ( string assertion )
636
+ => Nunit3VerifyDiagnostic ( "object actual, Type expected" , assertion ) ;
637
+
638
+ [ DataTestMethod ]
639
+ [ AssertionDiagnostic ( "ClassicAssert.IsNotInstanceOf(typeof(string), actual{0});" ) ]
640
+ [ AssertionDiagnostic ( "ClassicAssert.IsNotInstanceOf(expected, actual{0});" ) ]
641
+ [ AssertionDiagnostic ( "ClassicAssert.IsNotInstanceOf<string>(actual{0});" ) ]
642
+ [ Implemented ]
643
+ public void Nunit4_AssertIsNotInstanceOf_TestAnalyzer ( string assertion )
644
+ => Nunit4VerifyDiagnostic ( "object actual, Type expected" , assertion ) ;
645
+
646
+ [ DataTestMethod ]
647
+ [ AssertionCodeFix (
648
+ oldAssertion : "Assert.IsNotInstanceOf(typeof(string), actual{0});" ,
649
+ newAssertion : "actual.Should().NotBeOfType<string>({0});" ) ]
650
+ [ AssertionCodeFix (
651
+ oldAssertion : "Assert.IsNotInstanceOf(expected, actual{0});" ,
652
+ newAssertion : "actual.Should().NotBeOfType(expected{0});" ) ]
653
+ [ Implemented ]
654
+ public void Nunit3_AssertIsNotInstanceOf_TestCodeFix ( string oldAssertion , string newAssertion )
655
+ => Nunit3VerifyFix ( "object actual, Type expected" , oldAssertion , newAssertion ) ;
656
+
657
+ [ DataTestMethod ]
658
+ [ AssertionCodeFix (
659
+ oldAssertion : "ClassicAssert.IsNotInstanceOf(typeof(string), actual{0});" ,
660
+ newAssertion : "actual.Should().NotBeOfType<string>({0});" ) ]
661
+ [ AssertionCodeFix (
662
+ oldAssertion : "ClassicAssert.IsNotInstanceOf(expected, actual{0});" ,
663
+ newAssertion : "actual.Should().NotBeOfType(expected{0});" ) ]
664
+ [ Implemented ]
665
+ public void Nunit4_AssertIsNotInstanceOf_TestCodeFix ( string oldAssertion , string newAssertion )
666
+ => Nunit4VerifyFix ( "object actual, Type expected" , oldAssertion , newAssertion ) ;
667
+
668
+ #endregion
669
+
513
670
private void Nunit3VerifyDiagnostic ( string methodArguments , string assertion )
514
671
=> VerifyDiagnostic ( GenerateCode . Nunit3Assertion ( methodArguments , assertion ) , PackageReference . Nunit_3_14_0 ) ;
515
672
private void Nunit3VerifyFix ( string methodArguments , string oldAssertion , string newAssertion )
0 commit comments