{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"required","params":[],"results":{"codes":[]}},"next":{"description":"","pages":[]},"title":"Automatic construction","type":"basic","slug":"build-objects-without-calling-constructor","excerpt":"","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)","updates":[],"order":4,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"55563946ea5e120d00188550","project":"553dec691a946a0d00ad6f27","createdAt":"2015-05-15T18:21:58.072Z","githubsync":"","user":"54c4b05742190d0d00f5fbde","version":{"version":"1.0","version_clean":"1.0.0","codename":"","is_stable":true,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["553dec691a946a0d00ad6f2b","5543585f795b590d001dc89a"],"_id":"553dec691a946a0d00ad6f2a","createdAt":"2015-04-27T07:59:37.477Z","project":"553dec691a946a0d00ad6f27","__v":2,"releaseDate":"2015-04-27T07:59:37.477Z"},"__v":2,"category":{"sync":{"isSync":false,"url":""},"pages":["554358c8b7f4540d00fcef43","55435b69b7f4540d00fcef46","55435bf2795b590d001dc8a3","55435ec262b30e0d004b1706","555636f626e9bc0d0044ea81","55563946ea5e120d00188550","555639cc26e9bc0d0044ea8d","5561dd7bb40338210035f905","56bafe8ccec63e0d00f0d2eb"],"title":"Usage","slug":"usage","order":1,"from_sync":false,"reference":false,"_id":"5543585f795b590d001dc89a","version":"553dec691a946a0d00ad6f2a","__v":9,"createdAt":"2015-05-01T10:41:35.279Z","project":"553dec691a946a0d00ad6f27"}}

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)