mardi 4 juillet 2023

How to use Fluent Assertions Should().Throw() with NOT hardcoded exception type?

I would like to use fluent assertions .Should().Throw, but do not want to hardcode the type of the expected exception, instead I want it parametrized, so it is in a variable which type is Type.

Without parametrized it should be the following:

Action act = () => sut.MyMethod();
act.Should().Throw<MyException>().Where(myPredicate);

However I would like to the type of MyException to be a parameter in a variable





Aucun commentaire:

Enregistrer un commentaire