Skip to content

Commit 29c8c9e

Browse files
committedAug 26, 2019
Support 15.x applications folder+test
1 parent 789557c commit 29c8c9e

11 files changed

+292
-145
lines changed
 

‎.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
settings.ps1
2-
*.app
2+

‎AppHandling/Clean-BcContainerDatabase.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function Clean-BcContainerDatabase {
4141
Invoke-ScriptInBCContainer -containerName $containerName -scriptblock { Param($app, $SaveData, $onlySaveBaseAppData)
4242
if ($app.IsInstalled) {
4343
Write-Host "Uninstalling $($app.Name)"
44-
$app | Uninstall-NavApp -Force -doNotSaveData:(!$SaveData -or ($Name -ne "BaseApp" -and $onlySaveBaseAppData))
44+
$app | Uninstall-NavApp -Force -doNotSaveData:(!$SaveData -or ($Name -ne "BaseApp" -and $Name -ne "Base Application" -and $onlySaveBaseAppData))
4545
}
4646
} -argumentList $app, $SaveData, $onlySaveBaseAppData
4747
}

‎AppHandling/Create-AlProjectFolderFromNavContainer.ps1

+68-16
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,6 @@ function Create-AlProjectFolderFromNavContainer {
6666
$alFolder = Join-Path $ExtensionsFolder "Original-$navversion-al"
6767
$dotnetAssembliesFolder = Join-Path $ExtensionsFolder "$containerName\.netPackages"
6868

69-
if ($useBaseAppProperties) {
70-
$baseapp = Get-NavContainerAppInfo -containerName $containerName | Where-Object { $_.Name -eq 'BaseApp' }
71-
if ($baseapp) {
72-
$id = $baseapp.AppId
73-
$name = $baseapp.Name
74-
$publisher = $baseapp.Publisher
75-
$version = $baseapp.Version
76-
}
77-
else {
78-
throw "BaseApp not found"
79-
}
80-
}
81-
8269
if (!(Test-Path $alFolder -PathType Container) -or !(Test-Path $dotnetAssembliesFolder -PathType Container)) {
8370
throw "Container $containerName was not started with -includeAL (or -doNotExportObjectsAsText was specified)"
8471
}
@@ -94,12 +81,77 @@ function Create-AlProjectFolderFromNavContainer {
9481
if ($useBaseLine) {
9582
Copy-AlSourceFiles -Path "$alFolder\*" -Destination $AlProjectFolder -Recurse -alFileStructure $alFileStructure
9683
}
84+
elseif ($ver.Major -ge 15) {
85+
$id = [Guid]::NewGuid().Guid
86+
$appFile = Join-Path $ExtensionsFolder "BaseApp-$id.app"
87+
$appFolder = Join-Path $ExtensionsFolder "BaseApp-$id"
88+
$myAlFolder = Join-Path $ExtensionsFolder "al-$id"
89+
try {
90+
$appName = "Base Application"
91+
if ($ver -lt [Version]("15.0.35659.0")) {
92+
$appName = "BaseApp"
93+
}
94+
$baseapp = Get-NavContainerAppInfo -containerName $containerName | Where-Object { $_.Name -eq $appName }
95+
Get-NavContainerApp -containerName $containerName `
96+
-publisher $baseapp.Publisher `
97+
-appName $baseapp.Name `
98+
-appFile $appFile `
99+
-credential $credential
100+
101+
Extract-AppFileToFolder -appFilename $appFile -appFolder $appFolder
102+
'layout','src','translations' | ForEach-Object {
103+
if (Test-Path (Join-Path $appFolder $_)) {
104+
Copy-Item -Path (Join-Path $appFolder $_) -Destination $myAlFolder -Recurse -Force
105+
}
106+
}
107+
108+
Copy-AlSourceFiles -Path "$myAlFolder\*" -Destination $AlProjectFolder -Recurse -alFileStructure $alFileStructure
109+
}
110+
finally {
111+
Remove-Item -Path $myAlFolder -Recurse -Force -ErrorAction SilentlyContinue
112+
Remove-Item -Path $appFolder -Recurse -Force -ErrorAction SilentlyContinue
113+
Remove-Item -Path $appFile -Force -ErrorAction SilentlyContinue
114+
}
115+
}
97116
else {
98117
Convert-ModifiedObjectsToAl -containerName $containerName -doNotUseDeltas -alProjectFolder $AlProjectFolder -alFileStructure $alFileStructure -runTxt2AlInContainer $runTxt2AlInContainer
99118
}
100119

101120
$appJsonFile = Join-Path $AlProjectFolder "app.json"
102-
if ($ver.Major -eq 15) {
121+
if ($useBaseLine -and $ver -ge [Version]("15.0.35528.0")) {
122+
$appJson = Get-Content "$alFolder\app.json" | ConvertFrom-Json
123+
124+
if (-not $useBaseAppProperties) {
125+
$appJson.Id = $id
126+
$appJson.Name = $name
127+
$appJson.Publisher = $publisher
128+
$appJson.Version = $version
129+
}
130+
131+
} elseif ($ver.Major -ge 15) {
132+
133+
if ($useBaseAppProperties) {
134+
$appName = "Base Application"
135+
if ($ver -lt [Version]("15.0.35659.0")) {
136+
$appName = "BaseApp"
137+
}
138+
$baseapp = Get-NavContainerAppInfo -containerName $containerName | Where-Object { $_.Name -eq $appName }
139+
if ($baseapp) {
140+
$id = $baseapp.AppId
141+
$name = $baseapp.Name
142+
$publisher = $baseapp.Publisher
143+
$version = $baseapp.Version
144+
}
145+
else {
146+
throw "BaseApp not found"
147+
}
148+
}
149+
if ($ver -ge [Version]("15.0.35528.0")) {
150+
$sysAppVer = "$($ver.Major).0.0.0"
151+
}
152+
else {
153+
$sysAppVer = "1.0.0.0"
154+
}
103155
$appJson = @{
104156
"id" = $id
105157
"name" = $name
@@ -116,10 +168,10 @@ function Create-AlProjectFolderFromNavContainer {
116168
"appId" = "63ca2fa4-4f03-4f2b-a480-172fef340d3f"
117169
"publisher" = "Microsoft"
118170
"name" = "System Application"
119-
"version" = "1.0.0.0"
171+
"version" = $sysAppVer
120172
})
121173
"screenshots" = @()
122-
"platform" = "15.0.0.0"
174+
"platform" = "$($ver.Major).0.0.0"
123175
"idRanges" = @()
124176
"showMyCode" = $true
125177
"target" = "OnPrem"

‎AppHandling/Get-NavContainerApp.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
.Parameter credential
1818
Credentials of the SUPER user if using NavUserPassword authentication
1919
.Example
20-
$appFile = Get-NavContainerApp -containerName test -publisher "Microsoft" -appName "BaseApp" -appVersion "
20+
$appFile = Get-NavContainerApp -containerName test -publisher "Microsoft" -appName "Base Application" -appVersion "15.0.35528.0"
2121
#>
2222
function Get-NavContainerApp {
2323
Param(

‎AppHandling/Get-TestsFromNavContainer.ps1

+32-13
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ function Get-TestsFromNavContainer {
2929
[Parameter(Mandatory=$false)]
3030
[string] $testSuite = "DEFAULT",
3131
[Parameter(Mandatory=$false)]
32-
[string] $testCodeunit = "*"
32+
[string] $testCodeunit = "*",
33+
[Parameter(Mandatory=$false)]
34+
[int] $testPage
3335
)
3436

3537
$navversion = Get-NavContainerNavversion -containerOrImageName $containerName
3638
$version = [System.Version]($navversion.split('-')[0])
3739

38-
$PsTestToolFolder = "C:\ProgramData\NavContainerHelper\Extensions\$containerName\PsTestTool-1"
40+
$PsTestToolFolder = "C:\ProgramData\NavContainerHelper\Extensions\$containerName\PsTestTool-2"
3941
$PsTestFunctionsPath = Join-Path $PsTestToolFolder "PsTestFunctions.ps1"
4042
$ClientContextPath = Join-Path $PsTestToolFolder "ClientContext.ps1"
4143
$fobfile = Join-Path $PsTestToolFolder "PSTestToolPage.fob"
@@ -46,31 +48,48 @@ function Get-TestsFromNavContainer {
4648
throw "Container $containerName needs to include the WebClient in order to get tests (PublicWebBaseUrl is blank)"
4749
}
4850

51+
if (!$testPage) {
52+
if ($version.Major -ge 15) {
53+
$testPage = 130455
54+
}
55+
else {
56+
$testPage = 130409
57+
}
58+
}
59+
4960
If (!(Test-Path -Path $PsTestToolFolder -PathType Container)) {
5061
try {
5162
New-Item -Path $PsTestToolFolder -ItemType Directory | Out-Null
5263

5364
Copy-Item -Path (Join-Path $PSScriptRoot "PsTestFunctions.ps1") -Destination $PsTestFunctionsPath -Force
5465
Copy-Item -Path (Join-Path $PSScriptRoot "ClientContext.ps1") -Destination $ClientContextPath -Force
55-
if ($version.Major -lt 11) {
56-
Copy-Item -Path (Join-Path $PSScriptRoot "PSTestToolPage$($version.Major).fob") -Destination $fobfile -Force
66+
67+
if ($version.Major -ge 15) {
68+
if ($testPage -eq 130409) {
69+
Publish-BcContainerApp -containerName $containerName -appFile (Join-Path $PSScriptRoot "Microsoft_PSTestToolPage_15.0.0.0.app") -skipVerification -sync -install
70+
}
5771
}
5872
else {
59-
Copy-Item -Path (Join-Path $PSScriptRoot "PSTestToolPage.fob") -Destination $fobfile -Force
60-
}
73+
if ($version.Major -lt 11) {
74+
Copy-Item -Path (Join-Path $PSScriptRoot "PSTestToolPage$($version.Major).fob") -Destination $fobfile -Force
75+
}
76+
else {
77+
Copy-Item -Path (Join-Path $PSScriptRoot "PSTestToolPage.fob") -Destination $fobfile -Force
78+
}
6179

62-
if ($clientServicesCredentialType -eq "Windows") {
63-
Import-ObjectsToNavContainer -containerName $containerName -objectsFile $fobfile
64-
} else {
65-
Import-ObjectsToNavContainer -containerName $containerName -objectsFile $fobfile -sqlCredential $credential
80+
if ($clientServicesCredentialType -eq "Windows") {
81+
Import-ObjectsToNavContainer -containerName $containerName -objectsFile $fobfile
82+
} else {
83+
Import-ObjectsToNavContainer -containerName $containerName -objectsFile $fobfile -sqlCredential $credential
84+
}
6685
}
6786
} catch {
6887
Remove-Item -Path $PsTestToolFolder -Recurse -Force
6988
throw
7089
}
7190
}
7291

73-
Invoke-ScriptInNavContainer -containerName $containerName { Param([string] $tenant, [pscredential] $credential, [string] $accessToken, [string] $testSuite, [string] $testCodeunit, [string] $PsTestFunctionsPath, [string] $ClientContextPath, $version)
92+
Invoke-ScriptInNavContainer -containerName $containerName { Param([string] $tenant, [pscredential] $credential, [string] $accessToken, [string] $testSuite, [string] $testCodeunit, [string] $PsTestFunctionsPath, [string] $ClientContextPath, $testPage, $version)
7493

7594
$newtonSoftDllPath = (Get-Item "C:\Program Files\Microsoft Dynamics NAV\*\Service\NewtonSoft.json.dll").FullName
7695
$clientDllPath = "C:\Test Assemblies\Microsoft.Dynamics.Framework.UI.Client.dll"
@@ -110,7 +129,7 @@ function Get-TestsFromNavContainer {
110129

111130
$clientContext = New-ClientContext -serviceUrl $serviceUrl -auth $clientServicesCredentialType -credential $credential
112131

113-
Get-Tests -clientContext $clientContext -TestSuite $testSuite -TestCodeunit $testCodeunit
132+
Get-Tests -clientContext $clientContext -TestSuite $testSuite -TestCodeunit $testCodeunit -testPage $testPage
114133

115134
}
116135
finally {
@@ -120,7 +139,7 @@ function Get-TestsFromNavContainer {
120139
Remove-ClientContext -clientContext $clientContext
121140
}
122141

123-
} -argumentList $tenant, $credential, $accessToken, $testSuite, $testCodeunit, $PsTestFunctionsPath, $ClientContextPath, $version | ConvertFrom-Json
142+
} -argumentList $tenant, $credential, $accessToken, $testSuite, $testCodeunit, $PsTestFunctionsPath, $ClientContextPath, $testPage, $version | ConvertFrom-Json
124143
}
125144
Set-Alias -Name Get-TestsFromBCContainer -Value Get-TestsFromNavContainer
126145
Export-ModuleMember -Function Get-TestsFromNavContainer -Alias Get-TestsFromBCContainer
Binary file not shown.

‎AppHandling/PsTestFunctions.ps1

+49-30
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ function Get-Tests {
6767
[string] $testCodeunit = "*"
6868
)
6969

70+
if ($testPage -eq 130455) {
71+
$LineTypeAdjust = 1
72+
}
73+
else {
74+
$lineTypeAdjust = 0
75+
}
76+
7077
$form = $clientContext.OpenForm($testPage)
7178
if (!($form)) {
7279
throw "Cannot open page $testPage. You might need to import the page object here: http://aka.ms/pstesttoolpagefob"
@@ -94,30 +101,32 @@ function Get-Tests {
94101
}
95102
$row = $repeater.DefaultViewport[$rowIndex]
96103
$lineTypeControl = $clientContext.GetControlByName($row, "LineType")
97-
$lineType = $lineTypeControl.StringValue
104+
$lineType = "$(([int]$lineTypeControl.StringValue) + $lineTypeAdjust)"
98105
$name = $clientContext.GetControlByName($row, "Name").StringValue
99106
$codeUnitId = $clientContext.GetControlByName($row, "TestCodeunit").StringValue
100107

101108
# Refresh form????
102109
#Write-Host "$linetype $name"
103110

104-
if ($linetype -eq "0") {
105-
$group = @{ "Group" = $name; "Codeunits" = @() }
106-
$Tests += $group
107-
108-
} elseif ($linetype -eq "1") {
109-
$codeUnitName = $name
110-
if ($codeunitId -like $testCodeunit -or $codeunitName -like $testCodeunit) {
111-
$codeunit = @{ "Id" = "$codeunitId"; "Name" = $codeUnitName; "Tests" = @() }
112-
if ($group) {
113-
$group.Codeunits += $codeunit
114-
} else {
115-
$Tests += $codeunit
111+
if ($name) {
112+
if ($linetype -eq "0") {
113+
$group = @{ "Group" = $name; "Codeunits" = @() }
114+
$Tests += $group
115+
116+
} elseif ($linetype -eq "1") {
117+
$codeUnitName = $name
118+
if ($codeunitId -like $testCodeunit -or $codeunitName -like $testCodeunit) {
119+
$codeunit = @{ "Id" = "$codeunitId"; "Name" = $codeUnitName; "Tests" = @() }
120+
if ($group) {
121+
$group.Codeunits += $codeunit
122+
} else {
123+
$Tests += $codeunit
124+
}
125+
}
126+
} elseif ($lineType -eq "2") {
127+
if ($codeunitId -like $testCodeunit -or $codeunitName -like $testCodeunit) {
128+
$codeunit.Tests += $name
116129
}
117-
}
118-
} elseif ($lineType -eq "2") {
119-
if ($codeunitId -like $testCodeunit -or $codeunitName -like $testCodeunit) {
120-
$codeunit.Tests += $name
121130
}
122131
}
123132
}
@@ -141,6 +150,14 @@ function Run-Tests {
141150
[string] $AzureDevOps = 'no'
142151
)
143152

153+
if ($testPage -eq 130455) {
154+
$LineTypeAdjust = 1
155+
$runSelectedName = "RunSelectedTests"
156+
}
157+
else {
158+
$lineTypeAdjust = 0
159+
$runSelectedName = "RunSelected"
160+
}
144161
$allPassed = $true
145162

146163
$form = $clientContext.OpenForm($testPage)
@@ -205,22 +222,24 @@ function Run-Tests {
205222
}
206223
$row = $repeater.DefaultViewport[$rowIndex]
207224
$lineTypeControl = $clientContext.GetControlByName($row, "LineType")
208-
$lineType = $lineTypeControl.StringValue
225+
$lineType = "$(([int]$lineTypeControl.StringValue) + $lineTypeAdjust)"
209226
$name = $clientContext.GetControlByName($row, "Name").StringValue
210227
$codeUnitId = $clientContext.GetControlByName($row, "TestCodeunit").StringValue
211-
if ($linetype -eq "0") {
212-
$groupName = $name
213-
}
214-
elseif ($linetype -eq "1") {
215-
$codeUnitName = $name
216-
$codeUnitNames += @{ $codeunitId = $codeunitName }
217-
}
218-
elseif ($linetype -eq "2") {
219-
$codeUnitname = $codeUnitNames[$codeunitId]
228+
if ($name) {
229+
if ($linetype -eq "0") {
230+
$groupName = $name
231+
}
232+
elseif ($linetype -eq "1") {
233+
$codeUnitName = $name
234+
$codeUnitNames += @{ $codeunitId = $codeunitName }
235+
}
236+
elseif ($linetype -eq "2") {
237+
$codeUnitname = $codeUnitNames[$codeunitId]
238+
}
220239
}
221240
} while (!(($codeunitId -like $testCodeunit -or $codeunitName -like $testCodeunit) -and ($linetype -eq "1" -or $name -like $testFunction)))
222241

223-
if ($rowIndex -ge $repeater.DefaultViewport.Count)
242+
if ($rowIndex -ge $repeater.DefaultViewport.Count -or !($name))
224243
{
225244
break
226245
}
@@ -234,7 +253,7 @@ function Run-Tests {
234253
Write-Host " Codeunit $codeunitId $name " -NoNewline
235254
$clientContext.ActivateControl($lineTypeControl)
236255

237-
$clientContext.InvokeAction($clientContext.GetActionByName($form, "RunSelected"))
256+
$clientContext.InvokeAction($clientContext.GetActionByName($form, $runSelectedName))
238257
$finishTime = get-date
239258
$duration = $finishTime.Subtract($startTime)
240259

@@ -287,7 +306,7 @@ function Run-Tests {
287306
$clientContext.ActivateControl($lineTypeControl)
288307

289308
$startTime = get-date
290-
$clientContext.InvokeAction($clientContext.GetActionByName($form, "RunSelected"))
309+
$clientContext.InvokeAction($clientContext.GetActionByName($form, $runSelectedName))
291310
$finishTime = get-date
292311
$testduration = $finishTime.Subtract($startTime)
293312

‎AppHandling/Publish-NewApplicationToNavContainer.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function Publish-NewApplicationToNavContainer {
8484
if (!(Test-Path $appsFolder)) {
8585
New-Item -Path $appsFolder -ItemType Directory | Out-Null
8686
}
87-
$installedApps = Get-NavContainerAppInfo -containerName $containerName -tenantSpecificProperties -sort DependenciesFirst | Where-Object { $_.Name -ne "System Application" -and $_.Name -ne "BaseApp" }
87+
$installedApps = Get-NavContainerAppInfo -containerName $containerName -tenantSpecificProperties -sort DependenciesFirst | Where-Object { $_.Name -ne "System Application" -and $_.Name -ne "BaseApp" -and $_.Name -ne "Base Application" }
8888
$installedApps | ForEach-Object {
8989
if ($_.Scope -eq "Global" -and !$doNotUseDevEndpoint) {
9090
Write-Warning "Restoring apps to global scope might not work when publishing base app to dev endpoint. You might need to specify -doNotUseDevEndpoint"

‎AppHandling/Run-TestsInNavContainer.ps1

+33-13
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ function Run-TestsInNavContainer {
6060
[string] $AzureDevOps = 'no',
6161
[switch] $detailed,
6262
[timespan] $interactionTimeout = [timespan]::FromHours(24),
63-
[switch] $returnTrueIfAllPassed
63+
[switch] $returnTrueIfAllPassed,
64+
[Parameter(Mandatory=$false)]
65+
[int] $testPage
6466
)
6567

6668
$navversion = Get-NavContainerNavversion -containerOrImageName $containerName
@@ -74,7 +76,7 @@ function Run-TestsInNavContainer {
7476
}
7577
}
7678

77-
$PsTestToolFolder = "C:\ProgramData\NavContainerHelper\Extensions\$containerName\PsTestTool-1"
79+
$PsTestToolFolder = "C:\ProgramData\NavContainerHelper\Extensions\$containerName\PsTestTool-2"
7880
$PsTestFunctionsPath = Join-Path $PsTestToolFolder "PsTestFunctions.ps1"
7981
$ClientContextPath = Join-Path $PsTestToolFolder "ClientContext.ps1"
8082
$fobfile = Join-Path $PsTestToolFolder "PSTestToolPage.fob"
@@ -85,23 +87,40 @@ function Run-TestsInNavContainer {
8587
throw "Container $containerName needs to include the WebClient in order to run tests (PublicWebBaseUrl is blank)"
8688
}
8789

90+
if (!$testPage) {
91+
if ($version.Major -ge 15) {
92+
$testPage = 130455
93+
}
94+
else {
95+
$testPage = 130409
96+
}
97+
}
98+
8899
If (!(Test-Path -Path $PsTestToolFolder -PathType Container)) {
89100
try {
90101
New-Item -Path $PsTestToolFolder -ItemType Directory | Out-Null
91102

92103
Copy-Item -Path (Join-Path $PSScriptRoot "PsTestFunctions.ps1") -Destination $PsTestFunctionsPath -Force
93104
Copy-Item -Path (Join-Path $PSScriptRoot "ClientContext.ps1") -Destination $ClientContextPath -Force
94-
if ($version.Major -lt 11) {
95-
Copy-Item -Path (Join-Path $PSScriptRoot "PSTestToolPage$($version.Major).fob") -Destination $fobfile -Force
105+
106+
if ($version.Major -ge 15) {
107+
if ($testPage -eq 130409) {
108+
Publish-BcContainerApp -containerName $containerName -appFile (Join-Path $PSScriptRoot "Microsoft_PSTestToolPage_15.0.0.0.app") -skipVerification -sync -install
109+
}
96110
}
97111
else {
98-
Copy-Item -Path (Join-Path $PSScriptRoot "PSTestToolPage.fob") -Destination $fobfile -Force
99-
}
112+
if ($version.Major -lt 11) {
113+
Copy-Item -Path (Join-Path $PSScriptRoot "PSTestToolPage$($version.Major).fob") -Destination $fobfile -Force
114+
}
115+
else {
116+
Copy-Item -Path (Join-Path $PSScriptRoot "PSTestToolPage.fob") -Destination $fobfile -Force
117+
}
100118

101-
if ($clientServicesCredentialType -eq "Windows") {
102-
Import-ObjectsToNavContainer -containerName $containerName -objectsFile $fobfile
103-
} else {
104-
Import-ObjectsToNavContainer -containerName $containerName -objectsFile $fobfile -sqlCredential $credential
119+
if ($clientServicesCredentialType -eq "Windows") {
120+
Import-ObjectsToNavContainer -containerName $containerName -objectsFile $fobfile
121+
} else {
122+
Import-ObjectsToNavContainer -containerName $containerName -objectsFile $fobfile -sqlCredential $credential
123+
}
105124
}
106125
} catch {
107126
Remove-Item -Path $PsTestToolFolder -Recurse -Force
@@ -116,7 +135,7 @@ function Run-TestsInNavContainer {
116135
}
117136
}
118137

119-
$allPassed = Invoke-ScriptInNavContainer -containerName $containerName { Param([string] $tenant, [string] $companyName, [pscredential] $credential, [string] $accessToken, [string] $testSuite, [string] $testGroup, [string] $testCodeunit, [string] $testFunction, [string] $PsTestFunctionsPath, [string] $ClientContextPath, [string] $XUnitResultFileName, [bool] $AppendToXUnitResultFile, [bool] $ReRun, [string] $AzureDevOps, [bool] $detailed, [timespan] $interactionTimeout, $version)
138+
$allPassed = Invoke-ScriptInNavContainer -containerName $containerName { Param([string] $tenant, [string] $companyName, [pscredential] $credential, [string] $accessToken, [string] $testSuite, [string] $testGroup, [string] $testCodeunit, [string] $testFunction, [string] $PsTestFunctionsPath, [string] $ClientContextPath, [string] $XUnitResultFileName, [bool] $AppendToXUnitResultFile, [bool] $ReRun, [string] $AzureDevOps, [bool] $detailed, [timespan] $interactionTimeout, $testPage, $version)
120139

121140
$newtonSoftDllPath = (Get-Item "C:\Program Files\Microsoft Dynamics NAV\*\Service\NewtonSoft.json.dll").FullName
122141
$clientDllPath = "C:\Test Assemblies\Microsoft.Dynamics.Framework.UI.Client.dll"
@@ -170,7 +189,8 @@ function Run-TestsInNavContainer {
170189
-AppendToXUnitResultFile:$AppendToXUnitResultFile `
171190
-ReRun:$ReRun `
172191
-AzureDevOps $AzureDevOps `
173-
-detailed:$detailed
192+
-detailed:$detailed `
193+
-testPage $testPage
174194
}
175195
finally {
176196
if ($disableSslVerification) {
@@ -179,7 +199,7 @@ function Run-TestsInNavContainer {
179199
Remove-ClientContext -clientContext $clientContext
180200
}
181201

182-
} -argumentList $tenant, $companyName, $credential, $accessToken, $testSuite, $testGroup, $testCodeunit, $testFunction, $PsTestFunctionsPath, $ClientContextPath, $containerXUnitResultFileName, $AppendToXUnitResultFile, $ReRun, $AzureDevOps, $detailed, $interactionTimeout, $version
202+
} -argumentList $tenant, $companyName, $credential, $accessToken, $testSuite, $testGroup, $testCodeunit, $testFunction, $PsTestFunctionsPath, $ClientContextPath, $containerXUnitResultFileName, $AppendToXUnitResultFile, $ReRun, $AzureDevOps, $detailed, $interactionTimeout, $testPage, $version
183203
if ($returnTrueIfAllPassed) {
184204
$allPassed
185205
}

‎ContainerHandling/New-NavContainer.ps1

+38-16
Original file line numberDiff line numberDiff line change
@@ -1211,24 +1211,46 @@ Get-NavServerUser -serverInstance $ServerInstance -tenant default |? LicenseType
12111211
$alFolder = Join-Path $ExtensionsFolder "Original-$navversion-al"
12121212
if (!(Test-Path $alFolder)) {
12131213
New-Item $alFolder -ItemType Directory | Out-Null
1214-
$appFile = Join-Path $ExtensionsFolder "BaseApp-$navVersion.app"
1215-
Get-NavContainerApp -containerName $containerName `
1216-
-publisher Microsoft `
1217-
-appName BaseApp `
1218-
-appFile $appFile `
1219-
-credential $credential
1220-
1221-
$appFolder = Join-Path $ExtensionsFolder "BaseApp-$navVersion"
1222-
Extract-AppFileToFolder -appFilename $appFile -appFolder $appFolder
1223-
1224-
'layout','src','translations' | ForEach-Object {
1225-
if (Test-Path (Join-Path $appFolder $_)) {
1226-
Copy-Item -Path (Join-Path $appFolder $_) -Destination $alFolder -Recurse -Force
1214+
if ($version -ge [Version]("15.0.35528.0")) {
1215+
Invoke-ScriptInBcContainer -containerName $containerName -scriptBlock { Param($alFolder, $country)
1216+
[Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.Filesystem") | Out-Null
1217+
if (Test-Path "C:\Applications.$country") {
1218+
$baseAppSource = @(get-childitem -Path "C:\Applications.$country\*.*" -recurse -filter "Base Application.Source.zip")
1219+
}
1220+
else {
1221+
$baseAppSource = @(get-childitem -Path "C:\Applications\*.*" -recurse -filter "Base Application.Source.zip")
1222+
}
1223+
if ($baseAppSource.Count -ne 1) {
1224+
throw "Unable to locate Base Application.Source.zip"
1225+
}
1226+
Write-Host "Extracting $($baseAppSource[0].FullName)"
1227+
[System.IO.Compression.ZipFile]::ExtractToDirectory($baseAppSource[0].FullName, $alFolder)
1228+
} -argumentList (Get-BCContainerPath -containerName $containerName -path $alFolder), $devCountry
1229+
}
1230+
else {
1231+
$appFile = Join-Path $ExtensionsFolder "BaseApp-$navVersion.app"
1232+
$appName = "Base Application"
1233+
if ($version -lt [Version]("15.0.35659.0")) {
1234+
$appName = "BaseApp"
1235+
}
1236+
Get-NavContainerApp -containerName $containerName `
1237+
-publisher Microsoft `
1238+
-appName $appName `
1239+
-appFile $appFile `
1240+
-credential $credential
1241+
1242+
$appFolder = Join-Path $ExtensionsFolder "BaseApp-$navVersion"
1243+
Extract-AppFileToFolder -appFilename $appFile -appFolder $appFolder
1244+
1245+
'layout','src','translations' | ForEach-Object {
1246+
if (Test-Path (Join-Path $appFolder $_)) {
1247+
Copy-Item -Path (Join-Path $appFolder $_) -Destination $alFolder -Recurse -Force
1248+
}
12271249
}
1250+
1251+
Remove-Item -Path $appFolder -Recurse -Force
1252+
Remove-Item -Path $appFile -Force
12281253
}
1229-
1230-
Remove-Item -Path $appFolder -Recurse -Force
1231-
Remove-Item -Path $appFile -Force
12321254
}
12331255
}
12341256
elseif ($version.Major -gt 10) {

‎ObjectHandling/Import-TestToolkitToNavContainer.ps1

+68-53
Original file line numberDiff line numberDiff line change
@@ -50,68 +50,83 @@ function Import-TestToolkitToNavContainer {
5050
$doNotUpdateSymbols = $true
5151
}
5252

53-
$sqlCredential = Get-DefaultSqlCredential -containerName $containerName -sqlCredential $sqlCredential -doNotAskForCredential
54-
55-
Invoke-ScriptInNavContainer -containerName $containerName -ScriptBlock { Param([PSCredential]$sqlCredential, $includeTestLibrariesOnly, $testToolkitCountry, $doNotUpdateSymbols, $ImportAction)
56-
57-
if (-not (Test-Path -Path "C:\TestToolKit" -PathType Container)) {
58-
throw "Container $containerName does not include the TestToolkit yet"
53+
if ($version.Major -ge 15) {
54+
if ($version -lt [Version]("15.0.35528.0")) {
55+
throw "Container $containerName (platform version $version) doesn't support the Test Toolkit yet, you need a laster version"
5956
}
60-
61-
$customConfigFile = Join-Path (Get-Item "C:\Program Files\Microsoft Dynamics NAV\*\Service").FullName "CustomSettings.config"
62-
[xml]$customConfig = [System.IO.File]::ReadAllText($customConfigFile)
63-
$databaseServer = $customConfig.SelectSingleNode("//appSettings/add[@key='DatabaseServer']").Value
64-
$databaseInstance = $customConfig.SelectSingleNode("//appSettings/add[@key='DatabaseInstance']").Value
65-
$databaseName = $customConfig.SelectSingleNode("//appSettings/add[@key='DatabaseName']").Value
66-
$managementServicesPort = $customConfig.SelectSingleNode("//appSettings/add[@key='ManagementServicesPort']").Value
67-
if ($databaseInstance) { $databaseServer += "\$databaseInstance" }
68-
69-
$params = @{}
70-
if ($sqlCredential) {
71-
$params = @{ 'Username' = $sqlCredential.UserName; 'Password' = ([System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sqlCredential.Password))) }
57+
if (!$includeTestLibrariesOnly) {
58+
Write-Warning "Importing Microsoft tests isn't yet supported, only test libraries will be imported"
7259
}
73-
if ($testToolkitCountry) {
74-
$fileFilter = "*.$testToolkitCountry.fob"
60+
61+
$appFiles = Invoke-ScriptInBCContainer -containerName $containerName -scriptblock {
62+
"Microsoft_Any.app", "Microsoft_Library Assert.app", "Microsoft_Test Runner.app" | % {
63+
@(get-childitem -Path "C:\Applications\*.*" -recurse -filter $_)
64+
}
7565
}
76-
else {
77-
$fileFilter = "*.fob"
66+
$appFiles | % {
67+
Publish-BCContainerApp -containerName $containerName -appFile ":$($_.FullName)" -sync -install
7868
}
79-
Get-ChildItem -Path "C:\TestToolKit" -Filter $fileFilter | ForEach-Object {
80-
if (!$includeTestLibrariesOnly -or $_.Name.StartsWith("CALTestLibraries")) {
81-
$objectsFile = $_.FullName
82-
Write-Host "Importing Objects from $objectsFile (container path)"
83-
$databaseServerParameter = $databaseServer
84-
85-
if (!$doNotUpdateSymbols) {
86-
Write-Host "Generating Symbols while importing"
87-
# HACK: Parameter insertion...
88-
# generatesymbolreference is not supported by Import-NAVApplicationObject yet
89-
# insert an extra parameter for the finsql command by splitting the filter property
90-
$databaseServerParameter = '",generatesymbolreference=1,ServerName="'+$databaseServer
69+
Write-Host -ForegroundColor Green "TestToolkit successfully imported"
70+
}
71+
else {
72+
$sqlCredential = Get-DefaultSqlCredential -containerName $containerName -sqlCredential $sqlCredential -doNotAskForCredential
73+
Invoke-ScriptInNavContainer -containerName $containerName -ScriptBlock { Param([PSCredential]$sqlCredential, $includeTestLibrariesOnly, $testToolkitCountry, $doNotUpdateSymbols, $ImportAction)
74+
75+
$customConfigFile = Join-Path (Get-Item "C:\Program Files\Microsoft Dynamics NAV\*\Service").FullName "CustomSettings.config"
76+
[xml]$customConfig = [System.IO.File]::ReadAllText($customConfigFile)
77+
$databaseServer = $customConfig.SelectSingleNode("//appSettings/add[@key='DatabaseServer']").Value
78+
$databaseInstance = $customConfig.SelectSingleNode("//appSettings/add[@key='DatabaseInstance']").Value
79+
$databaseName = $customConfig.SelectSingleNode("//appSettings/add[@key='DatabaseName']").Value
80+
$managementServicesPort = $customConfig.SelectSingleNode("//appSettings/add[@key='ManagementServicesPort']").Value
81+
if ($databaseInstance) { $databaseServer += "\$databaseInstance" }
82+
83+
$params = @{}
84+
if ($sqlCredential) {
85+
$params = @{ 'Username' = $sqlCredential.UserName; 'Password' = ([System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sqlCredential.Password))) }
86+
}
87+
if ($testToolkitCountry) {
88+
$fileFilter = "*.$testToolkitCountry.fob"
89+
}
90+
else {
91+
$fileFilter = "*.fob"
92+
}
93+
Get-ChildItem -Path "C:\TestToolKit" -Filter $fileFilter | ForEach-Object {
94+
if (!$includeTestLibrariesOnly -or $_.Name.StartsWith("CALTestLibraries")) {
95+
$objectsFile = $_.FullName
96+
Write-Host "Importing Objects from $objectsFile (container path)"
97+
$databaseServerParameter = $databaseServer
98+
99+
if (!$doNotUpdateSymbols) {
100+
Write-Host "Generating Symbols while importing"
101+
# HACK: Parameter insertion...
102+
# generatesymbolreference is not supported by Import-NAVApplicationObject yet
103+
# insert an extra parameter for the finsql command by splitting the filter property
104+
$databaseServerParameter = '",generatesymbolreference=1,ServerName="'+$databaseServer
105+
}
106+
107+
Import-NAVApplicationObject @params -Path $objectsFile `
108+
-DatabaseName $databaseName `
109+
-DatabaseServer $databaseServerParameter `
110+
-ImportAction $ImportAction `
111+
-SynchronizeSchemaChanges No `
112+
-NavServerName localhost `
113+
-NavServerInstance $ServerInstance `
114+
-NavServerManagementPort "$managementServicesPort" `
115+
-Confirm:$false
116+
91117
}
118+
}
92119

93-
Import-NAVApplicationObject @params -Path $objectsFile `
94-
-DatabaseName $databaseName `
95-
-DatabaseServer $databaseServerParameter `
96-
-ImportAction $ImportAction `
97-
-SynchronizeSchemaChanges No `
98-
-NavServerName localhost `
99-
-NavServerInstance $ServerInstance `
100-
-NavServerManagementPort "$managementServicesPort" `
101-
-Confirm:$false
120+
# Sync after all objects hav been imported
121+
Get-NAVTenant -ServerInstance $ServerInstance | Sync-NavTenant -Mode ForceSync -Force
102122

103-
}
123+
} -ArgumentList $sqlCredential, $includeTestLibrariesOnly, $testToolkitCountry, $doNotUpdateSymbols, $ImportAction
124+
125+
if ($generateSymbols) {
126+
Generate-SymbolsInNavContainer -containerName $containerName -sqlCredential $sqlCredential
104127
}
105-
106-
# Sync after all objects hav been imported
107-
Get-NAVTenant -ServerInstance $ServerInstance | Sync-NavTenant -Mode ForceSync -Force
108-
109-
} -ArgumentList $sqlCredential, $includeTestLibrariesOnly, $testToolkitCountry, $doNotUpdateSymbols, $ImportAction
110-
111-
if ($generateSymbols) {
112-
Generate-SymbolsInNavContainer -containerName $containerName -sqlCredential $sqlCredential
128+
Write-Host -ForegroundColor Green "TestToolkit successfully imported"
113129
}
114-
Write-Host -ForegroundColor Green "TestToolkit successfully imported"
115130
}
116131
Set-Alias -Name Import-TestToolkitToBCContainer -Value Import-TestToolkitToNavContainer
117132
Export-ModuleMember -Function Import-TestToolkitToNavContainer -Alias Import-TestToolkitToBCContainer

0 commit comments

Comments
 (0)
Please sign in to comment.