public async Task EvaluateAsyncShouldReturnNullWhenExpressionIsEmpty([Frozen] ILiquidTemplateManager liquidTemplateManager, LiquidHandler sut, string expression, [StubActivityExecutionContext] ActivityExecutionContext context, Type returnType) { Mock.Get(liquidTemplateManager) .Setup(x => x.RenderAsync(expression, It.IsAny <TemplateContext>(), HtmlEncoder.Default)) .Returns(() => Task.FromResult(String.Empty)); var result = await sut.EvaluateAsync(expression, returnType, context, default); Assert.Null(result); }
public async Task EvaluateAsyncShouldConvertToDateTimeWhenThatIsDesiredReturnType([Frozen] ILiquidTemplateManager liquidTemplateManager, LiquidHandler sut, string expression, [StubActivityExecutionContext] ActivityExecutionContext context) { Mock.Get(liquidTemplateManager) .Setup(x => x.RenderAsync(expression, It.IsAny <TemplateContext>(), HtmlEncoder.Default)) .Returns(() => Task.FromResult("2001-03-04T12:45:32Z")); var result = await sut.EvaluateAsync(expression, typeof(DateTime), context, default); Assert.Equal(new DateTime(2001, 03, 04, 12, 45, 32, DateTimeKind.Utc), result); }
public async Task EvaluateAsyncShouldReturnExpressionResultWhenReturnTypeIsObject([Frozen] ILiquidTemplateManager liquidTemplateManager, LiquidHandler sut, string expression, string expectedResult, [StubActivityExecutionContext] ActivityExecutionContext context) { Mock.Get(liquidTemplateManager) .Setup(x => x.RenderAsync(expression, It.IsAny <TemplateContext>(), HtmlEncoder.Default)) .Returns(() => Task.FromResult(expectedResult)); var result = await sut.EvaluateAsync(expression, typeof(object), context, default); Assert.Equal(expectedResult, result); }