Skip to content

dchetwynd/Implicit_Builder_Conversion_in_CSharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

This is an example of a neat trick that I learned about test builders in C# whilst attending the LeedsSharp user group (http://www.leeds-sharp.co.uk/). Leeds Sharp meets on the last Thursday of every month.

Test builders are classes used to simplify the creation of complex objects in tests. They have a series of "with" methods corresponding to setting fields in the target object, where these are called in a chain to generate the target object. The final method call in this chain is a build() call that converts the builder object into the desired target object.

This example shows that by using implicit type conversion in C#, this final build() call is not necessary for a builder.

About

An example of how to use C# implicit type conversion when using builders to create test objects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published