private string GetContentFromPersistedTemplate(TemplateConfigurator config) { var templateRes = string.Empty; using (var reader = new StreamReader(config.Persistence.OutputTemplatePath)) { templateRes = reader.ReadToEnd(); } templateRes.Should().NotBeNullOrEmpty().And.NotBeBlank(); return templateRes; }
/// <summary> /// Processes the template. /// </summary> /// <param name="embeddedResourceName">Name of the embedded resource.</param> /// <param name="resourceNamespace">The resource namespace.</param> /// <param name="processingTemplate">The processing template delegate.</param> /// <returns> /// The TemplateConfigurator object used to process the template /// </returns> public TemplateConfigurator ProcessTemplate(string embeddedResourceName, string resourceNamespace, Action<Template, CommandLineOptions, string> processingTemplate) { Condition.Requires(embeddedResourceName, "embeddedResourceName").IsNotNullOrWhiteSpace(); Condition.Requires(processingTemplate, "processingTemplate").IsNotNull(); Condition.Requires(this.AreArgumentsValid()) .IsTrue("The command line arguments must be valid before calling the ProcessTemplate method"); var configurator = new TemplateConfigurator(); configurator .Factory .Find .From .Assembly .Using .CurrentAssembly() .FindEmbeddedResource(embeddedResourceName, resourceNamespace) .Context .Establish .Options(this.options) .Processor .CurrentTemplate .Prepare() .Process(processingTemplate) .Persistence .CurrentTemplate .SetDestinationFile() .Commit(); return configurator; }
public void can_navigate_from_the_root_configurator_object_to_the_TemplateProcessor_CurrentTemplate_member() { var tmpCfg = new TemplateConfigurator(); tmpCfg.Processor.CurrentTemplate.Should().NotBeNull(); }
private TemplateConfigurator CreateConfiguration(string resourceNamespace = "NCastor.AutoBuilder.Console.Templates") { var cfg = new TemplateConfigurator(); var ser = new Mock<IAssemblyResourceFinder>(); var res = TemplateConstants.Solution; var namespacePrefix = resourceNamespace; var templateBody = "hello '{{ " + TemplateTokenConstants.FileName + " }}' world!"; var stream = new MemoryStream(ASCIIEncoding.Default.GetBytes(templateBody)); var opt = new CommandLineOptions { ProductName = "My Prod Name", OutputPath = "." }; ser.SetupAllProperties(); ser.Setup(x => x.FindResource<Stream>(It.IsAny<string>())) .Returns(stream); cfg .Factory .Find.From.Assembly.Using.CurrentAssembly() .FindEmbeddedResource(ser.Object, res, namespacePrefix) .Context .Establish .Options(opt); return cfg; }
public void can_navigate_from_the_root_configurator_object_to_the_TemplateContext_Establish_member() { var tmpCfg = new TemplateConfigurator(); tmpCfg.Context.Establish.Should().NotBeNull(); }
public void can_navigate_from_the_root_configurator_object_to_the_TemplateFactory_Using_member() { var tmpCfg = new TemplateConfigurator(); tmpCfg.Factory.Using.Should().NotBeNull(); }
public void can_navigate_from_TemplateConfigurator_to_the_TemplateProcessor_object() { var tmpCfg = new TemplateConfigurator(); tmpCfg.Processor.Should().NotBeNull(); }
public void can_navigate_from_TemplateConfigurator_to_the_TemplatePersistence_object() { var tmpCfg = new TemplateConfigurator(); tmpCfg.Persistence.Should().NotBeNull(); }
public void can_navigate_from_Templateconfigurator_to_the_TemplateContext_object() { var tmpCfg = new TemplateConfigurator(); tmpCfg.Context.Should().NotBeNull(); }
public void can_create_a_new_TemplateConfigurator_instance() { var templConfig = new TemplateConfigurator(); templConfig.Should().NotBeNull(); }
public void can_navigate_from_the_TemplateConfigurator_to_the_TemplateFactory_object() { var tempConfig = new TemplateConfigurator(); tempConfig.Factory.Should().NotBeNull(); }