Skip to content

Configuration

Robert Wagner edited this page Nov 2, 2016 · 3 revisions

The behaviour of Assent can be customised by passing a Configuration object to the Assent method:

var configuration = new Configuration();
this.Assent("String To Assert", configuration);

Configuration is immutable, so a configuration can be maintained for a suit of tests, and then customised individual tests. Instance methods return a new mutated instance of Configuration, similar to LINQ methods. For example:

Configuration commonConfiguration = new Configuration()
	.UsingComparer(new CustomComparer());

public void Test1()
{
    var testConfiguration = commonConfiguration.UsingExtension("json");
    this.Assent("String To Assert", testConfiguration);
}

public void Test2()
{
    // Will use the default extension (`txt`), not `json`
    this.Assent("String To Assert", commonConfiguration ); 
}
Clone this wiki locally