Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the `Assert.That` property for?

Does anybody know what this Assert.That property is for? All members of Assert are static so what is the point of getting an instance?

I know that NUnit has a method Assert.That for hamcrest matchers but a property does not seem to make sense. Maybe this property is for custom assertions as extension methods on Assert?

enter image description here

like image 568
halllo Avatar asked Dec 18 '22 02:12

halllo


1 Answers

Assert.That Property

Gets the singleton instance of the Assert functionality.

Users can use this to plug-in custom assertions through C# extension methods. For instance, the signature of a custom assertion provider could be "public static void IsOfType(this Assert assert, object obj)" Users could then use a syntax similar to the default assertions which in this case is "Assert.That.IsOfType<Dog>(animal);"

More documentation is at https://github.com/Microsoft/testfx-docs.

like image 196
Rufus L Avatar answered Jan 01 '23 07:01

Rufus L