#readwise
# Test Data Builders in C#

## Metadata
- Author: [[Mark Seemann]]
- Full Title: Test Data Builders in C#
- URL: https://blog.ploeh.dk/2017/08/15/test-data-builders-in-c/
## Highlights
- The purpose of a Test Data Builder is to make it easy to create input data (or objects) for unit tests. Imagine, for example, that for a particular test case, you need an address in Paris; no other values matter. With a Test Data Builder, you can write an expression that gives you such a value:
`var address = new AddressBuilder().WithCity("Paris").Build();`
The `address` object explicity has a `City` value of `"Paris"`. Any other values are default values defined by `AddressBuilder`. The values are there, but when they're unimportant to a particular test case, you don't have to specify them. To [paraphrase Robert C. Martin](http://amzn.to/19W4JHk), this eliminates the irrelevant, and amplifies the essentials of the test. ([View Highlight](https://read.readwise.io/read/01gwa1e3p8pdb217vbskkedbwk))