What I'd like to do is create a class with some attributes on different properties, pass that class to another that will set the properties with appropriate random data... here in pseudo code:
public class Customer
{
[Attribute("FirstName")]
private string CustomerFirstName;
public {get;set} //etc
[Attribute("LastName")]
private string CustomerLastName;
public {get;set;} //etc
[Attribute("DateTime")]
private DateTime CustomerSignUpDate;
public DateTime {get;set;} //yadda
[Attribute("Phone")]
private string CustomerPhone;
public string {get;set;} //yadda
}
And then do like this
IList<Customer> CustomerList=ClassFillerOutClass(new Customer(),5);
And the result would be a List of 5 Customers that have appropriate 'random' data in their properties.
If this doesn't exist...I guess I could start a project myself to do...I just don't want to reinvent the wheel if it's not necessary.
EDIT: I forgot a piece. I'm looking to use this as a test tool. So in the example above I could quickly create a list of 5 customers with random but appropriate values. And then say pass that to my persistence method, and have something I can check against. I'm trying to avoid manually creating a populated object everytime for my TDD purposes.
EDIT 2: Ok so I started rolling my own...I'll post it on Codeplex this weekend and link it here...I clearly won't be done but it'll be a start if anyone else wants to work on it.
I tried AutoFixture (http://autofixture.codeplex.com/) and it worked well for me. I was able to generate an object with a deep hierarchy of children in one line of code.
Ok...so I never found one....so I decided to start my own. Check out: Object Hydrator.
The project is presently a quick spike...but I think it has potential...let me know if you have ideas how to make it better.
Nowadays you have also NBuilder ( nbuilder.org ) that does the same.
I don't know if both projects are linked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With