Small refactor on Template logic

This commit is contained in:
Stef Heyenrath
2022-01-06 21:25:15 +01:00
parent 0f1a4f32ef
commit 60bdc06d29
3 changed files with 8 additions and 10 deletions

View File

@@ -1,6 +1,7 @@
using System; using System;
using HandlebarsDotNet; using HandlebarsDotNet;
using JetBrains.Annotations; using JetBrains.Annotations;
using Stef.Validation;
using WireMock.Handlers; using WireMock.Handlers;
namespace WireMock.Transformers.Handlebars namespace WireMock.Transformers.Handlebars
@@ -12,7 +13,7 @@ namespace WireMock.Transformers.Handlebars
public HandlebarsContextFactory([NotNull] IFileSystemHandler fileSystemHandler, [CanBeNull] Action<IHandlebars, IFileSystemHandler> action) public HandlebarsContextFactory([NotNull] IFileSystemHandler fileSystemHandler, [CanBeNull] Action<IHandlebars, IFileSystemHandler> action)
{ {
_fileSystemHandler = fileSystemHandler ?? throw new ArgumentNullException(nameof(fileSystemHandler)); _fileSystemHandler = Guard.NotNull(fileSystemHandler);
_action = action; _action = action;
} }

View File

@@ -1,5 +1,5 @@
using System;
using Scriban; using Scriban;
using Stef.Validation;
using WireMock.Handlers; using WireMock.Handlers;
using WireMock.Types; using WireMock.Types;
@@ -13,7 +13,7 @@ namespace WireMock.Transformers.Scriban
public ScribanContext(IFileSystemHandler fileSystemHandler, TransformerType transformerType) public ScribanContext(IFileSystemHandler fileSystemHandler, TransformerType transformerType)
{ {
FileSystemHandler = fileSystemHandler ?? throw new ArgumentNullException(nameof(fileSystemHandler)); FileSystemHandler = Guard.NotNull(fileSystemHandler);
_transformerType = transformerType; _transformerType = transformerType;
} }

View File

@@ -1,4 +1,4 @@
using WireMock.Handlers; using WireMock.Handlers;
using WireMock.Types; using WireMock.Types;
using Stef.Validation; using Stef.Validation;
@@ -11,11 +11,8 @@ namespace WireMock.Transformers.Scriban
public ScribanContextFactory(IFileSystemHandler fileSystemHandler, TransformerType transformerType) public ScribanContextFactory(IFileSystemHandler fileSystemHandler, TransformerType transformerType)
{ {
Guard.NotNull(fileSystemHandler, nameof(fileSystemHandler)); _fileSystemHandler = Guard.NotNull(fileSystemHandler);
Guard.Condition(transformerType, t => t == TransformerType.Scriban || t == TransformerType.ScribanDotLiquid, nameof(transformerType)); _transformerType = Guard.Condition(transformerType, t => t == TransformerType.Scriban || t == TransformerType.ScribanDotLiquid);
_fileSystemHandler = fileSystemHandler;
_transformerType = transformerType;
} }
public ITransformerContext Create() public ITransformerContext Create()