Skip to content

Instantly share code, notes, and snippets.

@bitsprint
Created March 14, 2013 13:50
Show Gist options
  • Select an option

  • Save bitsprint/5161461 to your computer and use it in GitHub Desktop.

Select an option

Save bitsprint/5161461 to your computer and use it in GitHub Desktop.
TestDataBuilder
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