Provides a default instance of the tested type.

Namespace:  MbUnit.Framework.ContractVerifiers
Assembly:  MbUnit (in MbUnit.dll) Version: 3.3.0.0 (3.3.610.0)

Syntax

C#
public Func<TTarget> DefaultInstance { get; set; }
Visual Basic (Declaration)
Public Property DefaultInstance As Func(Of TTarget)

Remarks

By default, the contract verifier attempts to invoke the default constructor to get an valid instance. Overwrite the default provider if the type has no default constructor, or if you want to use a particular instance.

Examples

CopyC#
[VerifyContract]
public readonly IContract AccessorTest = new AccessorContract<Foo, int>
{
    DefaultInstance = () => new Foo("Hello")
    // Other initialization stuff...
};

See Also