Ejemplo n.º 1
0
 public TemplateProcessor(
     IGeneratorProvider generatorProvider,
     ITemplateWriter templateWriter,
     ITemplateSetProvider templateSetProvider,
     ITemplateContextProvider templateContextProvider)
 {
     _templateWriter          = Preconditions.ThrowIfNull(templateWriter, nameof(templateWriter));
     _templateSetProvider     = Preconditions.ThrowIfNull(templateSetProvider, nameof(templateSetProvider));
     _templateContextProvider = Preconditions.ThrowIfNull(templateContextProvider, nameof(templateContextProvider));
     _generatorProvider       = Preconditions.ThrowIfNull(generatorProvider, nameof(generatorProvider));
 }
Ejemplo n.º 2
0
            protected override void Arrange()
            {
                _assemblyData = new AssemblyData
                {
                    AssemblyName = "testAssembly",
                    Path         = "testFolder",
                    TemplateSet  = "standard"
                };

                _templateSet = new TemplateSet
                {
                    Name       = "Entities.mustache", Driver = "Entities",
                    OutputPath = "Models\\Entities\\Entities.generated.cs"
                };

                var templates = new List <TemplateSet> {
                    _templateSet
                };

                var model = new object();

                _templateContext = new TemplateContext();

                _templateWriter          = Stub <ITemplateWriter>();
                _codeRepositoryProvider  = Stub <ICodeRepositoryProvider>();
                _templateSetProvider     = Stub <ITemplateSetProvider>();
                _templateContextProvider = Stub <ITemplateContextProvider>();
                _generator         = Stub <IGenerator>();
                _generatorProvider = Stub <IGeneratorProvider>();

                A.CallTo(() => _codeRepositoryProvider.GetResolvedCodeRepositoryByName(A <string> ._, A <string> ._))
                .Returns("testRepo\\testFolder");

                A.CallTo(() => _templateSetProvider.GetTemplatesByName(A <string> ._))
                .Returns(templates);

                A.CallTo(() => _templateContextProvider.Create(A <AssemblyData> ._))
                .Returns(_templateContext);

                A.CallTo(() => _generator.Generate(A <TemplateContext> ._))
                .Returns(model);

                A.CallTo(() => _generatorProvider.GetGeneratorByDriverName(A <string> ._))
                .Returns(_generator);

                _templateProcessor = new TemplateProcessor(
                    _generatorProvider,
                    _templateWriter,
                    _templateSetProvider,
                    _templateContextProvider);
            }