Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 31 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@ Example Usage
===========
Let's say you have a Person class like so:

```
class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Title { get; set; }
public int Age { get; set; }
public int NumberOfKids { get; set; }
private string _middleName;
public void SetMiddleName(string name){ _middleName = name; }
}
``` cs
class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Title { get; set; }
public int Age { get; set; }
public int NumberOfKids { get; set; }

private string _middleName;
public void SetMiddleName(string name){ _middleName = name; }
}
```

And you want a new instance of Person. With GenFu, you just do this:

```
var person = A.New<Person>();
``` cs
var person = A.New<Person>();
```

Tada! Your `person` is now filled with all the data you could ever dream of!
Expand All @@ -54,8 +54,8 @@ Tada! Your `person` is now filled with all the data you could ever dream of!

Easy-peasy lemon squeezy, my friend! Ask for a list instead of a single instance like so:

```
var people = A.ListOf<Person>();
``` cs
var people = A.ListOf<Person>();
```

There...you have 25 people, this is the default in a list.
Expand All @@ -64,13 +64,11 @@ There...you have 25 people, this is the default in a list.

Cool beans, my brother or sister. Here's how GenFu rolls:

```

GenFu.Configure<Person>()
.Fill(p => p.Age)
.WithinRange(19, 25);
var people = A.ListOf<Person>();

``` cs
GenFu.Configure<Person>()
.Fill(p => p.Age)
.WithinRange(19, 25);
var people = A.ListOf<Person>();
```

And you're off to the races! Don't worry, I won't tell your boss how long that took. ;)
Expand All @@ -80,13 +78,13 @@ Custom Property Fillers

If you want to control how the property is set, you can use your own function (anonymous or otherwise) to do so.

```
var blogTitle = "GenFu";
``` cs
var blogTitle = "GenFu";

GenFu.Configure<BlogPost>()
.Fill(b => b.Title, () => { return blogTitle; })
var post = A.New<BlogPost>();
GenFu.Configure<BlogPost>()
.Fill(b => b.Title, () => { return blogTitle; })

var post = A.New<BlogPost>();
```


Expand All @@ -95,10 +93,10 @@ Method Fillers

If your project uses one-parameter setter methods, you can use GenFu too!

```
GenFu.Configure<Person>()
.MethodFill<string>(x => x.SetMiddleName(null))
var post = A.New<Person>();
``` cs
GenFu.Configure<Person>()
.MethodFill<string>(x => x.SetMiddleName(null))
var post = A.New<Person>();
```

You can use any of the helper methods with setter methods, just like with properties.
Expand Down