Files
WireMock.Net-wiremock/src/WireMock.Net/Transformers/HandlebarsContextFactory.cs
Stef Heyenrath 06be3aff95 Add ThrowExceptionWhenMatcherFails option to all Matchers (#500)
* .

* ut

* IMatcher.ThrowException

* settings

* more tests

* linq matcher throw

* .

* .
2020-08-13 08:58:18 +02:00

38 lines
1.2 KiB
C#

using System;
using HandlebarsDotNet;
using WireMock.Handlers;
namespace WireMock.Transformers
{
internal class HandlebarsContextFactory : IHandlebarsContextFactory
{
private static readonly HandlebarsConfiguration HandlebarsConfiguration = new HandlebarsConfiguration
{
UnresolvedBindingFormatter = "{0}"
};
private readonly IFileSystemHandler _fileSystemHandler;
private readonly Action<IHandlebars, IFileSystemHandler> _action;
public HandlebarsContextFactory(IFileSystemHandler fileSystemHandler, Action<IHandlebars, IFileSystemHandler> action)
{
_fileSystemHandler = fileSystemHandler;
_action = action;
}
public IHandlebarsContext Create()
{
var handlebars = Handlebars.Create(HandlebarsConfiguration);
WireMockHandlebarsHelpers.Register(handlebars, _fileSystemHandler);
_action?.Invoke(handlebars, _fileSystemHandler);
return new HandlebarsContext
{
Handlebars = handlebars,
FileSystemHandler = _fileSystemHandler
};
}
}
}