mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-21 00:11:44 +02:00
Update Transformer functionality to return value instead of string (#858)
This commit is contained in:
@@ -1,52 +1,59 @@
|
||||
using System;
|
||||
using FluentAssertions;
|
||||
using HandlebarsDotNet;
|
||||
using Moq;
|
||||
using WireMock.Handlers;
|
||||
using WireMock.Settings;
|
||||
using WireMock.Transformers.Handlebars;
|
||||
using Xunit;
|
||||
|
||||
namespace WireMock.Net.Tests.Transformers.Handlebars
|
||||
namespace WireMock.Net.Tests.Transformers.Handlebars;
|
||||
|
||||
public class HandlebarsContextFactoryTests
|
||||
{
|
||||
public class HandlebarsContextFactoryTests
|
||||
private readonly Mock<IFileSystemHandler> _fileSystemHandlerMock = new();
|
||||
|
||||
[Fact]
|
||||
public void Create_WithNullAction_DoesNotInvokeAction()
|
||||
{
|
||||
private readonly Mock<IFileSystemHandler> _fileSystemHandlerMock = new Mock<IFileSystemHandler>();
|
||||
|
||||
[Fact]
|
||||
public void Create_WithNullAction_DoesNotInvokeAction()
|
||||
// Arrange
|
||||
var settings = new WireMockServerSettings
|
||||
{
|
||||
// Arrange
|
||||
var sut = new HandlebarsContextFactory(_fileSystemHandlerMock.Object, null);
|
||||
FileSystemHandler = _fileSystemHandlerMock.Object
|
||||
};
|
||||
var sut = new HandlebarsContextFactory(settings);
|
||||
|
||||
// Act
|
||||
var result = sut.Create();
|
||||
// Act
|
||||
var result = sut.Create();
|
||||
|
||||
// Assert
|
||||
result.Should().NotBeNull();
|
||||
}
|
||||
// Assert
|
||||
result.Should().NotBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Create_WithAction_InvokesAction()
|
||||
[Fact]
|
||||
public void Create_WithAction_InvokesAction()
|
||||
{
|
||||
// Arrange
|
||||
int num = 0;
|
||||
var settings = new WireMockServerSettings
|
||||
{
|
||||
// Arrange
|
||||
int num = 0;
|
||||
Action<IHandlebars, IFileSystemHandler> action = (ctx, fs) =>
|
||||
FileSystemHandler = _fileSystemHandlerMock.Object,
|
||||
HandlebarsRegistrationCallback = (ctx, fs) =>
|
||||
{
|
||||
ctx.Should().NotBeNull();
|
||||
fs.Should().NotBeNull();
|
||||
|
||||
num++;
|
||||
};
|
||||
var sut = new HandlebarsContextFactory(_fileSystemHandlerMock.Object, action);
|
||||
}
|
||||
};
|
||||
|
||||
// Act
|
||||
var result = sut.Create();
|
||||
var sut = new HandlebarsContextFactory(settings);
|
||||
|
||||
// Assert
|
||||
result.Should().NotBeNull();
|
||||
// Act
|
||||
var result = sut.Create();
|
||||
|
||||
// Verify
|
||||
num.Should().Be(1);
|
||||
}
|
||||
// Assert
|
||||
result.Should().NotBeNull();
|
||||
|
||||
// Verify
|
||||
num.Should().Be(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user