@@ -924,7 +924,7 @@ Configuration CertificateExport_CertByFriendlyName_Config
924
924
$mockGitUserEmail = ' [email protected] '
925
925
$mockGitUserName = ' mock'
926
926
$mockGithubAccessToken = ' 1234567890'
927
- $mockPath = " C:\Windows\Temp "
927
+ $mockPath = $ env: temp
928
928
$mockJobId = ' imy2wgh1ylo9qcpb'
929
929
$mockBuildVersion = ' 2.1.456.0'
930
930
$mockapiUrl = ' https://ci.appveyor.com/api'
@@ -1383,6 +1383,7 @@ Configuration Example
1383
1383
$script :mockReadmePath = Join-Path - Path $script :mockSchemaFolder - ChildPath ' readme.md'
1384
1384
$script :mockOutputFile = Join-Path - Path $script :mockOutputPath - ChildPath " $ ( $script :mockResourceName ) .md"
1385
1385
$script :mockSavePath = Join-Path - Path $script :mockModulePath - ChildPath " DscResources\$ ( $script :mockResourceName ) \en-US\about_$ ( $script :mockResourceName ) .help.txt"
1386
+ $script :mockOutputSavePath = Join-Path - Path $script :mockOutputPath - ChildPath " about_$ ( $script :mockResourceName ) .help.txt"
1386
1387
$script :mockGetContentReadme = ' # Description
1387
1388
1388
1389
The description of the resource.'
@@ -1455,6 +1456,10 @@ Configuration Example
1455
1456
$InputObject -eq $script :mockPowerShellHelpOutput -and
1456
1457
$FilePath -eq $script :mockSavePath
1457
1458
}
1459
+ $script :outFileOutputInputObject_parameterFilter = {
1460
+ $InputObject -eq $script :mockPowerShellHelpOutput -and
1461
+ $FilePath -eq $script :mockOutputSavePath
1462
+ }
1458
1463
$script :writeWarningDescription_parameterFilter = {
1459
1464
$Message -eq ($script :localizedData.NoDescriptionFileFoundWarning -f $mockResourceName )
1460
1465
}
@@ -1465,6 +1470,10 @@ Configuration Example
1465
1470
$script :newDscResourcePowerShellHelp_parameters = @ {
1466
1471
ModulePath = $script :mockModulePath
1467
1472
}
1473
+ $script :newDscResourcePowerShellHelpOutput_parameters = @ {
1474
+ ModulePath = $script :mockModulePath
1475
+ OutputPath = $script :mockOutputPath
1476
+ }
1468
1477
1469
1478
Context ' When there is no schemas found in the module folder' {
1470
1479
BeforeAll {
@@ -1621,7 +1630,7 @@ Configuration Example
1621
1630
}
1622
1631
}
1623
1632
1624
- Context ' When there is one schema found in the module folder and one example using .EXAMPLE' {
1633
+ Context ' When there is one schema found in the module folder and one example using .EXAMPLE and the OutputPath is specified ' {
1625
1634
BeforeAll {
1626
1635
Mock `
1627
1636
- CommandName Get-ChildItem `
@@ -1654,8 +1663,105 @@ Configuration Example
1654
1663
- MockWith { $script :mockExampleContent }
1655
1664
1656
1665
Mock `
1666
+ - CommandName Out-File
1667
+
1668
+ Mock `
1669
+ - CommandName Write-Warning `
1670
+ - ParameterFilter $script :writeWarningExample_parameterFilter
1671
+
1672
+ Mock `
1673
+ - CommandName Write-Warning `
1674
+ - ParameterFilter $script :writeWarningDescription_parameterFilter
1675
+ }
1676
+
1677
+ It ' Should not throw an exception' {
1678
+ { New-DscResourcePowerShellHelp @script :newDscResourcePowerShellHelpOutput_parameters } | Should -Not - Throw
1679
+ }
1680
+
1681
+ It ' Should produce the correct output' {
1682
+ Assert-MockCalled `
1657
1683
- CommandName Out-File `
1658
- - ParameterFilter $script :outFile_parameterFilter
1684
+ - ParameterFilter $script :outFileOutputInputObject_parameterFilter `
1685
+ - Exactly - Times 1
1686
+ }
1687
+
1688
+ It ' Should call the expected mocks ' {
1689
+ Assert-MockCalled `
1690
+ - CommandName Get-ChildItem `
1691
+ - ParameterFilter $script :getChildItemSchema_parameterFilter `
1692
+ - Exactly - Times 1
1693
+
1694
+ Assert-MockCalled `
1695
+ - CommandName Get-MofSchemaObject `
1696
+ - ParameterFilter $script :getMofSchemaObjectSchema_parameterfilter `
1697
+ - Exactly - Times 1
1698
+
1699
+ Assert-MockCalled `
1700
+ - CommandName Test-Path `
1701
+ - ParameterFilter $script :getTestPathReadme_parameterFilter `
1702
+ - Exactly - Times 1
1703
+
1704
+ Assert-MockCalled `
1705
+ - CommandName Get-Content `
1706
+ - ParameterFilter $script :getContentReadme_parameterFilter `
1707
+ - Exactly - Times 1
1708
+
1709
+ Assert-MockCalled `
1710
+ - CommandName Get-ChildItem `
1711
+ - ParameterFilter $script :getChildItemExample_parameterFilter `
1712
+ - Exactly - Times 1
1713
+
1714
+ Assert-MockCalled `
1715
+ - CommandName Get-DscResourceHelpExampleContent `
1716
+ - ParameterFilter $script :getDscResourceHelpExampleContent_parameterFilter `
1717
+ - Exactly - Times 1
1718
+
1719
+ Assert-MockCalled `
1720
+ - CommandName Write-Warning `
1721
+ - ParameterFilter $script :writeWarningExample_parameterFilter `
1722
+ - Exactly - Times 0
1723
+
1724
+ Assert-MockCalled `
1725
+ - CommandName Write-Warning `
1726
+ - ParameterFilter $script :writeWarningDescription_parameterFilter `
1727
+ - Exactly - Times 0
1728
+ }
1729
+ }
1730
+
1731
+ Context ' When there is one schema found in the module folder and one example using .EXAMPLE and the OutputPath is not specified' {
1732
+ BeforeAll {
1733
+ Mock `
1734
+ - CommandName Get-ChildItem `
1735
+ - ParameterFilter $script :getChildItemSchema_parameterFilter `
1736
+ - MockWith { $script :mockSchemaFiles }
1737
+
1738
+ Mock `
1739
+ - CommandName Get-MofSchemaObject `
1740
+ - ParameterFilter $script :getMofSchemaObjectSchema_parameterfilter `
1741
+ - MockWith { $script :mockGetMofSchemaObject }
1742
+
1743
+ Mock `
1744
+ - CommandName Test-Path `
1745
+ - ParameterFilter $script :getTestPathReadme_parameterFilter `
1746
+ - MockWith { $true }
1747
+
1748
+ Mock `
1749
+ - CommandName Get-Content `
1750
+ - ParameterFilter $script :getContentReadme_parameterFilter `
1751
+ - MockWith { $script :mockGetContentReadme }
1752
+
1753
+ Mock `
1754
+ - CommandName Get-ChildItem `
1755
+ - ParameterFilter $script :getChildItemExample_parameterFilter `
1756
+ - MockWith { $script :mockExampleFiles }
1757
+
1758
+ Mock `
1759
+ - CommandName Get-DscResourceHelpExampleContent `
1760
+ - ParameterFilter $script :getDscResourceHelpExampleContent_parameterFilter `
1761
+ - MockWith { $script :mockExampleContent }
1762
+
1763
+ Mock `
1764
+ - CommandName Out-File
1659
1765
1660
1766
Mock `
1661
1767
- CommandName Write-Warning `
@@ -1693,7 +1799,7 @@ Configuration Example
1693
1799
- ParameterFilter $script :getTestPathReadme_parameterFilter `
1694
1800
- Exactly - Times 1
1695
1801
1696
- Assert-MockCalled `
1802
+ Assert-MockCalled `
1697
1803
- CommandName Get-Content `
1698
1804
- ParameterFilter $script :getContentReadme_parameterFilter `
1699
1805
- Exactly - Times 1
0 commit comments