public void ShouldInvokeInjectScriptLibraries(Mock<ScriptExecutor> executor) { executor.Protected(); executor.Object.Initialize(Enumerable.Empty<string>(), Enumerable.Empty<IScriptPack>(), ""); executor.Setup(e => e.InjectScriptLibraries( It.IsAny<string>(), It.IsAny<FilePreProcessorResult>(), It.IsAny<IDictionary<string, object>>())); var result = new FilePreProcessorResult(); executor.Object.EngineExecute("", new string[] { }, result); executor.Verify(e => e.InjectScriptLibraries( It.IsAny<string>(), result, It.IsAny<IDictionary<string, object>>())); }
public void ShouldInvokeEngineExecute( [Frozen] Mock<IFilePreProcessor> preProcessor, Mock<ScriptExecutor> executor, FilePreProcessorResult result ) { executor.Protected(); preProcessor.Setup(p => p.ProcessScript(It.IsAny<string>())).Returns(result); executor.Setup( e => e.EngineExecute( It.IsAny<string>(), It.IsAny<string[]>(), It.IsAny<FilePreProcessorResult>())); var args = new string[] { }; executor.Object.ExecuteScript("", args); executor.Verify( e => e.EngineExecute( "workingdirectory", args, result)); }
public void ShouldAddReferencesFromScriptLibrary( [Frozen] Mock<IScriptEngine> scriptEngine, Mock<ScriptExecutor> scriptExecutor ) { scriptExecutor.Protected(); var result = new FilePreProcessorResult(); scriptExecutor.Setup(e => e.InjectScriptLibraries(It.IsAny<string>(), result, It.IsAny<IDictionary<string, object>>())) .Callback((string p, FilePreProcessorResult r, IDictionary<string, object> s) => { r.References.Add("Foo.Bar"); }); scriptEngine.Setup(e => e.Execute( It.IsAny<string>(), It.IsAny<string[]>(), It.IsAny<AssemblyReferences>(), It.IsAny<IEnumerable<string>>(), It.IsAny<ScriptPackSession>())); scriptExecutor.Object.Initialize(Enumerable.Empty<string>(), Enumerable.Empty<IScriptPack>()); scriptExecutor.Object.EngineExecute("", new string[] {}, result); scriptEngine.Verify( e => e.Execute( It.IsAny<string>(), It.IsAny<string[]>(), It.Is<AssemblyReferences>(x => x.Paths.Contains("Foo.Bar")), It.IsAny<IEnumerable<string>>(), It.IsAny<ScriptPackSession>()), Times.Once()); }