Created
March 14, 2013 13:50
-
-
Save bitsprint/5161461 to your computer and use it in GitHub Desktop.
TestDataBuilder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace Tests.Core.Builder | |
| { | |
| using System; | |
| public class TestDataBuilder<T, U> where T : TestDataBuilder<T, U>, new() where U : new() | |
| { | |
| private readonly U entity = new U(); | |
| protected TestDataBuilder() | |
| { | |
| } | |
| public static T New | |
| { | |
| get { return new T(); } | |
| } | |
| protected U Entity | |
| { | |
| get { return this.entity; } | |
| } | |
| public T With(Action<U> expression) | |
| { | |
| expression(this.entity); | |
| return (T)this; | |
| } | |
| public U Build() | |
| { | |
| return this.entity; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment