-
Notifications
You must be signed in to change notification settings - Fork 3
Object Generation
reddy6ue edited this page Sep 4, 2017
·
5 revisions
Start the process off by calling Session.Single<T>
- Session
-
Single<T>: Kicks off the generation process for a single object of typeT-
Impose(x=>x.Property, "Value"): Imposes a value onto a property of the generated object, overwriting any data source provided value. Re-returns the Single object - Get(): Creates the object with all property modification applied and returns it
-
-
Create a user and override some properties on that user
SimpleUser user = mSession.Single<SimpleUser>()
.Impose(x => x.EmailAddress, "override@override.com")
.Impose(x=>x.FirstName, "Override")
.Impose(x=>x.LastName, "Override")
.Get();Start the process off by calling Session.List
-
Session-
List<T>(int count): Kicks off the generation process for a list ofTof size 'count'-
Impose(x=>x.Property, "Value"): Imposes a value onto the property of every single object, re-returns theList<T>object -
First(int count): Selects the first 'count' items in the collection-
Impose(x=>x.Property, "Value"): Imposes value onto the property of every single object in the current selection, re-returns the First object -
Next(int count): Selects the next 'count' items in the collection, re-returns the First object -
All(): Returns to theList<T>object
-
-
Random(int count): Selects a random selection of items from the collection of size 'count' *Impose(x=>x.Property, "Value"): Imposes value onto the property of every single object in the current selection, re-returns the Random object-
Next(int count): Selects the next 'count' items in the randomized collection, this will not include any previously selected items -
All(): Returns to the List object
-
-
Get(): Creates the list of objects with all property modifications applied and returns it
-
-
Create a list of users, call the first 5 of them Bob, call the next 5 of them Alice
mSession.List<SimpleUser>()
.First(5)
.Impose(x => x.FirstName, "Bob")
.Next(5)
.Impose(x => x.FirstName, "Alice")
.All()
.Get();| # | First Name |
|---|---|
| 0 | Bob |
| 1 | Bob |
| 2 | Bob |
| 3 | Bob |
| 4 | Bob |
| 5 | Alice |
| 6 | Alice |
| 7 | Alice |
| 8 | Alice |
| 9 | Alice |
Create a list of users, call a 5 randoms Bob, and the other 5 randoms Alice
mSession.List<SimpleUser>()
.Random(5)
.Impose(x => x.FirstName, "Bob")
.Next(5)
.Impose(x => x.FirstName, "Alice")
.All()
.Get();| # | First Name |
|---|---|
| 0 | Bob |
| 1 | Alice |
| 2 | Alice |
| 3 | Bob |
| 4 | Bob |
| 5 | Alice |
| 6 | Bob |
| 7 | Alice |
| 8 | Bob |
| 9 | Alice |
Create a list of users, call a 5 randoms Bob, and the other 5 randoms Alice Ensure the first 5 have last names of "Blue" Ensure the last 5 have last names of "Red"
mSession.List<SimpleUser>()
.Random(5)
.Impose(x => x.FirstName, "Bob")
.Next(5)
.Impose(x => x.FirstName, "Alice")
.All()
.First(5)
.Impose(x => x.LastName, "Blue")
.Next(5)
.Impose(x => x.FirstName, "Red")
.All()
.Get();| # | First Name | Last Name |
|---|---|---|
| 0 | Bob | Blue |
| 1 | Alice | Blue |
| 2 | Alice | Blue |
| 3 | Bob | Blue |
| 4 | Bob | Blue |
| 5 | Alice | Red |
| 6 | Bob | Red |
| 7 | Alice | Red |
| 8 | Bob | Red |
| 9 | Alice | Red |