Skip to content

Commit 14b8f16

Browse files
committed
fix
1 parent ef95c8b commit 14b8f16

3 files changed

Lines changed: 159 additions & 25 deletions

File tree

docs/Get-FSCPSModelVersion.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
external help file: fscps.tools-help.xml
3+
Module Name: fscps.tools
4+
online version:
5+
schema: 2.0.0
6+
---
7+
8+
# Get-FSCPSModelVersion
9+
10+
## SYNOPSIS
11+
This gets the D365FSC model version
12+
13+
## SYNTAX
14+
15+
```
16+
Get-FSCPSModelVersion [-ModelPath] <String> [-ProgressAction <ActionPreference>] [<CommonParameters>]
17+
```
18+
19+
## DESCRIPTION
20+
This gets the D365FSC model version from the descriptor file by automatically finding the descriptor in the model path
21+
22+
## EXAMPLES
23+
24+
### EXAMPLE 1
25+
```
26+
Get-FSCPSModelVersion -ModelPath "c:\temp\metadata\TestModel"
27+
```
28+
29+
This will get the version information of the TestModel by automatically finding the descriptor file
30+
31+
### EXAMPLE 2
32+
```
33+
Get-FSCPSModelVersion -ModelPath "c:\temp\PackagesLocalDirectory\MyCustomModel"
34+
```
35+
36+
This will get the version information of MyCustomModel including layer name
37+
38+
## PARAMETERS
39+
40+
### -ModelPath
41+
Path to the model folder (automatically searches for Descriptor\*.xml inside)
42+
43+
```yaml
44+
Type: String
45+
Parameter Sets: (All)
46+
Aliases:
47+
48+
Required: True
49+
Position: 1
50+
Default value: None
51+
Accept pipeline input: False
52+
Accept wildcard characters: False
53+
```
54+
55+
### -ProgressAction
56+
{{ Fill ProgressAction Description }}
57+
58+
```yaml
59+
Type: ActionPreference
60+
Parameter Sets: (All)
61+
Aliases: proga
62+
63+
Required: False
64+
Position: Named
65+
Default value: None
66+
Accept pipeline input: False
67+
Accept wildcard characters: False
68+
```
69+
70+
### CommonParameters
71+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
72+
73+
## INPUTS
74+
75+
## OUTPUTS
76+
77+
## NOTES
78+
Tags: D365, FO, Finance, Operations, Model, Version, Descriptor, Metadata
79+
80+
Author: Oleksandr Nikolaiev (@onikolaiev)
81+
82+
## RELATED LINKS

fscps.tools/functions/get-fscpsmodelversion.ps1

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,12 @@
2020
This will get the version information of MyCustomModel including layer name
2121
2222
.NOTES
23+
Tags: D365, FO, Finance, Operations, Model, Version, Descriptor, Metadata
24+
2325
Author: Oleksandr Nikolaiev (@onikolaiev)
26+
2427
#>
2528

