{"__v":2,"_id":"55563946ea5e120d00188550","category":{"__v":9,"_id":"5543585f795b590d001dc89a","pages":["554358c8b7f4540d00fcef43","55435b69b7f4540d00fcef46","55435bf2795b590d001dc8a3","55435ec262b30e0d004b1706","555636f626e9bc0d0044ea81","55563946ea5e120d00188550","555639cc26e9bc0d0044ea8d","5561dd7bb40338210035f905","56bafe8ccec63e0d00f0d2eb"],"project":"553dec691a946a0d00ad6f27","version":"553dec691a946a0d00ad6f2a","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-05-01T10:41:35.279Z","from_sync":false,"order":1,"slug":"usage","title":"Usage"},"project":"553dec691a946a0d00ad6f27","user":"54c4b05742190d0d00f5fbde","version":{"__v":2,"_id":"553dec691a946a0d00ad6f2a","project":"553dec691a946a0d00ad6f27","createdAt":"2015-04-27T07:59:37.477Z","releaseDate":"2015-04-27T07:59:37.477Z","categories":["553dec691a946a0d00ad6f2b","5543585f795b590d001dc89a"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-05-15T18:21:58.072Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":4,"body":"When you extend the `TestDataBuilder` as part of creating a custom builder you will be forced to override the abstract `BuildObject` method. You have full flexibility to  call the constructor of your class directly as shown above, but you can also invoke some convention-based factories to speed up the creation of your builder (also shown above) using the `BuildUsing` method.\n\nThe `BuildUsing` method takes an instance of `IFactory`, of which you can create your own factory implementation that takes into account your own conventions or you can use one of the built-in ones:\n\n* `AllPropertiesFactory` - Calls the longest constructor with builder values (or anonymous values if none set) based on case-insensitive match of constructor parameter names against property names and then calls the setter on all properties (public or private) with builder values (or anonymous values if none set)\n* `PublicPropertySettersFactory` - Calls the longest constructor with builder values (or anonymous values if none set) based on case-insensitive match of constructor parameter names against property names and then calls the setter on all properties with public setters with builder values (or anonymous values if none set)\n* `CallConstructorFactory` - Calls the longest constructor with builder values (or anonymous values if none set) based on case-insensitive match of constructor parameter names against property names\n* `AutoFixtureFactory` - Asks AutoFixture to create an anonymous instance of the class (note: does **not** use any builder values or anonymous values from Dossier)","excerpt":"","slug":"build-objects-without-calling-constructor","type":"basic","title":"Automatic construction"}

Automatic construction


When you extend the `TestDataBuilder` as part of creating a custom builder you will be forced to override the abstract `BuildObject` method. You have full flexibility to call the constructor of your class directly as shown above, but you can also invoke some convention-based factories to speed up the creation of your builder (also shown above) using the `BuildUsing` method. The `BuildUsing` method takes an instance of `IFactory`, of which you can create your own factory implementation that takes into account your own conventions or you can use one of the built-in ones: * `AllPropertiesFactory` - Calls the longest constructor with builder values (or anonymous values if none set) based on case-insensitive match of constructor parameter names against property names and then calls the setter on all properties (public or private) with builder values (or anonymous values if none set) * `PublicPropertySettersFactory` - Calls the longest constructor with builder values (or anonymous values if none set) based on case-insensitive match of constructor parameter names against property names and then calls the setter on all properties with public setters with builder values (or anonymous values if none set) * `CallConstructorFactory` - Calls the longest constructor with builder values (or anonymous values if none set) based on case-insensitive match of constructor parameter names against property names * `AutoFixtureFactory` - Asks AutoFixture to create an anonymous instance of the class (note: does **not** use any builder values or anonymous values from Dossier)