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