26-
# Helper function to convert layer number to layer name
27-
function Get-LayerName {
28-
param([int]$LayerNumber)
29-
30-
switch ($LayerNumber) {
31-
0 { return "SYS" }
32-
1 { return "SYP" }
33-
2 { return "GLS" }
34-
3 { return "GLP" }
35-
4 { return "FPK" }
36-
5 { return "FPP" }
37-
6 { return "SLN" }
38-
7 { return "SLP" }
39-
8 { return "ISV" }
40-
9 { return "ISP" }
41-
10 { return "VAR" }
42-
11 { return "VAP" }
43-
12 { return "CUS" }
44-
13 { return "CUP" }
45-
14 { return "USR" }
46-
15 { return "USP" }
47-
default { return "Unknown" }
48-
}
49-
}
50-
5129
function Get-FSCPSModelVersion {
5230
[CmdletBinding()]
5331
param(
@@ -63,6 +41,31 @@ function Get-FSCPSModelVersion {
6341
if (-not (Test-Path -LiteralPath $ModelPath -PathType Container)) {
6442
throw "Model path '$ModelPath' does not exist or is not a directory"
6543
}
44+
45+
# Helper function to convert layer number to layer name
46+
function Get-LayerName {
47+
param([int]$LayerNumber)
48+
49+
switch ($LayerNumber) {
50+
0 { return "SYS" }
51+
1 { return "SYP" }
52+
2 { return "GLS" }
53+
3 { return "GLP" }
54+
4 { return "FPK" }
55+
5 { return "FPP" }
56+
6 { return "SLN" }
57+
7 { return "SLP" }
58+
8 { return "ISV" }
59+
9 { return "ISP" }
60+
10 { return "VAR" }
61+
11 { return "VAP" }
62+
12 { return "CUS" }
63+
13 { return "CUP" }
64+
14 { return "USR" }
65+
15 { return "USP" }
66+
default { return "Unknown" }
67+
}
68+
}
6669
}
6770

6871
process{
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
Describe "Get-FSCPSModelVersion Unit Tests" -Tag "Unit" {
2+
BeforeAll {
3+
# Place here all things needed to prepare for the tests
4+
}
5+
AfterAll {
6+
# Here is where all the cleanup tasks go
7+
}
8+
9+
Describe "Ensuring unchanged command signature" {
10+
It "should have the expected parameter sets" {
11+
(Get-Command Get-FSCPSModelVersion).ParameterSets.Name | Should -Be '__AllParameterSets'
12+
}
13+
14+
It 'Should have the expected parameter ModelPath' {
15+
$parameter = (Get-Command Get-FSCPSModelVersion).Parameters['ModelPath']
16+
$parameter.Name | Should -Be 'ModelPath'
17+
$parameter.ParameterType.ToString() | Should -Be System.String
18+
$parameter.IsDynamic | Should -Be $False
19+
$parameter.ParameterSets.Keys | Should -Be '__AllParameterSets'
20+
$parameter.ParameterSets.Keys | Should -Contain '__AllParameterSets'
21+
$parameter.ParameterSets['__AllParameterSets'].IsMandatory | Should -Be $True
22+
$parameter.ParameterSets['__AllParameterSets'].Position | Should -Be 0
23+
$parameter.ParameterSets['__AllParameterSets'].ValueFromPipeline | Should -Be $False
24+
$parameter.ParameterSets['__AllParameterSets'].ValueFromPipelineByPropertyName | Should -Be $False
25+
$parameter.ParameterSets['__AllParameterSets'].ValueFromRemainingArguments | Should -Be $False
26+
}
27+
It 'Should have the expected parameter ProgressAction' {
28+
$parameter = (Get-Command Get-FSCPSModelVersion).Parameters['ProgressAction']
29+
$parameter.Name | Should -Be 'ProgressAction'
30+
$parameter.ParameterType.ToString() | Should -Be System.Management.Automation.ActionPreference
31+
$parameter.IsDynamic | Should -Be $False
32+
$parameter.ParameterSets.Keys | Should -Be '__AllParameterSets'
33+
$parameter.ParameterSets.Keys | Should -Contain '__AllParameterSets'
34+
$parameter.ParameterSets['__AllParameterSets'].IsMandatory | Should -Be $False
35+
$parameter.ParameterSets['__AllParameterSets'].Position | Should -Be -2147483648
36+
$parameter.ParameterSets['__AllParameterSets'].ValueFromPipeline | Should -Be $False
37+
$parameter.ParameterSets['__AllParameterSets'].ValueFromPipelineByPropertyName | Should -Be $False
38+
$parameter.ParameterSets['__AllParameterSets'].ValueFromRemainingArguments | Should -Be $False
39+
}
40+
}
41+
42+
Describe "Testing parameterset __AllParameterSets" {
43+
<#
44+
__AllParameterSets -ModelPath
45+
__AllParameterSets -ModelPath -ProgressAction
46+
#>
47+
}
48+
49+
}

0 commit comments

Comments
 (0)