Skip to content

Commit 287339a

Browse files
committed
Add functional tests option to Add-DualProjects
Add packages to functional tests
1 parent e042a4b commit 287339a

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

dotnet-new/dual-projects/dual-projects.psm1

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ function Add-DualProjects {
8383
[Alias("create-sln")][switch]$createSolution = $false,
8484
[Alias("s")][string]$solutionName = $null,
8585
[bool]$mkdir = $true,
86-
[Alias("no-build")][switch]$noBuild
86+
[Alias("no-build")][switch]$noBuild,
87+
[Alias("add-functional-tests")][switch]$addFunctionalTests,
88+
[Alias("tests-props")][string]$customTestsPropsFile = $null,
89+
[Alias("functional-tests-props")][string]$customFunctionalTestsPropsFile = $null
8790
)
8891

8992
Write-Debug "projectName: $projectName"
@@ -92,6 +95,7 @@ function Add-DualProjects {
9295
Write-Debug "solutionName: $solutionName"
9396
Write-Debug "mkdir: $mkdir"
9497
Write-Debug "noBuild: $noBuild"
98+
Write-Debug "addFunctionalTests: $addFunctionalTests"
9599

96100
if ($createSolution) {
97101
Add-Solution $solutionName $mkdir $projectName
@@ -108,6 +112,14 @@ function Add-DualProjects {
108112
$testProjectPath = GetProjectPath test "$projectName.Tests"
109113
ReferenceSourceFromTest $srcProjectPath $testProjectPath
110114

115+
# Update the RootNamespace to the test project
116+
UpdateRootNamespace $projectName $testProjectPath
117+
118+
# Create a functional test project
119+
if ($addFunctionalTests) {
120+
Add-FunctionalTests $projectName $solutionName -no-build
121+
}
122+
111123
# Execute post-creation actions
112124
if (!$noBuild) {
113125
BuildSolution $solutionName
@@ -120,7 +132,7 @@ function Add-FunctionalTests {
120132
[Parameter(Mandatory = $true)][Alias("p")][string]$projectName,
121133
[Alias("s")][string]$solutionName = $null,
122134
[Alias("no-build")][switch]$noBuild,
123-
[Alias("props")][string]$customPropsFile = "..\FunctionalTests.Build.props"
135+
[Alias("props")][string]$customPropsFile = $null #"..\FunctionalTests.Build.props"
124136
)
125137
Write-Debug "projectName: $projectName"
126138
Write-Debug "solutionName: $solutionName"
@@ -134,7 +146,11 @@ function Add-FunctionalTests {
134146
$testProjectPath = GetProjectPath test "$projectName.FunctionalTests"
135147
ReferenceSourceFromTest $srcProjectPath $testProjectPath
136148

137-
# Include FunctionalTests.Build.props to project (if it exists)
149+
# Add Microsoft.AspNetCore.Mvc.Testing
150+
dotnet add $testProjectPath package Microsoft.AspNetCore.App
151+
dotnet add $testProjectPath package Microsoft.AspNetCore.Mvc.Testing
152+
153+
# Include the RootNamespace and optionally a custom .props file to the project
138154
UpdateRootNamespace $projectName $testProjectPath $customPropsFile
139155

140156
# Execute post-creation actions
@@ -149,7 +165,6 @@ function UpdateRootNamespace($projectName, $testProjectPath, $customPropsFile =
149165
foreach ($line in [System.IO.File]::ReadLines($testProjectPath)) {
150166
if ($i -eq 1) {
151167
if ($customPropsFile) {
152-
# -and (Test-Path $customPropsFile)) {
153168
Write-Verbose "Adding '$customPropsFile' to '$testProjectPath'."
154169
Add-Content -Path $tmpFile -Value " <Import Project=""$customPropsFile"" />"
155170
Add-Content -Path $tmpFile -Value ""

0 commit comments

Comments
 (0)