@@ -694,6 +694,81 @@ public void AssertEquivalent_TestAnalyzer(string arguments, string assertion) =>
694694 public void AssertEquivalent_TestCodeFix ( string oldAssertion , string newAssertion )
695695 => VerifyCSharpFix ( "object actual, object expected" , oldAssertion , newAssertion ) ;
696696
697+ [ DataTestMethod ]
698+ [ DataRow ( "Action action" , "Assert.Throws(typeof(ArgumentException), action);" ) ]
699+ [ DataRow ( "Action action, Type exceptionType" , "Assert.Throws(exceptionType, action);" ) ]
700+ [ DataRow ( "Action action" , "Assert.Throws<NullReferenceException>(action);" ) ]
701+ [ DataRow ( "Action action" , "Assert.Throws<ArgumentException>(\" propertyName\" , action);" ) ]
702+ [ Implemented ]
703+ public void AssertThrows_TestAnalyzer ( string arguments , string assertion )
704+ => VerifyCSharpDiagnostic ( arguments , assertion ) ;
705+
706+ [ DataTestMethod ]
707+ [ DataRow ( "Action action" ,
708+ /* oldAssertion */ "Assert.Throws(typeof(ArgumentException), action);" ,
709+ /* newAssertion */ "action.Should().ThrowExactly<ArgumentException>();" ) ]
710+ [ DataRow ( "Action action" ,
711+ /* oldAssertion */ "Assert.Throws<NullReferenceException>(action);" ,
712+ /* newAssertion */ "action.Should().ThrowExactly<NullReferenceException>();" ) ]
713+ [ DataRow ( "Action action" ,
714+ /* oldAssertion */ "Assert.Throws<ArgumentException>(\" propertyName\" , action);" ,
715+ /* newAssertion */ "action.Should().ThrowExactly<ArgumentException>().WithParameterName(\" propertyName\" );" ) ]
716+ [ Implemented ]
717+ public void AssertThrows_TestCodeFix ( string arguments , string oldAssertion , string newAssertion )
718+ => VerifyCSharpFix ( arguments , oldAssertion , newAssertion ) ;
719+
720+ [ DataTestMethod ]
721+ [ DataRow ( "Func<Task> action" , "Assert.ThrowsAsync(typeof(ArgumentException), action);" ) ]
722+ [ DataRow ( "Func<Task> action, Type exceptionType" , "Assert.ThrowsAsync(exceptionType, action);" ) ]
723+ [ DataRow ( "Func<Task> action" , "Assert.ThrowsAsync<NullReferenceException>(action);" ) ]
724+ [ DataRow ( "Func<Task> action" , "Assert.ThrowsAsync<ArgumentException>(\" propertyName\" , action);" ) ]
725+ [ Implemented ]
726+ public void AssertThrowsAsync_TestAnalyzer ( string arguments , string assertion )
727+ => VerifyCSharpDiagnostic ( arguments , assertion ) ;
728+
729+ [ DataTestMethod ]
730+ [ DataRow ( "Func<Task> action" ,
731+ /* oldAssertion */ "Assert.ThrowsAsync(typeof(ArgumentException), action);" ,
732+ /* newAssertion */ "action.Should().ThrowExactlyAsync<ArgumentException>();" ) ]
733+ [ DataRow ( "Func<Task> action" ,
734+ /* oldAssertion */ "Assert.ThrowsAsync<NullReferenceException>(action);" ,
735+ /* newAssertion */ "action.Should().ThrowExactlyAsync<NullReferenceException>();" ) ]
736+ [ DataRow ( "Func<Task> action" ,
737+ /* oldAssertion */ "Assert.ThrowsAsync<ArgumentException>(\" propertyName\" , action);" ,
738+ /* newAssertion */ "action.Should().ThrowExactlyAsync<ArgumentException>().WithParameterName(\" propertyName\" );" ) ]
739+ [ Implemented ]
740+ public void AssertThrowsAsync_TestCodeFix ( string arguments , string oldAssertion , string newAssertion )
741+ => VerifyCSharpFix ( arguments , oldAssertion , newAssertion ) ;
742+
743+ [ DataTestMethod ]
744+ [ DataRow ( "Action action" , "Assert.ThrowsAny<NullReferenceException>(action);" ) ]
745+ [ Implemented ]
746+ public void AssertThrowsAny_TestAnalyzer ( string arguments , string assertion )
747+ => VerifyCSharpDiagnostic ( arguments , assertion ) ;
748+
749+ [ DataTestMethod ]
750+ [ DataRow ( "Action action" ,
751+ /* oldAssertion */ "Assert.ThrowsAny<NullReferenceException>(action);" ,
752+ /* newAssertion */ "action.Should().Throw<NullReferenceException>();" ) ]
753+ [ Implemented ]
754+ public void AssertThrowsAny_TestCodeFix ( string arguments , string oldAssertion , string newAssertion )
755+ => VerifyCSharpFix ( arguments , oldAssertion , newAssertion ) ;
756+
757+ [ DataTestMethod ]
758+ [ DataRow ( "Func<Task> action" , "Assert.ThrowsAnyAsync<NullReferenceException>(action);" ) ]
759+ [ Implemented ]
760+ public void AssertThrowsAnyAsync_TestAnalyzer ( string arguments , string assertion )
761+ => VerifyCSharpDiagnostic ( arguments , assertion ) ;
762+
763+ [ DataTestMethod ]
764+ [ DataRow ( "Func<Task> action" ,
765+ /* oldAssertion */ "Assert.ThrowsAnyAsync<NullReferenceException>(action);" ,
766+ /* newAssertion */ "action.Should().ThrowAsync<NullReferenceException>();" ) ]
767+ [ Implemented ]
768+ public void AssertThrowsAnyAsync_TestCodeFix ( string arguments , string oldAssertion , string newAssertion )
769+ => VerifyCSharpFix ( arguments , oldAssertion , newAssertion ) ;
770+
771+
697772 private void VerifyCSharpDiagnostic ( string methodArguments , string assertion )
698773 {
699774 var source = GenerateCode . XunitAssertion ( methodArguments , assertion ) ;
0 commit comments