예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }