public void SetUp()
 {
     _templateFactoryFactory = new TemplateFactoryFactory(
         new FileTemplateContentProvider(),
         new HamlTreeParser(new HamlFileLexer()),
         new HamlDocumentWalker(new CodeDomClassBuilder()),
         new CodeDomTemplateCompiler(new CSharp2TemplateTypeBuilder()),
         new List<string>(),
         new List<string>());
 }
 public void SetUp()
 {
     var templateFactoryFactory = new TemplateFactoryFactory(
         new FileTemplateContentProvider(),
         new ViewSourceParser(new HamlFileLexer(), new HamlTreeParser()),
         new HamlDocumentWalker(new CodeDomClassBuilder()),
         new CodeDomTemplateCompiler(new CSharp2TemplateTypeBuilder()),
         new List<string>(),
         new List<string>());
     _templateEngine = new TemplateEngine(new SimpleTemplateCache(), templateFactoryFactory);
 }
Esempio n. 3
0
        public void CompileTemplateFactory_CallsTreeParser()
        {
            // Arrange
            var fakeHamlSource = ViewSourceBuilder.Create();

            // Act
            var compiledTemplate = new TemplateFactoryFactory(_templateContentProviderMock.Object, _parserMock.Object,
                _documentWalkerMock.Object, _compilerMock.Object, new List<string>(), new List<string>());
            compiledTemplate.CompileTemplateFactory("className", fakeHamlSource);

            // Assert
            _parserMock.Verify(x => x.ParseViewSource(fakeHamlSource));
        }
Esempio n. 4
0
        public void CompileTemplateFactory_CallsCompile()
        {
            // Arrange
            const string fakeTemplateSource = "FakeTemplateSource";
            _documentWalkerMock.Setup(x => x.Walk(It.IsAny<HamlDocument>(), It.IsAny<string>(),
                It.IsAny<Type>(), It.IsAny<IList<string>>()))
                .Returns(fakeTemplateSource);
            var viewSource = ViewSourceBuilder.Create();
            var assemblies = new List<string>();

            // Act
            var compiledTemplate = new TemplateFactoryFactory(_contentProviderMock.Object, _viewSourceParserMock.Object,
                _documentWalkerMock.Object, _compilerMock.Object, new List<string>(), assemblies);
            compiledTemplate.CompileTemplateFactory(viewSource.GetClassName(), viewSource);

            // Assert
            _compilerMock.Verify(x => x.Compile(fakeTemplateSource, viewSource.GetClassName(), assemblies));
        }
Esempio n. 5
0
        public void CompileTemplateFactory_CallsDocumentWalker()
        {
            // Arrange
            const string className = "className";
            var baseType = typeof(Template);

            var fakeHamlDocument = HamlDocumentBuilder.Create("");
            _viewSourceParserMock.Setup(x => x.Parse(It.IsAny<ViewSource>()))
                .Returns(fakeHamlDocument);
            var viewSource = ViewSourceBuilder.Create();
            var imports = new List<string>();

            // Act
            var compiledTemplate = new TemplateFactoryFactory(_contentProviderMock.Object, _viewSourceParserMock.Object,
                _documentWalkerMock.Object, _compilerMock.Object, new List<string>(), imports);
            compiledTemplate.CompileTemplateFactory(className, new ViewSourceCollection { viewSource }, baseType);

            // Assert
            _documentWalkerMock.Verify(x => x.Walk(fakeHamlDocument, className, baseType, imports));
        }
 public void Setup()
 {
     _viewSourceParserMock = new Mock<IViewSourceParser>();
     _documentWalkerMock = new Mock<IDocumentWalker>();
     _templateCompilerMock = new Mock<ITemplateFactoryCompiler>();
     _templateContentProviderMock = new Mock<ITemplateContentProvider>();
     _templateFactoryFactory = new TemplateFactoryFactory(
         _templateContentProviderMock.Object,
         _viewSourceParserMock.Object,
         _documentWalkerMock.Object,
         _templateCompilerMock.Object,
         new List<string>(),
         new List<string>());
 }