This commit is contained in:
Chris Cheetham 2020-08-14 11:51:56 -04:00
Родитель 394fb220d0
Коммит 80e1748ec3
16 изменённых файлов: 209 добавлений и 111 удалений

Просмотреть файл

@ -21,7 +21,7 @@ namespace Steeltoe.Initializr.TemplateEngine.Models
public class GeneratorModel
{
private string _projectName;
private DotnetTemplateVersion? _templateVersion;
private DotnetFramework? _templateVersion;
public string Dependencies { get; set; }
@ -43,13 +43,13 @@ namespace Steeltoe.Initializr.TemplateEngine.Models
return string.IsNullOrEmpty(Dependencies) ? null : Dependencies.ToLower().Split(',');
}
public DotnetTemplateVersion TemplateVersion
public DotnetFramework Framework
{
get
{
if (_templateVersion == null)
{
return TargetFrameworkVersion == "netcoreapp3.1" ? DotnetTemplateVersion.V3 : DotnetTemplateVersion.V2;
return TargetFrameworkVersion == "netcoreapp3.1" ? DotnetFramework.NetCoreApp31 : DotnetFramework.NetCoreApp21;
}
return _templateVersion.Value;

Просмотреть файл

@ -28,6 +28,6 @@ namespace Steeltoe.Initializr.TemplateEngine.Models
public string Tags { get; set; }
public DotnetTemplateVersion DotnetTemplateVersion { get; set; }
public DotnetFramework DotnetFramework { get; set; }
}
}

Просмотреть файл

@ -133,7 +133,7 @@ namespace Steeltoe.Initializr.TemplateEngine.Services.DotNetTemplateEngine
var templateShortName = string.IsNullOrEmpty(model.TemplateShortName) ? DEFAULT_TEMPLATE : model.TemplateShortName;
TemplateInfo templateInfo = FindTemplateByShortName(templateShortName, model.TemplateVersion, EnvSettings);
TemplateInfo templateInfo = FindTemplateByShortName(templateShortName, model.Framework, EnvSettings);
if (templateInfo == null)
{
throw new Exception($"Could not find template with shortName: {templateShortName} ");
@ -192,20 +192,20 @@ namespace Steeltoe.Initializr.TemplateEngine.Services.DotNetTemplateEngine
{
Name = x.Name,
ShortName = x.ShortName,
DotnetTemplateVersion = x.Identity.EndsWith("2.0") ? DotnetTemplateVersion.V2 : DotnetTemplateVersion.V3,
DotnetFramework = x.Identity.EndsWith("2.0") ? DotnetFramework.NetCoreApp21 : DotnetFramework.NetCoreApp31,
Language = x.Parameters?.FirstOrDefault(p => p.Name == "language")?.DefaultValue,
Tags = x.Classifications.Aggregate((current, next) => current + "/" + next),
});
return items.ToList();
}
public List<ProjectDependency> GetDependencies(string shortName, DotnetTemplateVersion dotnetTemplateVersion = DotnetTemplateVersion.V2)
public List<ProjectDependency> GetDependencies(string shortName, DotnetFramework dotnetFramework = DotnetFramework.NetCoreApp21)
{
var list = GetAllTemplates();
shortName = string.IsNullOrEmpty(shortName) ? DEFAULT_TEMPLATE : shortName;
var versionString = dotnetTemplateVersion == DotnetTemplateVersion.V2 ? "2.0" : "3.0";
var versionString = dotnetFramework == DotnetFramework.NetCoreApp21 ? "2.0" : "3.0";
var selectedTemplate = list.FirstOrDefault(x => x.ShortName == shortName && x.Identity.EndsWith(versionString));
if (selectedTemplate == null)
@ -253,10 +253,10 @@ namespace Steeltoe.Initializr.TemplateEngine.Services.DotNetTemplateEngine
return envSettings;
}
private TemplateInfo FindTemplateByShortName(string shortName, DotnetTemplateVersion version, IEngineEnvironmentSettings envSettings)
private TemplateInfo FindTemplateByShortName(string shortName, DotnetFramework version, IEngineEnvironmentSettings envSettings)
{
var loader = (InitializrSettingsLoader)envSettings.SettingsLoader;
var versionString = version == DotnetTemplateVersion.V2 ? "2.0" : "3.0";
var versionString = version == DotnetFramework.NetCoreApp21 ? "2.0" : "3.0";
return loader.UserTemplateCache
.TemplateInfo
.FirstOrDefault(ti => ti.ShortNameList.Contains(shortName) && ti.Identity.EndsWith(versionString));

Просмотреть файл

@ -14,9 +14,9 @@
namespace Steeltoe.Initializr.TemplateEngine.Services
{
public enum DotnetTemplateVersion
public enum DotnetFramework
{
V2,
V3,
NetCoreApp21,
NetCoreApp31,
}
}

Просмотреть файл

@ -26,7 +26,7 @@ namespace Steeltoe.Initializr.TemplateEngine.Services
List<TemplateViewModel> GetAvailableTemplates();
List<ProjectDependency> GetDependencies(string shortName = null, DotnetTemplateVersion dotnetTemplateVersion = DotnetTemplateVersion.V2);
List<ProjectDependency> GetDependencies(string shortName = null, DotnetFramework dotnetFramework = DotnetFramework.NetCoreApp21);
void ClearCache();
}

Просмотреть файл

