Skip to content


Repository files navigation


Build status


One of the more immediately applicable recommendations from Growing Object-Oriented Software, Guided by Tests (GOOS) is to make use of Test Data Builders, to allow you to construct test data with a fluent syntax, such as

            .WithFirstLine("123 Main Street")

This pattern is immensely powerful, but requires the writing of a lot of code for each type you wish to build. The aim of BobTheBuilder is to provide a generic implementation of the Test Data Builder pattern from GOOS, using C#'s support for dynamic dispatch to intelligently hydrate the destination object. For example, using the same hypothetical types as above:

Customer customer =
                .WithFirstLine("123 Main Street")

Note that a dynamic builder can be implicitly cast to the type it builds and the Build() method will be automatically invoked. This saves you a bit of typing if desired and reduces noise, but requires you to explicitly state your variable types; it comes into its own when nesting builders, though, as in the example above.

Task List

  • Add support for readonly properties via the constructor
  • Add support for objects with constructor dependencies
    • Add support for supplying constructor arguments via builder syntax
    • Add support for providing unspecified constructor arguments with a mock library or similar
  • Add support for complex types
  • Add support for named arguments syntax (.With(stringProperty: "new value"))
  • Get a better name...

Please request features and report bugs, or better still fork me and send me a pull request.


The idea for this library was partially inspired by previous exposure to Simple.Data, and the number of Test Data Builders I have written in the last twelve months. Thanks Steve and Nat for such an elegantly simple, and yet extremely powerful, piece of advice.