public void Render_should_invoke_NHaml()
        {
            // Given, When
            var template = engine.RenderView(GetDummyViewLocationResult(), null, this.renderContext);

            template.Contents.Invoke(new MemoryStream());

            //Then
            A.CallTo(() => nHamlEngine.GetCompiledTemplate(A <ViewSource> .Ignored, A <Type> .Ignored))
            .MustHaveHappened();
        }
        public NHamlViewEngineFixture()
        {
            nHamlEngine = A.Fake<ITemplateEngine>();
            engine = new NHamlViewEngine(nHamlEngine);

            A.CallTo(() => nHamlEngine.GetCompiledTemplate(A<ViewSource>.Ignored, A<Type>.Ignored))
                .Returns(new TemplateFactory(typeof(DummyNHamlTemplate)));

            var cache = A.Fake<IViewCache>();
            A.CallTo(() => cache.GetOrAdd(A<ViewLocationResult>.Ignored, A<Func<ViewLocationResult, TemplateFactory>>.Ignored))
                .ReturnsLazily(x =>
                {
                    var result = x.GetArgument<ViewLocationResult>(0);
                    return x.GetArgument<Func<ViewLocationResult, TemplateFactory>>(1).Invoke(result);
                });

            this.renderContext = A.Fake<IRenderContext>();
            A.CallTo(() => this.renderContext.ViewCache).Returns(cache);
        }
        public NHamlViewEngineFixture()
        {
            nHamlEngine = A.Fake <ITemplateEngine>();
            engine      = new NHamlViewEngine(nHamlEngine);

            A.CallTo(() => nHamlEngine.GetCompiledTemplate(A <ViewSource> .Ignored, A <Type> .Ignored))
            .Returns(new TemplateFactory(typeof(DummyNHamlTemplate)));

            var cache = A.Fake <IViewCache>();

            A.CallTo(() => cache.GetOrAdd(A <ViewLocationResult> .Ignored, A <Func <ViewLocationResult, TemplateFactory> > .Ignored))
            .ReturnsLazily(x =>
            {
                var result = x.GetArgument <ViewLocationResult>(0);
                return(x.GetArgument <Func <ViewLocationResult, TemplateFactory> >(1).Invoke(result));
            });

            this.renderContext = A.Fake <IRenderContext>();
            A.CallTo(() => this.renderContext.ViewCache).Returns(cache);
        }
Пример #4
0
        private TemplateFactory GetTemplateFactory(ViewLocationResult viewLocationResult)
        {
            var view = new NancyNHamlView(viewLocationResult);

            return(_templateEngine.GetCompiledTemplate(view, typeof(NancyNHamlTemplateBase)));
        }