@@ -134,4 +134,58 @@ Describe "SetModuleContent" {
134134 }
135135 }
136136
137- }
137+ Context " Adds a newline before the content of each script file" {
138+ ${global :mock get content index} = 1
139+
140+ Mock Get-Content - ModuleName ModuleBuilder {
141+ " Script Content"
142+ " File $ ( (${global :mock get content index} ++ )) "
143+ " From $Path "
144+ }
145+
146+ Mock Resolve-Path - ModuleName ModuleBuilder {
147+ if ($path -match " TestDrive:" ) {
148+ $path -replace " TestDrive:\\" , " .\"
149+ } else {
150+ write-error " $path not found"
151+ }
152+ } - ParameterFilter { $Relative }
153+
154+
155+ InModuleScope ModuleBuilder {
156+ $Files = " using module Configuration" ,
157+ " TestDrive:\Private\First.ps1" ,
158+ " TestDrive:\Private\Second.ps1" ,
159+ " TestDrive:\Public\Third.ps1" ,
160+ " Export-ModuleMember Stuff"
161+ SetModuleContent - Source $Files - Output TestDrive:\Output.psm1
162+ }
163+
164+ It " Calls get-content on every source file" {
165+ Assert-MockCalled Get-Content - ModuleName ModuleBuilder - ParameterFilter { $Path -eq " .\Private\First.ps1" }
166+ Assert-MockCalled Get-Content - ModuleName ModuleBuilder - ParameterFilter { $Path -eq " .\Private\Second.ps1" }
167+ Assert-MockCalled Get-Content - ModuleName ModuleBuilder - ParameterFilter { $Path -eq " .\Public\Third.ps1" }
168+ }
169+
170+ It " Copies all three files into the Output" {
171+ $Content = Get-Content TestDrive:\Output.psm1 - Raw
172+ $Content | Should -Match " File 1"
173+ $Content | Should -Match " First.ps1"
174+
175+ $Content | Should -Match " File 2"
176+ $Content | Should -Match " Second.ps1"
177+
178+ $Content | Should -Match " File 3"
179+ $Content | Should -Match " Third.ps1"
180+ }
181+
182+ It " Include a new line before the content of each script file" {
183+ # Replacing CRLF to LF to support cross-platform testing.
184+ $Content = (Get-Content TestDrive:\Output.psm1 - Raw) -replace ' \r?\n' , " `n "
185+
186+ $Content | Should -Match " \#Region\ '\.\\Private\\First\.ps1'\ -1\n{1,}"
187+ $Content | Should -Match " \#Region\ '\.\\Private\\Second\.ps1'\ -1\n{1,}"
188+ $Content | Should -Match " \#Region\ '\.\\Public\\Third\.ps1'\ -1\n{1,}"
189+ }
190+ }
191+ }
0 commit comments