@@ -1538,6 +1538,7 @@ Configuration Example
1538
1538
$script :mockReadmePath = Join-Path - Path $script :mockSchemaFolder - ChildPath ' readme.md'
1539
1539
$script :mockOutputFile = Join-Path - Path $script :mockOutputPath - ChildPath " $ ( $script :mockResourceName ) .md"
1540
1540
$script :mockSavePath = Join-Path - Path $script :mockModulePath - ChildPath " DscResources\$ ( $script :mockResourceName ) \en-US\about_$ ( $script :mockResourceName ) .help.txt"
1541
+ $script :mockOutputSavePath = Join-Path - Path $script :mockOutputPath - ChildPath " about_$ ( $script :mockResourceName ) .help.txt"
1541
1542
$script :mockGetContentReadme = ' # Description
1542
1543
1543
1544
The description of the resource.'
@@ -1609,6 +1610,10 @@ Configuration Example
1609
1610
$InputObject -eq $script :mockPowerShellHelpOutput -and
1610
1611
$FilePath -eq $script :mockSavePath
1611
1612
}
1613
+ $script :outFileOutputInputObject_parameterFilter = {
1614
+ $InputObject -eq $script :mockPowerShellHelpOutput -and
1615
+ $FilePath -eq $script :mockOutputSavePath
1616
+ }
1612
1617
$script :writeWarningDescription_parameterFilter = {
1613
1618
$Message -eq ($script :localizedData.NoDescriptionFileFoundWarning -f $mockResourceName )
1614
1619
}
@@ -1619,6 +1624,10 @@ Configuration Example
1619
1624
$script :newDscResourcePowerShellHelp_parameters = @ {
1620
1625
ModulePath = $script :mockModulePath
1621
1626
}
1627
+ $script :newDscResourcePowerShellHelpOutput_parameters = @ {
1628
+ ModulePath = $script :mockModulePath
1629
+ OutputPath = $script :mockOutputPath
1630
+ }
1622
1631
1623
1632
Context ' When there is no schemas found in the module folder' {
1624
1633
BeforeAll {
@@ -1775,7 +1784,7 @@ Configuration Example
1775
1784
}
1776
1785
}
1777
1786
1778
- Context ' When there is one schema found in the module folder and one example using .EXAMPLE' {
1787
+ Context ' When there is one schema found in the module folder and one example using .EXAMPLE and the OutputPath is specified ' {
1779
1788
BeforeAll {
1780
1789
Mock `
1781
1790
- CommandName Get-ChildItem `
@@ -1808,8 +1817,105 @@ Configuration Example
1808
1817
- MockWith { $script :mockExampleContent }
1809
1818
1810
1819
Mock `
1820
+ - CommandName Out-File
1821
+
1822
+ Mock `
1823
+ - CommandName Write-Warning `
1824
+ - ParameterFilter $script :writeWarningExample_parameterFilter
1825
+
1826
+ Mock `
1827
+ - CommandName Write-Warning `
1828
+ - ParameterFilter $script :writeWarningDescription_parameterFilter
1829
+ }
1830
+
1831
+ It ' Should not throw an exception' {
1832
+ { New-DscResourcePowerShellHelp @script :newDscResourcePowerShellHelpOutput_parameters } | Should -Not - Throw
1833
+ }
1834
+
1835
+ It ' Should produce the correct output' {
1836
+ Assert-MockCalled `
1811
1837
- CommandName Out-File `
1812
- - ParameterFilter $script :outFile_parameterFilter
1838
+ - ParameterFilter $script :outFileOutputInputObject_parameterFilter `
1839
+ - Exactly - Times 1
1840
+ }
1841
+
1842
+ It ' Should call the expected mocks ' {
1843
+ Assert-MockCalled `
1844
+ - CommandName Get-ChildItem `
1845
+ - ParameterFilter $script :getChildItemSchema_parameterFilter `
1846
+ - Exactly - Times 1
1847
+
1848
+ Assert-MockCalled `
1849
+ - CommandName Get-MofSchemaObject `
1850
+ - ParameterFilter $script :getMofSchemaObjectSchema_parameterfilter `
1851
+ - Exactly - Times 1
1852
+
1853
+ Assert-MockCalled `
1854
+ - CommandName Test-Path `
1855
+ - ParameterFilter $script :getTestPathReadme_parameterFilter `
1856
+ - Exactly - Times 1
1857
+
1858
+ Assert-MockCalled `
1859
+ - CommandName Get-Content `
1860
+ - ParameterFilter $script :getContentReadme_parameterFilter `
1861
+ - Exactly - Times 1
1862
+
1863
+ Assert-MockCalled `
1864
+ - CommandName Get-ChildItem `
1865
+ - ParameterFilter $script :getChildItemExample_parameterFilter `
1866
+ - Exactly - Times 1
1867
+
1868
+ Assert-MockCalled `
1869
+ - CommandName Get-DscResourceHelpExampleContent `
1870
+ - ParameterFilter $script :getDscResourceHelpExampleContent_parameterFilter `
1871
+ - Exactly - Times 1
1872
+
1873
+ Assert-MockCalled `
1874
+ - CommandName Write-Warning `
1875
+ - ParameterFilter $script :writeWarningExample_parameterFilter `
1876
+ - Exactly - Times 0
1877
+
1878
+ Assert-MockCalled `
1879
+ - CommandName Write-Warning `
1880
+ - ParameterFilter $script :writeWarningDescription_parameterFilter `
1881
+ - Exactly - Times 0
1882
+ }
1883
+ }
1884
+
1885
+ Context ' When there is one schema found in the module folder and one example using .EXAMPLE and the OutputPath is not specified' {
1886
+ BeforeAll {
1887
+ Mock `
1888
+ - CommandName Get-ChildItem `
1889
+ - ParameterFilter $script :getChildItemSchema_parameterFilter `
1890
+ - MockWith { $script :mockSchemaFiles }
1891
+
1892
+ Mock `
1893
+ - CommandName Get-MofSchemaObject `
1894
+ - ParameterFilter $script :getMofSchemaObjectSchema_parameterfilter `
1895
+ - MockWith { $script :mockGetMofSchemaObject }
1896
+
1897
+ Mock `
1898
+ - CommandName Test-Path `
1899
+ - ParameterFilter $script :getTestPathReadme_parameterFilter `
1900
+ - MockWith { $true }
1901
+
1902
+ Mock `
1903
+ - CommandName Get-Content `
1904
+ - ParameterFilter $script :getContentReadme_parameterFilter `
1905
+ - MockWith { $script :mockGetContentReadme }
1906
+
1907
+ Mock `
1908
+ - CommandName Get-ChildItem `
1909
+ - ParameterFilter $script :getChildItemExample_parameterFilter `
1910
+ - MockWith { $script :mockExampleFiles }
1911
+
1912
+ Mock `
1913
+ - CommandName Get-DscResourceHelpExampleContent `
1914
+ - ParameterFilter $script :getDscResourceHelpExampleContent_parameterFilter `
1915
+ - MockWith { $script :mockExampleContent }
1916
+
1917
+ Mock `
1918
+ - CommandName Out-File
1813
1919
1814
1920
Mock `
1815
1921
- CommandName Write-Warning `
@@ -1847,7 +1953,7 @@ Configuration Example
1847
1953
- ParameterFilter $script :getTestPathReadme_parameterFilter `
1848
1954
- Exactly - Times 1
1849
1955
1850
- Assert-MockCalled `
1956
+ Assert-MockCalled `
1851
1957
- CommandName Get-Content `
1852
1958
- ParameterFilter $script :getContentReadme_parameterFilter `
1853
1959
- Exactly - Times 1
0 commit comments