@ -173,12 +173,12 @@ namespace Steeltoe.Initializr.TemplateEngine.Services.Mustache
private void LoadConfig(string templatePath)
{
var versions = (DotnetTemplateVersion[])Enum.GetValues(typeof(DotnetTemplateVersion));
var versions = (DotnetFramework[])Enum.GetValues(typeof(DotnetFramework));
foreach (var version in versions)
{
var versionString = version == DotnetTemplateVersion.V2 ? "netcoreapp2.1" : "netcoreapp3.1";
var path = templatePath + Path.DirectorySeparatorChar + versionString;
var versionString = version == DotnetFramework.NetCoreApp21 ? "netcoreapp2.1" : "netcoreapp3.1";
var path = Path.Join(templatePath, "2.4", versionString);
foreach (var dir in new DirectoryInfo(path).EnumerateDirectories())
{
var mustacheTemplateSetting = new MustacheTemplateSettings(_logger, dir.FullName);

Просмотреть файл

@ -35,7 +35,7 @@ namespace Steeltoe.Initializr.TemplateEngine.Services.Mustache
public class MustacheTemplateService : ITemplateService
{
private const string DefaultTemplateName = "Steeltoe-WebApi";
private const DotnetTemplateVersion DefaultVersion = DotnetTemplateVersion.V2;
private const DotnetFramework DefaultVersion = DotnetFramework.NetCoreApp21;
private Dictionary<string, string> FriendlyNames { get; set; }
@ -70,11 +70,11 @@ namespace Steeltoe.Initializr.TemplateEngine.Services.Mustache
{
var name = string.IsNullOrEmpty(model.TemplateShortName) ? DefaultTemplateName : model.TemplateShortName;
var templateKey = new TemplateKey(name, model.TemplateVersion);
var templateKey = new TemplateKey(name, model.Framework);
if (!_mustacheConfig.GetTemplateKeys().Contains(templateKey))
{
throw new InvalidDataException($"Template with Name: {name} and Version: {model.TemplateVersion} doesn't exist");
throw new InvalidDataException($"Template with Name: {name} and Version: {model.Framework} doesn't exist");
}
Dictionary<string, string> dataView;
@ -112,14 +112,14 @@ namespace Steeltoe.Initializr.TemplateEngine.Services.Mustache
{
Name = templateKey.Name,
ShortName = templateKey.Name,
DotnetTemplateVersion = templateKey.Version,
DotnetFramework = templateKey.Version,
Language = "C#",
Tags = "Web/Microservice",
})
.ToList();
}
public List<ProjectDependency> GetDependencies(string shortName, DotnetTemplateVersion version)
public List<ProjectDependency> GetDependencies(string shortName, DotnetFramework version)
{
shortName = string.IsNullOrEmpty(shortName) ? DefaultTemplateName : shortName;
var list = GetAvailableTemplates();

Просмотреть файл

@ -18,9 +18,9 @@ namespace Steeltoe.Initializr.TemplateEngine.Services.Mustache
{
public string Name { get; }
public DotnetTemplateVersion Version { get; }
public DotnetFramework Version { get; }
public TemplateKey(string name, DotnetTemplateVersion version)
public TemplateKey(string name, DotnetFramework version)
{
Name = name;
Version = version;

Просмотреть файл

@ -9,6 +9,99 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
</None>
<None Include="..\templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\Controllers\ValuesController.cs">
<Link>templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\Controllers\ValuesController.cs</Link>
</None>
<None Include="..\templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\Models\ConfigServerData.cs">
<Link>templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\Models\ConfigServerData.cs</Link>
</None>
<None Include="..\templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\Models\ErrorViewModel.cs">
<Link>templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\Models\ErrorViewModel.cs</Link>
</None>
<None Include="..\templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\Models\InitializeContext.cs">
<Link>templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\Models\InitializeContext.cs</Link>
</None>
<None Include="..\templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\Models\SampleData.cs">
<Link>templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\Models\SampleData.cs</Link>
</None>
<None Include="..\templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\Models\TestContext.cs">
<Link>templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\Models\TestContext.cs</Link>
</None>
<None Update="..\templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\Properties\launchSettings.json">
<Link>templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\Properties\launchSettings.json</Link>
</None>
<None Update="..\templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\.gitignore">
<Link>templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\.gitignore</Link>
</None>
<None Update="..\templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\app.config">
<Link>templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\app.config</Link>
</None>
<None Update="..\templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\appsettings.json">
<Link>templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\appsettings.json</Link>
</None>
<None Update="..\templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\Dockerfile">
<Link>templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\Dockerfile</Link>
</None>
<None Update="..\templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\mustache.json">
<Link>templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\mustache.json</Link>
</None>
<None Include="..\templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\MyCircuitBreakerCommand.cs">
<Link>templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\MyCircuitBreakerCommand.cs</Link>
</None>
<None Include="..\templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\Program.cs">
<Link>templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\Program.cs</Link>
</None>
<None Update="..\templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\ReplaceMe.csproj">
<Link>templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\ReplaceMe.csproj</Link>
</None>
<None Include="..\templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\Startup.cs">
<Link>templates\Mustache\2.4\netcoreapp2.1\Steeltoe-WebApi\Startup.cs</Link>
</None>
<None Include="..\templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\Controllers\ValuesController.cs">
<Link>templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\Controllers\ValuesController.cs</Link>
</None>
<None Include="..\templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\Models\ErrorViewModel.cs">
<Link>templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\Models\ErrorViewModel.cs</Link>
</None>
<None Include="..\templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\Models\InitializeContext.cs">
<Link>templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\Models\InitializeContext.cs</Link>
</None>
<None Include="..\templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\Models\SampleData.cs">
<Link>templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\Models\SampleData.cs</Link>
</None>
<None Include="..\templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\Models\TestContext.cs">
<Link>templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\Models\TestContext.cs</Link>
</None>
<None Update="..\templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\Properties\launchSettings.json">
<Link>templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\Properties\launchSettings.json</Link>
</None>
<None Update="..\templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\.gitignore">
<Link>templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\.gitignore</Link>
</None>
<None Update="..\templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\app.config">
<Link>templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\app.config</Link>
</None>
<None Update="..\templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\appsettings.json">
<Link>templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\appsettings.json</Link>
</None>
<None Update="..\templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\Dockerfile">
<Link>templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\Dockerfile</Link>
</None>
<None Update="..\templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\mustache.json">
<Link>templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\mustache.json</Link>
</None>
<None Include="..\templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\MyCircuitBreakerCommand.cs">
<Link>templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\MyCircuitBreakerCommand.cs</Link>
</None>
<None Include="..\templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\Program.cs">
<Link>templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\Program.cs</Link>
</None>
<None Update="..\templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\ReplaceMe.csproj">
<Link>templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\ReplaceMe.csproj</Link>
</None>
<None Include="..\templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\Startup.cs">
<Link>templates\Mustache\2.4\netcoreapp3.1\Steeltoe-WebApi\Startup.cs</Link>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="3.1.0" />
@ -20,4 +113,9 @@
<PackageReference Include="Stubble.Core" Version="1.2.7" />
<PackageReference Include="Stubble.Extensions.JsonNet" Version="1.0.18" />
</ItemGroup>
<ItemGroup>
<Folder Include="..\templates\Mustache\2.4">
<Link>templates\Mustache\2.4</Link>
</Folder>
</ItemGroup>
</Project>

Просмотреть файл

@ -74,7 +74,7 @@ Get project:
private string GetDependencies()
{
var result = new StringBuilder();
var dependencies = _templateService.GetDependencies(string.Empty, DotnetTemplateVersion.V3);
var dependencies = _templateService.GetDependencies(string.Empty, DotnetFramework.NetCoreApp31);
var fieldWidths = new int[] { 40, 100 };
result.Append("\nDependencies: \n");

Просмотреть файл

@ -53,9 +53,9 @@ namespace Steeltoe.Initializr.WebApp.Controllers
}
[Route("dependencies")]
public ActionResult GetDependencies([FromQuery(Name = "templateShortName")] string templateShortName, [FromQuery(Name = "templateVersion")] DotnetTemplateVersion? templateVersion)
public ActionResult GetDependencies([FromQuery(Name = "templateShortName")] string templateShortName, [FromQuery(Name = "templateVersion")] DotnetFramework? templateVersion)
{
return Ok(_sttemplateService.GetDependencies(templateShortName, templateVersion ?? DotnetTemplateVersion.V2));
return Ok(_sttemplateService.GetDependencies(templateShortName, templateVersion ?? DotnetFramework.NetCoreApp21));
}
[Route("templates")]

Просмотреть файл

@ -43,7 +43,7 @@ namespace Steeltoe.Initializr.TemplateEngine.Test
// "Steeltoe-React",
"Steeltoe-WebApi",
};
var templateVersions = (DotnetTemplateVersion[])Enum.GetValues(typeof(DotnetTemplateVersion));
var templateVersions = (DotnetFramework[])Enum.GetValues(typeof(DotnetFramework));
var data = from implementation in implementations
from templateName in templateNames
select new object[] { implementation, templateName };

Просмотреть файл

@ -43,7 +43,7 @@ namespace Steeltoe.Initializr.TemplateEngine.Test
// "Steeltoe-React",
"Steeltoe-WebApi",
};
var templateVersions = (DotnetTemplateVersion[])Enum.GetValues(typeof(DotnetTemplateVersion));
var templateVersions = (DotnetFramework[])Enum.GetValues(typeof(DotnetFramework));
var data = from implementation in implementations
from templateName in templateNames
from templateVersion in templateVersions

Просмотреть файл

@ -47,7 +47,7 @@ namespace Steeltoe.Initializr.TemplateEngine.Test.IntegrationTests
_loggerFactory = new LoggerFactory();
}
public static IEnumerable<object[]> GetAllCombinations(Type templateServiceType, string templateName, DotnetTemplateVersion version, int take)
public static IEnumerable<object[]> GetAllCombinations(Type templateServiceType, string templateName, DotnetFramework version, int take)
{
ITemplateService templateService;
if (templateServiceType == typeof(MustacheTemplateService))
@ -70,16 +70,16 @@ namespace Steeltoe.Initializr.TemplateEngine.Test.IntegrationTests
}
[Theory]
[MemberData(nameof(GetAllCombinations), typeof(MustacheTemplateService), "Steeltoe-WebApi", DotnetTemplateVersion.V2, 1, DisableDiscoveryEnumeration = true)]
public async Task CreateTemplate_Mustache_WebApi_V2_OneAtaTime_Test(ITemplateService templateService, string templateName, DotnetTemplateVersion version, string depString)
[MemberData(nameof(GetAllCombinations), typeof(MustacheTemplateService), "Steeltoe-WebApi", DotnetFramework.NetCoreApp21, 1, DisableDiscoveryEnumeration = true)]
public async Task CreateTemplate_Mustache_WebApi_V2_OneAtaTime_Test(ITemplateService templateService, string templateName, DotnetFramework version, string depString)
{
_testOutputHelper.WriteLine(depString);
await CreateTemplate_Test(templateService, templateName, version, depString);
}
[Theory]
[MemberData(nameof(GetAllCombinations), typeof(MustacheTemplateService), "Steeltoe-WebApi", DotnetTemplateVersion.V2, int.MaxValue, DisableDiscoveryEnumeration = true)]
public async Task CreateTemplate_Mustache_WebApi_V2_All_Test(ITemplateService templateService, string templateName, DotnetTemplateVersion version, string depString)
[MemberData(nameof(GetAllCombinations), typeof(MustacheTemplateService), "Steeltoe-WebApi", DotnetFramework.NetCoreApp21, int.MaxValue, DisableDiscoveryEnumeration = true)]
public async Task CreateTemplate_Mustache_WebApi_V2_All_Test(ITemplateService templateService, string templateName, DotnetFramework version, string depString)
{
_testOutputHelper.WriteLine(depString);
await CreateTemplate_Test(templateService, templateName, version, depString);
@ -185,7 +185,7 @@ namespace Steeltoe.Initializr.TemplateEngine.Test.IntegrationTests
}
*/
private async Task CreateTemplate_Test(ITemplateService service, string template, DotnetTemplateVersion dotnet, string dependency, string steeltoe = "2.4.4")
private async Task CreateTemplate_Test(ITemplateService service, string template, DotnetFramework dotnet, string dependency, string steeltoe = "2.4.4")
{
_testOutputHelper.WriteLine($"testing Steeltoe {steeltoe} with {dependency}");
@ -194,7 +194,7 @@ namespace Steeltoe.Initializr.TemplateEngine.Test.IntegrationTests
Dependencies = dependency,
TemplateShortName = template,
ProjectName = "Foo.Bar",
TemplateVersion = dotnet,
Framework = dotnet,
SteeltoeVersion = steeltoe,
});

Просмотреть файл

@ -43,17 +43,17 @@ namespace Steeltoe.Initializr.TemplateEngine.Test
Assert.NotNull(templates);
Assert.NotEmpty(templates);
Assert.Contains(templates, x => x.ShortName == "Steeltoe-WebApi" && x.DotnetTemplateVersion == DotnetTemplateVersion.V2);
Assert.Contains(templates, x => x.ShortName == "Steeltoe-WebApi" && x.DotnetTemplateVersion == DotnetTemplateVersion.V3);
Assert.Contains(templates, x => x.ShortName == "Steeltoe-React" && x.DotnetTemplateVersion == DotnetTemplateVersion.V2);
Assert.Contains(templates, x => x.ShortName == "Steeltoe-React" && x.DotnetTemplateVersion == DotnetTemplateVersion.V3);
Assert.Contains(templates, x => x.ShortName == "Steeltoe-WebApi" && x.DotnetFramework == DotnetFramework.NetCoreApp21);
Assert.Contains(templates, x => x.ShortName == "Steeltoe-WebApi" && x.DotnetFramework == DotnetFramework.NetCoreApp31);
Assert.Contains(templates, x => x.ShortName == "Steeltoe-React" && x.DotnetFramework == DotnetFramework.NetCoreApp21);
Assert.Contains(templates, x => x.ShortName == "Steeltoe-React" && x.DotnetFramework == DotnetFramework.NetCoreApp31);
}
[Theory]
[ClassData(typeof(AllImplementationsAndTemplates))]
public void GetDependencies(ITemplateService templateService, string templateName, DotnetTemplateVersion dotnetTemplateVersion)
public void GetDependencies(ITemplateService templateService, string templateName, DotnetFramework dotnetFramework)
{
var deps = templateService.GetDependencies(templateName, dotnetTemplateVersion);
var deps = templateService.GetDependencies(templateName, dotnetFramework);
Assert.NotNull(deps);
Assert.NotEmpty(deps);
@ -62,9 +62,9 @@ namespace Steeltoe.Initializr.TemplateEngine.Test
[Theory]
[ClassData(typeof(AllImplementationsAndTemplates))]
public void GetDependencies_WithFriendlyNames(ITemplateService templateService, string templateName, DotnetTemplateVersion dotnetTemplateVersion)
public void GetDependencies_WithFriendlyNames(ITemplateService templateService, string templateName, DotnetFramework dotnetFramework)
{
var deps = templateService.GetDependencies(templateName, dotnetTemplateVersion);
var deps = templateService.GetDependencies(templateName, dotnetFramework);
Assert.NotNull(deps);
Assert.NotEmpty(deps);
@ -74,20 +74,20 @@ namespace Steeltoe.Initializr.TemplateEngine.Test
[Theory]
[ClassData(typeof(AllImplementationsAndTemplates))]
public async Task CreateTemplate_actuators(ITemplateService templateService, string templateName, DotnetTemplateVersion version)
public async Task CreateTemplate_actuators(ITemplateService templateService, string templateName, DotnetFramework version)
{
var files = await templateService.GenerateProjectFiles(new GeneratorModel()
{
Dependencies = "Actuators",
ProjectName = "testProject",
TemplateShortName = templateName,
TemplateVersion = version,
Framework = version,
});
string startUpContents = files.Find(x => x.Key == "Startup.cs").Value;
Assert.Contains("using Steeltoe.Management.CloudFoundry;", startUpContents);
if (!version.Equals(DotnetTemplateVersion.V3))
if (!version.Equals(DotnetFramework.NetCoreApp31))
{
Assert.Contains("using Steeltoe.Management.Endpoint;", startUpContents);
Assert.Contains("using Steeltoe.Management.Hypermedia;", startUpContents);
@ -97,13 +97,13 @@ namespace Steeltoe.Initializr.TemplateEngine.Test
[Theory]
[ClassData(typeof(AllImplementationsAndTemplates))]
public async Task CreateTemplate_react(ITemplateService templateService, string templateName, DotnetTemplateVersion version)
public async Task CreateTemplate_react(ITemplateService templateService, string templateName, DotnetFramework version)
{
var files = await templateService.GenerateProjectFiles(new GeneratorModel()
{
ProjectName = "testProject",
TemplateShortName = templateName,
TemplateVersion = version,
Framework = version,
});
var startUpContents = files.Find(x => x.Key == "Startup.cs").Value;
@ -112,13 +112,13 @@ namespace Steeltoe.Initializr.TemplateEngine.Test
[Theory]
[ClassData(typeof(AllImplementationsAndTemplates))]
public async Task CreateTemplate_discovery(ITemplateService templateService, string templateName, DotnetTemplateVersion version)
public async Task CreateTemplate_discovery(ITemplateService templateService, string templateName, DotnetFramework version)
{
var files = await templateService.GenerateProjectFiles(new GeneratorModel()
{
Dependencies = "Discovery",
TemplateShortName = templateName,
TemplateVersion = version,
Framework = version,
});
string startUpContents = files.Find(x => x.Key == "Startup.cs").Value;
@ -130,13 +130,13 @@ namespace Steeltoe.Initializr.TemplateEngine.Test
[Theory]
[ClassData(typeof(AllImplementationsAndTemplates))]
public async Task CreateTemplate_actuators_circuitbreakers(ITemplateService templateService, string templateName, DotnetTemplateVersion version)
public async Task CreateTemplate_actuators_circuitbreakers(ITemplateService templateService, string templateName, DotnetFramework version)
{
var files = await templateService.GenerateProjectFiles(new GeneratorModel()
{
Dependencies = "Actuators,CircuitBreaker",
TemplateShortName = templateName,
TemplateVersion = version,
Framework = version,
});
string startUpContents = files.Find(x => x.Key == "Startup.cs").Value;
@ -154,17 +154,17 @@ namespace Steeltoe.Initializr.TemplateEngine.Test
[Theory]
[ClassData(typeof(AllImplementationsAndTemplates))]
public async Task CreateTemplate_MySql(ITemplateService templateService, string templateName, DotnetTemplateVersion version)
public async Task CreateTemplate_MySql(ITemplateService templateService, string templateName, DotnetFramework version)
{
var files = await templateService.GenerateProjectFiles(new GeneratorModel()
{
Dependencies = "MySql",
TemplateShortName = templateName,
TemplateVersion = version,
Framework = version,
});
string startUpContents = files.Find(x => x.Key == "Startup.cs").Value;
if (version.Equals(DotnetTemplateVersion.V3))
if (version.Equals(DotnetFramework.NetCoreApp31))
{
Assert.Contains("using Steeltoe.Connector.MySql;", startUpContents);
}
@ -191,17 +191,17 @@ namespace Steeltoe.Initializr.TemplateEngine.Test
[Theory]
[ClassData(typeof(AllImplementationsAndTemplates))]
public async Task CreateTemplate_MySql_EFCore(ITemplateService templateService, string templateName, DotnetTemplateVersion version)
public async Task CreateTemplate_MySql_EFCore(ITemplateService templateService, string templateName, DotnetFramework version)
{
var files = await templateService.GenerateProjectFiles(new GeneratorModel()
{
Dependencies = "MySqlEFCore",
TemplateShortName = templateName,
TemplateVersion = version,
Framework = version,
});
string startUpContents = files.Find(x => x.Key == "Startup.cs").Value;
if (version.Equals(DotnetTemplateVersion.V3))
if (version.Equals(DotnetFramework.NetCoreApp31))
{
Assert.Contains("using Steeltoe.Connector.MySql;", startUpContents);
Assert.Contains("using Steeltoe.Connector.MySql.EFCore;", startUpContents);
@ -215,17 +215,17 @@ namespace Steeltoe.Initializr.TemplateEngine.Test
[Theory]
[ClassData(typeof(AllImplementationsAndTemplates))]
public async Task CreateTemplate_postgresql(ITemplateService templateService, string templateName, DotnetTemplateVersion version)
public async Task CreateTemplate_postgresql(ITemplateService templateService, string templateName, DotnetFramework version)
{
var files = await templateService.GenerateProjectFiles(new GeneratorModel()
{
Dependencies = "Postgres",
TemplateShortName = templateName,
TemplateVersion = version,
Framework = version,
});
string startUpContents = files.Find(x => x.Key == "Startup.cs").Value;
if (version.Equals(DotnetTemplateVersion.V3))
if (version.Equals(DotnetFramework.NetCoreApp31))
{
Assert.Contains("using Steeltoe.Connector.PostgreSql;", startUpContents);
}
@ -245,7 +245,7 @@ namespace Steeltoe.Initializr.TemplateEngine.Test
[Theory]
[ClassData(typeof(AllImplementationsAndTemplates))]
public async Task CreateTemplate_ConfigServer(ITemplateService templateService, string templateName, DotnetTemplateVersion version)
public async Task CreateTemplate_ConfigServer(ITemplateService templateService, string templateName, DotnetFramework version)
{
var configuration = TestHelper.GetConfiguration();
var logger = new LoggerFactory().CreateLogger<MustacheTemplateService>();
@ -254,7 +254,7 @@ namespace Steeltoe.Initializr.TemplateEngine.Test
{
Dependencies = "ConfigServer",
TemplateShortName = templateName,
TemplateVersion = version,
Framework = version,
});
Assert.DoesNotContain(files, file => file.Key.EndsWith("SampleData.cs"));
@ -272,7 +272,7 @@ namespace Steeltoe.Initializr.TemplateEngine.Test
[Theory]
[ClassData(typeof(AllImplementationsAndTemplates))]
public async Task CreateTemplate_Randomvalue(ITemplateService templateService, string templateName, DotnetTemplateVersion version)
public async Task CreateTemplate_Randomvalue(ITemplateService templateService, string templateName, DotnetFramework version)
{
var configuration = TestHelper.GetConfiguration();
var logger = new LoggerFactory().CreateLogger<MustacheTemplateService>();
@ -281,7 +281,7 @@ namespace Steeltoe.Initializr.TemplateEngine.Test
{
Dependencies = "RandomValueConfig",
TemplateShortName = templateName,
TemplateVersion = version,
Framework = version,
});
Assert.Contains(files, file => file.Key.EndsWith("ValuesController.cs"));
@ -298,7 +298,7 @@ namespace Steeltoe.Initializr.TemplateEngine.Test
[Theory]
[ClassData(typeof(AllImplementationsAndTemplates))]
public async Task CreateTemplate_Cloudfoundry(ITemplateService templateService, string templateName, DotnetTemplateVersion version)
public async Task CreateTemplate_Cloudfoundry(ITemplateService templateService, string templateName, DotnetFramework version)
{
var configuration = TestHelper.GetConfiguration();
var logger = new LoggerFactory().CreateLogger<MustacheTemplateService>();
@ -307,12 +307,12 @@ namespace Steeltoe.Initializr.TemplateEngine.Test
{
Dependencies = "CloudFoundry",
TemplateShortName = templateName,
TemplateVersion = version,
Framework = version,
});
string programContents = files.Find(x => x.Key == "Program.cs").Value;
if (version.Equals(DotnetTemplateVersion.V3))
if (version.Equals(DotnetFramework.NetCoreApp31))
{
Assert.Contains(".UseCloudHosting()", programContents);
Assert.Contains(".AddCloudFoundryConfiguration()", programContents);
@ -331,7 +331,7 @@ namespace Steeltoe.Initializr.TemplateEngine.Test
[Theory]
[ClassData(typeof(AllImplementationsAndTemplates))]
public async Task CreateTemplate_Placeholderconfig(ITemplateService templateService, string templateName, DotnetTemplateVersion version)
public async Task CreateTemplate_Placeholderconfig(ITemplateService templateService, string templateName, DotnetFramework version)
{
var configuration = TestHelper.GetConfiguration();
var logger = new LoggerFactory().CreateLogger<MustacheTemplateService>();
@ -340,14 +340,14 @@ namespace Steeltoe.Initializr.TemplateEngine.Test
{
Dependencies = "PlaceholderConfig",
TemplateShortName = templateName,
TemplateVersion = version,
Framework = version,
});
Assert.DoesNotContain(files, file => file.Key.EndsWith("SampleData.cs"));
Assert.Contains(files, file => file.Key.EndsWith("ValuesController.cs"));
string programContents = files.Find(x => x.Key == "Program.cs").Value;
if (version.Equals(DotnetTemplateVersion.V3))
if (version.Equals(DotnetFramework.NetCoreApp31))
{
Assert.Contains("using Steeltoe.Extensions.Configuration.Placeholder;", programContents);
}
@ -369,17 +369,17 @@ namespace Steeltoe.Initializr.TemplateEngine.Test
[Theory]
[ClassData(typeof(AllImplementationsAndTemplates))]
public async Task CreateTemplate_postgresEFCore(ITemplateService templateService, string templateName, DotnetTemplateVersion version)
public async Task CreateTemplate_postgresEFCore(ITemplateService templateService, string templateName, DotnetFramework version)
{
var files = await templateService.GenerateProjectFiles(new GeneratorModel()
{
Dependencies = "PostgresEFCore",
TemplateShortName = templateName,
TemplateVersion = version,
Framework = version,
});
string startUpContents = files.Find(x => x.Key == "Startup.cs").Value;
if (version.Equals(DotnetTemplateVersion.V3))
if (version.Equals(DotnetFramework.NetCoreApp31))
{
Assert.Contains("using Steeltoe.Connector.PostgreSql.EFCore;", startUpContents);
}
@ -393,17 +393,17 @@ namespace Steeltoe.Initializr.TemplateEngine.Test
[Theory]
[ClassData(typeof(AllImplementationsAndTemplates))]
public async Task CreateTemplate_RabbitMQ(ITemplateService templateService, string templateName, DotnetTemplateVersion version)
public async Task CreateTemplate_RabbitMQ(ITemplateService templateService, string templateName, DotnetFramework version)
{
var files = await templateService.GenerateProjectFiles(new GeneratorModel()
{
Dependencies = "RabbitMQ",
TemplateShortName = templateName,
TemplateVersion = version,
Framework = version,
});
string startUpContents = files.Find(x => x.Key == "Startup.cs").Value;
if (version.Equals(DotnetTemplateVersion.V3))
if (version.Equals(DotnetFramework.NetCoreApp31))
{
Assert.Contains("using Steeltoe.Connector.RabbitMQ;", startUpContents);
}
@ -430,17 +430,17 @@ using System.Threading;", valuesController);
[Theory]
[ClassData(typeof(AllImplementationsAndTemplates))]
public async Task CreateTemplate_Redis(ITemplateService templateService, string templateName, DotnetTemplateVersion version)
public async Task CreateTemplate_Redis(ITemplateService templateService, string templateName, DotnetFramework version)
{
var files = await templateService.GenerateProjectFiles(new GeneratorModel()
{
Dependencies = "Redis",
TemplateShortName = templateName,
TemplateVersion = version,
Framework = version,
});
string startUpContents = files.Find(x => x.Key == "Startup.cs").Value;
if (version.Equals(DotnetTemplateVersion.V3))
if (version.Equals(DotnetFramework.NetCoreApp31))
{
Assert.Contains("using Steeltoe.Connector.Redis", startUpContents);
}
@ -460,17 +460,17 @@ using System.Threading;", valuesController);
[Theory]
[ClassData(typeof(AllImplementationsAndTemplates))]
public async Task CreateTemplate_MongoDB(ITemplateService templateService, string templateName, DotnetTemplateVersion version)
public async Task CreateTemplate_MongoDB(ITemplateService templateService, string templateName, DotnetFramework version)
{
var files = await templateService.GenerateProjectFiles(new GeneratorModel()
{
Dependencies = "MongoDB",
TemplateShortName = templateName,
TemplateVersion = version,
Framework = version,
});
string startUpContents = files.Find(x => x.Key == "Startup.cs").Value;
if (version.Equals(DotnetTemplateVersion.V3))
if (version.Equals(DotnetFramework.NetCoreApp31))
{
Assert.Contains("using Steeltoe.Connector.MongoDb;", startUpContents);
}
@ -490,17 +490,17 @@ using System.Threading;", valuesController);
[Theory]
[ClassData(typeof(AllImplementationsAndTemplates))]
public async Task CreateTemplate_OauthConnector(ITemplateService templateService, string templateName, DotnetTemplateVersion version)
public async Task CreateTemplate_OauthConnector(ITemplateService templateService, string templateName, DotnetFramework version)
{
var files = await templateService.GenerateProjectFiles(new GeneratorModel()
{
Dependencies = "OAuthConnector",
TemplateShortName = templateName,
TemplateVersion = version,
Framework = version,
});
string startUpContents = files.Find(x => x.Key == "Startup.cs").Value;
if (version.Equals(DotnetTemplateVersion.V3))
if (version.Equals(DotnetFramework.NetCoreApp31))
{
Assert.Contains("using Steeltoe.Connector.OAuth;", startUpContents);
}
@ -513,7 +513,7 @@ using System.Threading;", valuesController);
[Theory]
[ClassData(typeof(AllImplementationsAndTemplates))]
public async Task CreateTemplate_SqlServer(ITemplateService templateService, string templateName, DotnetTemplateVersion version)
public async Task CreateTemplate_SqlServer(ITemplateService templateService, string templateName, DotnetFramework version)
{
var steeltoeVersion = "2.4.4";
@ -523,14 +523,14 @@ using System.Threading;", valuesController);
ProjectName = "testProject",
TemplateShortName = templateName,
SteeltoeVersion = steeltoeVersion,
TemplateVersion = version,
Framework = version,
});
var fileContents = files.Find(x => x.Key == "testProject.csproj").Value;
var aspnetCoreVersion = version == DotnetTemplateVersion.V3 ? "3.1.0" : "2.1.1";
var aspnetCoreVersion = version == DotnetFramework.NetCoreApp31 ? "3.1.0" : "2.1.1";
var startup = files.Find(x => x.Key == "Startup.cs").Value;
if (version.Equals(DotnetTemplateVersion.V3))
if (version.Equals(DotnetFramework.NetCoreApp31))
{
Assert.Contains(@"using Steeltoe.Connector.SqlServer.EFCore;", startup);
}
@ -550,19 +550,19 @@ using System.Threading;", valuesController);
[Theory]
[ClassData(typeof(AllImplementationsAndTemplates))]
public async Task CreateTemplate_DynamicLogger(ITemplateService templateService, string templateName, DotnetTemplateVersion version)
public async Task CreateTemplate_DynamicLogger(ITemplateService templateService, string templateName, DotnetFramework version)
{
var files = await templateService.GenerateProjectFiles(new GeneratorModel()
{
Dependencies = "DynamicLogger",
ProjectName = "testProject",
TemplateShortName = templateName,
TemplateVersion = version,
Framework = version,
});
string fileContents = files.Find(x => x.Key == "testProject.csproj").Value;
string programFileContents = files.Find(x => x.Key == "Program.cs").Value;
if (version.Equals(DotnetTemplateVersion.V3))
if (version.Equals(DotnetFramework.NetCoreApp31))
{
Assert.Contains(@"<PackageReference Include=""Steeltoe.Extensions.Logging.DynamicSerilogCore"" Version=", fileContents);
Assert.Contains(@"using Steeltoe.Extensions.Logging.DynamicSerilog", programFileContents);
@ -579,7 +579,7 @@ using System.Threading;", valuesController);
[Theory]
[ClassData(typeof(AllImplementationsAndTemplates))]
public async Task CreateTemplate_actuators_cloudFoundry(ITemplateService templateService, string templateName, DotnetTemplateVersion version)
public async Task CreateTemplate_actuators_cloudFoundry(ITemplateService templateService, string templateName, DotnetFramework version)
{
Assert.NotNull(templateService);
@ -587,10 +587,10 @@ using System.Threading;", valuesController);
{
Dependencies = "CloudFoundry",
TemplateShortName = templateName,
TemplateVersion = version,
Framework = version,
});
string programFileContents = files.Find(x => x.Key == "Program.cs").Value;
if (version.Equals(DotnetTemplateVersion.V3))
if (version.Equals(DotnetFramework.NetCoreApp31))
{
Assert.Contains("using Steeltoe.Common.Hosting;", programFileContents);
Assert.Contains(".UseCloudHosting(", programFileContents);
@ -606,14 +606,14 @@ using System.Threading;", valuesController);
[Theory]
[ClassData(typeof(AllImplementationsAndTemplates))]
public async Task CreateTemplate_actuators_v22(ITemplateService templateService, string templateName, DotnetTemplateVersion version)
public async Task CreateTemplate_actuators_v22(ITemplateService templateService, string templateName, DotnetFramework version)
{
var files = await templateService.GenerateProjectFiles(new GeneratorModel()
{
Dependencies = "Actuators",
SteeltoeVersion = "2.4.4",
TemplateShortName = templateName,
TemplateVersion = version,
Framework = version,
});
var startUpContents = files.Find(x => x.Key == "Startup.cs").Value;
@ -623,14 +623,14 @@ using System.Threading;", valuesController);
[Theory]
[ClassData(typeof(AllImplementationsAndTemplates))]
public async Task CreateTemplate_actuators_23(ITemplateService templateService, string templateName, DotnetTemplateVersion version)
public async Task CreateTemplate_actuators_23(ITemplateService templateService, string templateName, DotnetFramework version)
{
var files = await templateService.GenerateProjectFiles(new GeneratorModel()
{
Dependencies = "Actuators",
SteeltoeVersion = "2.4.4",
TemplateShortName = templateName,
TemplateVersion = version,
Framework = version,
});
var startUpContents = files.Find(x => x.Key == "Startup.cs").Value;
@ -640,14 +640,14 @@ using System.Threading;", valuesController);
[Theory]
[ClassData(typeof(AllImplementationsAndTemplates))]
public async Task CreateTemplate_actuators_24(ITemplateService templateService, string templateName, DotnetTemplateVersion version)
public async Task CreateTemplate_actuators_24(ITemplateService templateService, string templateName, DotnetFramework version)
{
var files = await templateService.GenerateProjectFiles(new GeneratorModel()
{
Dependencies = "Actuators",
SteeltoeVersion = "2.4.4",
TemplateShortName = templateName,
TemplateVersion = version,
Framework = version,
});
var startUpContents = files.Find(x => x.Key == "Startup.cs").Value;
@ -666,14 +666,14 @@ using System.Threading;", valuesController);
Dependencies = "Actuators",
SteeltoeVersion = "2.4.2",
TemplateShortName = templateName,
TemplateVersion = DotnetTemplateVersion.V3,
Framework = DotnetFramework.NetCoreApp31,
});
});
}
[Theory]
[ClassData(typeof(AllImplementationsAndTemplates))]
public async Task CreateTemplate_empty(ITemplateService templateService, string templateName, DotnetTemplateVersion version)
public async Task CreateTemplate_empty(ITemplateService templateService, string templateName, DotnetFramework version)
{
Assert.NotNull(templateService);
@ -681,7 +681,7 @@ using System.Threading;", valuesController);
{
TemplateShortName = templateName,
ProjectName = "Foo.Bar",
TemplateVersion = version,
Framework = version,
});
var startUpContents = files.Find(x => x.Key == "Startup.cs").Value;
@ -691,15 +691,15 @@ using System.Threading;", valuesController);
Assert.DoesNotContain("AddCloudFoundryActuators", startUpContents);
var projectFile = files.Find(x => x.Key == "Foo.Bar.csproj").Value;
var targetFramework = version == DotnetTemplateVersion.V3 ? "netcoreapp3.1" : "netcoreapp2.1";
var targetFramework = version == DotnetFramework.NetCoreApp31 ? "netcoreapp3.1" : "netcoreapp2.1";
Assert.Contains($"<TargetFramework>{targetFramework}</TargetFramework>", projectFile);
}
[Theory]
[ClassData(typeof(AllImplementationsAndTemplates))]
public async Task CreateTemplate_targetVersion21(ITemplateService templateService, string templateName, DotnetTemplateVersion version)
public async Task CreateTemplate_targetVersion21(ITemplateService templateService, string templateName, DotnetFramework version)
{
if (version == DotnetTemplateVersion.V3)
if (version == DotnetFramework.NetCoreApp31)
{
return;
}

Просмотреть файл

@ -97,7 +97,7 @@ namespace Steeltoe.Initializr.WebApp.Test
SteeltoeVersion = "2.4.4",
TargetFrameworkVersion = "netcoreapp2.1",
TemplateShortName = "Steeltoe-WebApi",
TemplateVersion = DotnetTemplateVersion.V2,
Framework = DotnetFramework.NetCoreApp21,
};
var props = model.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
@ -123,7 +123,7 @@ namespace Steeltoe.Initializr.WebApp.Test
SteeltoeVersion = "2.4.4",
TargetFrameworkVersion = "netcoreapp2.1",
TemplateShortName = "Steeltoe-WebApi",
TemplateVersion = DotnetTemplateVersion.V2,
Framework = DotnetFramework.NetCoreApp21,
};
var props = model.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);