Class BuilderBehavior.BuildTester<TBuilder, TBuilt>
Helper class that provides useful test patterns for a builder type and the type that it builds.
Inheritance
Namespace: LaunchDarkly.TestHelpers
Assembly: LaunchDarkly.TestHelpers.dll
Syntax
public sealed class BuildTester<TBuilder, TBuilt> : Object
Type Parameters
| Name | Description |
|---|---|
| TBuilder | the builder type |
| TBuilt | the type that it builds |
Remarks
Create instances of this class with For<TBuilder, TBuilt>(Func<TBuilder>, Func<TBuilder, TBuilt>).
Methods
New()
Creates an instance of the builder.
Declaration
public TBuilder New()
Returns
| Type | Description |
|---|---|
| TBuilder | a new instance |
Property<TValue>(Func<TBuilt, TValue>, Action<TBuilder, TValue>)
Creates a helper for testing a specific property of the builder.
Declaration
public BuilderBehavior.IPropertyAssertions<TValue> Property<TValue>(Func<TBuilt, TValue> getter, Action<TBuilder, TValue> builderSetter)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Func<TBuilt, TValue> | getter | function that gets that property from the built object |
| System.Action<TBuilder, TValue> | builderSetter | function that sets the property in the builder |
Returns
| Type | Description |
|---|---|
| BuilderBehavior.IPropertyAssertions<TValue> |
Type Parameters
| Name | Description |
|---|---|
| TValue | type of the property |
WithCopyConstructor(Func<TBuilt, TBuilder>)
Adds the ability to test the builder's copy constructor.
Declaration
public BuilderBehavior.BuildTester<TBuilder, TBuilt> WithCopyConstructor(Func<TBuilt, TBuilder> copyConstructor)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Func<TBuilt, TBuilder> | copyConstructor | function that should create a new builder with an identical state to the existing one |
Returns
| Type | Description |
|---|---|
| BuilderBehavior.BuildTester<TBuilder, TBuilt> | a copy of the |
Remarks
The effect of this is that all Property<TValue>(Func<TBuilt, TValue>, Action<TBuilder, TValue>) assertions created from the resulting helper will also verify that copying the builder also copies the value of this property.