Skip to content

Commit

Permalink
Template tests: Create dev cert only once (#31012)
Browse files Browse the repository at this point in the history
  • Loading branch information
HaoK authored Mar 19, 2021
1 parent 89c2573 commit 14af9d9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/ProjectTemplates/Shared/AspNetProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class AspNetProcess : IDisposable
internal ProcessEx Process { get; }

public AspNetProcess(
DevelopmentCertificate cert,
ITestOutputHelper output,
string workingDirectory,
string dllPath,
Expand All @@ -44,8 +45,7 @@ public AspNetProcess(
bool usePublishedAppHost = false,
ILogger logger = null)
{
_developmentCertificate = DevelopmentCertificate.Create(workingDirectory);

_developmentCertificate = cert;
_output = output;
_httpClient = new HttpClient(new HttpClientHandler()
{
Expand Down
5 changes: 3 additions & 2 deletions src/ProjectTemplates/Shared/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class Project : IDisposable
public string TemplateOutputDir { get; set; }
public string TargetFramework { get; set; } = GetAssemblyMetadata("Test.DefaultTargetFramework");
public string RuntimeIdentifier { get; set; } = string.Empty;
public static DevelopmentCertificate DevCert { get; } = DevelopmentCertificate.Create(AppContext.BaseDirectory);

public string TemplateBuildDir => Path.Combine(TemplateOutputDir, "bin", "Debug", TargetFramework, RuntimeIdentifier);
public string TemplatePublishDir => Path.Combine(TemplateOutputDir, "bin", "Release", TargetFramework, RuntimeIdentifier, "publish");
Expand Down Expand Up @@ -178,7 +179,7 @@ internal AspNetProcess StartBuiltProjectAsync(bool hasListeningUri = true, ILogg
}

var projectDll = Path.Combine(TemplateBuildDir, $"{ProjectName}.dll");
return new AspNetProcess(Output, TemplateOutputDir, projectDll, environment, published: false, hasListeningUri: hasListeningUri, logger: logger);
return new AspNetProcess(DevCert, Output, TemplateOutputDir, projectDll, environment, published: false, hasListeningUri: hasListeningUri, logger: logger);
}

internal AspNetProcess StartPublishedProjectAsync(bool hasListeningUri = true, bool usePublishedAppHost = false)
Expand All @@ -193,7 +194,7 @@ internal AspNetProcess StartPublishedProjectAsync(bool hasListeningUri = true, b
};

var projectDll = Path.Combine(TemplatePublishDir, $"{ProjectName}.dll");
return new AspNetProcess(Output, TemplatePublishDir, projectDll, environment, published: true, hasListeningUri: hasListeningUri, usePublishedAppHost: usePublishedAppHost);
return new AspNetProcess(DevCert, Output, TemplatePublishDir, projectDll, environment, published: true, hasListeningUri: hasListeningUri, usePublishedAppHost: usePublishedAppHost);
}

internal async Task<ProcessResult> RunDotNetEfCreateMigrationAsync(string migrationName)
Expand Down

0 comments on commit 14af9d9

Please sign in to comment.