简体   繁体   English

什么是'Assert.That`属性?

[英]What is the `Assert.That` property for?

Does anybody know what this Assert.That property is for? 有谁知道这个Assert.That属性是什么? All members of Assert are static so what is the point of getting an instance? Assert所有成员都是静态的,那么获取实例有什么意义呢?

I know that NUnit has a method Assert.That for hamcrest matchers but a property does not seem to make sense. 我知道NUnit有一个方法Assert.That对于hamcrest匹配器,但一个属性似乎没有意义。 Maybe this property is for custom assertions as extension methods on Assert ? 也许这个属性是自定义断言作为Assert上的扩展方法?

在此输入图像描述

Assert.That Property 断言。那个属性

Gets the singleton instance of the Assert functionality. 获取Assert功能的单例实例。

Users can use this to plug-in custom assertions through C# extension methods. 用户可以使用它通过C#扩展方法插入自定义断言。 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); " 例如,自定义断言提供程序的签名可以是“public static void IsOfType(this Assert assert,object obj)”然后,用户可以使用类似于默认断言的语法,在这种情况下是“ Assert.That.IsOfType<Dog>(animal);

More documentation is at https://github.com/Microsoft/testfx-docs . 更多文档位于https://github.com/Microsoft/testfx-docs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM