I have a tool that generate entities I need to generate a samlpe value for testing. the problem is that we have alot of logical types (some of the same type but still different) and befor coding i wanted to know if someone have a easier solution…
Here is the Enum :
public enum LogicalTypeEnum
{
Identity,
DateAndTime,
Binary,
Quantity,
Comment,
Money,
Rate,
TimeStamp,
Caption,
Reference,
Number,
Weight,
Space,
Username,
Phone,
Email,
ZipCode
}
Thanks!!!
EDIT 1: I want to generate a random value not get a random element from the enum. I’m searching a way to get a random email or zipcode or money value.
I think you have to divide your answer into two parts:
First get a random enum type out of the list. I think this part is already solved by the other answers provided.
Afterwards you like to create a list of random values for the selected enum. So you need a factory that can create a valid random value for each of these types. The thing that come closest to your needs should be AutoPoco. It is quite easy to create a bunch of sample object filled up with some values you like for example
As you can see you can provide for each property your own Source (
.Use<...Source>()).There are already some default sources within the project but i also made some on my own like the following:
So you could create your own source for each type and afterwards quite easy create a bunch of sample objects.