@@ -16,7 +16,8 @@ public static DebugScriptExecutor CreateScriptExecutor(
1616 Mock < IFileSystem > fileSystem = null ,
1717 Mock < IFilePreProcessor > fileProcessor = null ,
1818 Mock < IScriptEngine > scriptEngine = null ,
19- Mock < IScriptHostFactory > scriptHostFactory = null )
19+ Mock < IScriptHostFactory > scriptHostFactory = null ,
20+ Mock < ICompiledDllDebugger > compiledDllDebugger = null )
2021 {
2122 if ( fileSystem == null )
2223 {
@@ -40,13 +41,15 @@ public static DebugScriptExecutor CreateScriptExecutor(
4041 scriptEngine . Setup ( e => e . CreateSession ( It . IsAny < ScriptHost > ( ) ) ) . Returns ( mockSession . Object ) ;
4142 }
4243
44+ compiledDllDebugger = compiledDllDebugger ?? new Mock < ICompiledDllDebugger > ( ) ;
45+
4346 if ( scriptHostFactory == null )
4447 {
45- return new DebugScriptExecutor ( fileSystem . Object , fileProcessor . Object , scriptEngine . Object ) ;
48+ return new DebugScriptExecutor ( fileSystem . Object , fileProcessor . Object , scriptEngine . Object , compiledDllDebugger . Object ) ;
4649 }
4750 else
4851 {
49- return new DebugScriptExecutor ( fileSystem . Object , fileProcessor . Object , scriptEngine . Object , scriptHostFactory . Object ) ;
52+ return new DebugScriptExecutor ( fileSystem . Object , fileProcessor . Object , scriptEngine . Object , compiledDllDebugger . Object , scriptHostFactory . Object ) ;
5053 }
5154 }
5255
@@ -175,6 +178,46 @@ public void ShouldThrowCompilationExceptionIfCompilationFails()
175178 compilationResult . Verify ( r => r . ErrorMessage , Times . Once ( ) ) ;
176179 compilationResult . Verify ( r => r . Success , Times . Once ( ) ) ;
177180 }
181+
182+ [ Fact ]
183+ public void ShouldRunCompileAssemblyRunnerOnOutputPathIfCompilationSucceeds ( )
184+ {
185+ // arrange
186+ var scriptEngine = new Mock < IScriptEngine > ( ) ;
187+ var session = new Mock < ISession > ( ) ;
188+ var submission = new Mock < ISubmission < object > > ( ) ;
189+ var compilation = new Mock < ICompilation > ( ) ;
190+ var compilationResult = new Mock < ICompilationResult > ( ) ;
191+ var compiledDllDebugger = new Mock < ICompiledDllDebugger > ( ) ;
192+
193+ compilationResult . Setup ( r => r . Success ) . Returns ( true ) . Verifiable ( ) ;
194+
195+ const string PathToScript = @"C:\script.csx" ;
196+ const string BinDir = @"C:\bin" ;
197+ const string OutputDllName = "script.dll" ;
198+ var dllFullPath = Path . Combine ( BinDir , OutputDllName ) ;
199+
200+ scriptEngine . Setup ( e => e . CreateSession ( It . IsAny < ScriptHost > ( ) ) ) . Returns ( session . Object ) ;
201+ scriptEngine . SetupProperty ( e => e . BaseDirectory ) ;
202+
203+ session . Setup ( s => s . CompileSubmission < object > ( It . IsAny < string > ( ) ) ) . Returns ( submission . Object ) ;
204+ session . Setup ( s => s . Engine ) . Returns ( scriptEngine . Object ) ;
205+
206+ submission . Setup ( s => s . Compilation ) . Returns ( compilation . Object ) ;
207+
208+ compilation . Setup ( c => c . Emit ( It . IsAny < Stream > ( ) , It . IsAny < Stream > ( ) ) ) . Returns ( compilationResult . Object ) . Verifiable ( ) ;
209+
210+ compiledDllDebugger . Setup ( r => r . Run ( dllFullPath , session . Object ) ) . Verifiable ( ) ;
211+
212+ var scriptExecutor = DebugScriptExecutorTests . CreateScriptExecutor ( scriptEngine : scriptEngine , compiledDllDebugger : compiledDllDebugger ) ;
213+
214+ // act
215+ scriptExecutor . Execute ( PathToScript , Enumerable . Empty < string > ( ) , Enumerable . Empty < IScriptPack > ( ) ) ;
216+
217+ // assert
218+ compilationResult . Verify ( r => r . Success , Times . Once ( ) ) ;
219+ compiledDllDebugger . Verify ( r => r . Run ( dllFullPath , session . Object ) , Times . Once ( ) ) ;
220+ }
178221 }
179222 }
180223}
0 commit comments