开发者

Is there some library to create object instances with dummy data in their properties?

I wonder if there is any .net library to create "dum开发者_JS百科my" instances of an object. In my particular scenario im dealing with classes with lots of fields, so manual creation is not practical.

It would not be that hard to code this. But maybe there is something out there. Thanks


There is. Check out NBuilder.

var products = Builder<Product>.CreateListOfSize(100)
                 .WhereTheFirst(10)
                     .Have(x => x.QuantityInStock = Generate.RandomInt(1, 2000))
                 .List;

And it goes from there. Pretty cool stuff.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