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

By default the approved and received files are named in the following format:

{sourceFileDirectory}\{TypeName}.{MethodName}.{approved|received}.{extension}

The this.Assent() method call captures the test class instance (this), method name and source file location.

Extension

The extension used can be changed:

configuration.UsingExtension(".json");

Filename

The naming (ie the directory and filename) can be customised by implementing INamer and configuring it:

configuration.WithNamer(new CustomNamer())

INamer.GetName should return a file path without extension

Supplied Namers

PostfixNamer

This is a simple extension on the DefaultNamer that adds a . and a fixed string to the end of the name. This can be used to have different approval files based on test case, platform, architecture or runtime. For example the following will add the framework to the end of the name:

var framework = string.Concat(RuntimeInformation.FrameworkDescription.Split(' ').Take(2));
var configuration = new Configuration().UsingNamer(new PostfixNamer(framework));
this.Assent("String to assert", configuration);
Clone this wiki locally