Pex

编程入门 行业动态 更新时间:2024-10-26 16:27:38
Pex - 测试'Type'参数(Pex - testing 'Type' parameters)

我有几个方法检查类型之间的可分配性或接口可分配性。 因此我有类似(Type type1, Type type2)签名。

Pex努力为这些参数生成输入,并以某种类型构建某种类型或其他类型(已关闭VS),因为Type本身是抽象的。

我试着创建一个工厂,根据输入选择四种测试“类型”中的一种,然后希望Pex能够将工厂用于生成不同的输入,并因此将不同的输入输入到我的测试方法中。

typeof(object)和typeof(object) typeof(object)和typeof(string) 等等...

现在它只是抱怨Sytem.Type是抽象的,无法探索。 我是Pex的新手,但我不知道如何为方法生成不同的输入。

任何帮助?

I have a couple of methods that check for assignablity or interface assignabilty between types. Therefore I have signatures like (Type type1, Type type2).

Pex struggles to generate inputs for these parameters and ends up with some type build something or other type (sorry closed VS already) because Type itself is abstract.

I tried creating a factory that would pick one of four test 'types' based on inputs and then hoped that Pex would work the factory out to generate different inputs, and therefore put different inputs into my test method.

typeof(object) and typeof(object) typeof(object) and typeof(string) and so on...

Now it just complains that Sytem.Type is abstract and can't be explored. I'm new to Pex, but I don't know how else to generate varying inputs for the methods.

Any help?

最满意答案

使用int作为输入并使用开关根据int值选择一个类型。 讨厌的黑客攻击,但有时需要佩克斯。

Use an int as input and use a switch to choose a type based on the int value. A nasty hack, but sometimes required with Pex.

更多推荐

本文发布于:2023-07-24 19:32:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1250151.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Pex

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!