Fixup test

This commit is contained in:
Pranav K 2020-08-19 11:23:02 -07:00
parent ad8a927e85
commit 57db5937f8
No known key found for this signature in database
GPG Key ID: F748807460A27E91
3 changed files with 17 additions and 8 deletions

View File

@ -42,6 +42,7 @@ namespace Templates.Test.Helpers
IDictionary<string, string> environmentVariables,
bool published,
bool hasListeningUri = true,
bool usePublishedAppHost = false,
ILogger logger = null)
{
_developmentCertificate = DevelopmentCertificate.Create(workingDirectory);
@ -64,9 +65,17 @@ namespace Templates.Test.Helpers
string arguments;
if (published)
{
// When publishingu used the app host to run the app. This makes it easy to consistently run for regular and single-file publish
process = OperatingSystem.IsWindows() ? dllPath + ".exe" : dllPath;
arguments = null;
if (usePublishedAppHost)
{
// When publishingu used the app host to run the app. This makes it easy to consistently run for regular and single-file publish
process = Path.ChangeExtension(dllPath, OperatingSystem.IsWindows() ? ".exe" : null);
arguments = null;
}
else
{
process = DotNetMuxer.MuxerPathOrDefault();
arguments = $"exec {dllPath}";
}
}
else
{

View File

@ -179,7 +179,7 @@ namespace Templates.Test.Helpers
return new AspNetProcess(Output, TemplateOutputDir, projectDll, environment, published: false, hasListeningUri: hasListeningUri, logger: logger);
}
internal AspNetProcess StartPublishedProjectAsync(bool hasListeningUri = true)
internal AspNetProcess StartPublishedProjectAsync(bool hasListeningUri = true, bool usePublishedAppHost = false)
{
var environment = new Dictionary<string, string>
{
@ -190,8 +190,8 @@ namespace Templates.Test.Helpers
["ASPNETCORE_Logging__Console__FormatterOptions__IncludeScopes"] = "true",
};
var projectDll = Path.Combine(TemplatePublishDir, ProjectName);
return new AspNetProcess(Output, TemplatePublishDir, projectDll, environment, published: true, hasListeningUri: hasListeningUri);
var projectDll = Path.Combine(TemplatePublishDir, $"{ProjectName}.dll");
return new AspNetProcess(Output, TemplatePublishDir, projectDll, environment, published: true, hasListeningUri: hasListeningUri, usePublishedAppHost: usePublishedAppHost);
}
internal async Task<ProcessResult> RunDotNetEfCreateMigrationAsync(string migrationName)

View File

@ -243,7 +243,7 @@ namespace Templates.Test
return;
}
Project = await ProjectFactory.GetOrCreateProject("mvcindividualuld", Output);
Project = await ProjectFactory.GetOrCreateProject("mvcsinglefileexe", Output);
Project.RuntimeIdentifier = runtimeIdentifer;
var createResult = await Project.RunDotNetNewAsync("mvc", auth: "Individual", useLocalDB: true);
@ -286,7 +286,7 @@ namespace Templates.Test
},
};
using var aspNetProcess = Project.StartPublishedProjectAsync();
using var aspNetProcess = Project.StartPublishedProjectAsync(usePublishedAppHost: true);
Assert.False(
aspNetProcess.Process.HasExited,
ErrorMessages.GetFailedProcessMessageOrEmpty("Run published project", Project, aspNetProcess.Process));