public void Files_In_Project_Template_Should_Match_Manifest() { // Arrange var config = new InitializrConfig { ProjectTemplates = new[] { new ProjectTemplateConfiguration { Uri = new Uri("pt:///izr"), }, }, }; var registry = new TemplateRegistryBuilder().WithConfig(config).Build(); // Act var template = registry.Lookup(new ProjectSpec()); // Assert Assert.NotNull(template); var fileEntries = template.Manifest.ToList(); fileEntries.Count().Should().Be(3); fileEntries[0].Path.Should().Be("f1"); fileEntries[0].Text.Should().Be("my file f1"); fileEntries[0].Rename.Should().BeNull(); fileEntries[1].Path.Should().Be("d1/"); fileEntries[1].Text.Should().BeNull(); fileEntries[1].Rename.Should().BeNull(); fileEntries[2].Path.Should().Be("r1"); fileEntries[2].Text.Should().Be("my file r1->n1"); fileEntries[2].Rename.Should().Be("n1"); }
public void Invalid_Version_Should_Log_An_Error() { // Arrange var config = new InitializrConfig { ProjectTemplates = new[] { new ProjectTemplateConfiguration { Uri = new Uri("pt:///izr?steeltoeVersionRange=1.0"), }, }, }; var logger = new Mock <ILogger <ProjectTemplateRegistry> >(); var registry = new TemplateRegistryBuilder().WithConfig(config).WithLogger(logger.Object).Build(); var spec = new ProjectSpec { SteeltoeVersion = "1..1" }; // Act var template = registry.Lookup(spec); // Assert template.Should().BeNull(); logger.VerifyLog(LogLevel.Error, "Error looking up project template: Version not in correct format: '1..1'"); }
public void Initialize_Should_Reset_State() { // Arrange var config = new InitializrConfig { ProjectTemplates = new[] { new ProjectTemplateConfiguration { Uri = new Uri("pt:///izr"), }, }, }; var registry = new TemplateRegistryBuilder().WithConfig(config).Build(); // Act var template = registry.Lookup(new ProjectSpec()); // Assert template.Should().NotBeNull(); // Arrange config.ProjectTemplates = new ProjectTemplateConfiguration[0]; // Act registry.Initialize(); template = registry.Lookup(new ProjectSpec()); // Assert template.Should().BeNull(); }
public void Lookup_Should_Find_Match() { // Arrange var config = new InitializrConfig { ProjectTemplates = new[] { new ProjectTemplateConfiguration { Uri = new Uri( "pt:///izr?description=pt1&steeltoeVersionRange=st2.0&dotNetFrameworkRange=df1.0&dotNetTemplate=dt1&language=l1"), }, new ProjectTemplateConfiguration { Uri = new Uri( "pt:///izr?description=pt2&steeltoeVersionRange=st1.0&dotNetFrameworkRange=df1.0&dotNetTemplate=dt1&language=l1"), }, }, }; var registry = new TemplateRegistryBuilder().WithConfig(config).Build(); // Act var template = registry.Lookup(new ProjectSpec { SteeltoeVersion = "st2.0", DotNetFramework = "df1.0", DotNetTemplate = "dt1", Language = "l1" }); // Assert Assert.NotNull(template); template.Description.Should().Be("pt1"); // Act template = registry.Lookup(new ProjectSpec { SteeltoeVersion = "st1.0", DotNetFramework = "df1.0", DotNetTemplate = "dt1", Language = "l1" }); // Assert Assert.NotNull(template); template.Description.Should().Be("pt2"); }