开发者

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

开发者 https://www.devze.com 2022-12-08 06:57 出处:网络
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 practica

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

精彩评论

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