public void CreateNewScript() { var verifier = new Mock <ISyntaxVerifier>(); var scriptHost = new Mock <IHostScripts>(); { scriptHost.Setup(s => s.IsExecutingScript) .Returns(true); scriptHost.Setup(s => s.VerifySyntax(It.IsAny <ScriptLanguage>())) .Returns(verifier.Object) .Verifiable(); } var context = new Mock <IContextAware>(); var model = new ScriptDescriptionModel(context.Object, ScriptLanguage.IronPython); Func <Tuple <FileInfo, ScriptDescriptionModel> > selectScript = () => new Tuple <FileInfo, ScriptDescriptionModel>(new FileInfo(@"c:\temp\file.txt"), model); Action <ScriptDescriptionModel, FileInfo, ISyntaxVerifier> storeScript = (s, f, v) => { Assert.AreSame(model, s); Assert.AreSame(verifier.Object, v); }; Func <string, IDisposable> timerFunc = s => new MockDisposable(); var command = new OpenScriptCommand(scriptHost.Object, selectScript, storeScript, timerFunc); command.Execute(null); }
public void CanLoadScriptWithNullHost() { Func <Tuple <FileInfo, ScriptDescriptionModel> > selectScript = () => new Tuple <FileInfo, ScriptDescriptionModel>(new FileInfo(@"c:\temp\file.txt"), null); Action <ScriptDescriptionModel, FileInfo, ISyntaxVerifier> storeScript = (s, f, v) => { }; Func <string, IDisposable> timerFunc = s => new MockDisposable(); var command = new OpenScriptCommand(null, selectScript, storeScript, timerFunc); Assert.IsFalse(command.CanExecute(null)); }
public void CreateNewScriptWithoutSelectingScriptLanguage() { var scriptHost = new Mock <IHostScripts>(); { scriptHost.Setup(s => s.IsExecutingScript) .Returns(true); } Func <Tuple <FileInfo, ScriptDescriptionModel> > selectScript = () => new Tuple <FileInfo, ScriptDescriptionModel>(null, null); Action <ScriptDescriptionModel, FileInfo, ISyntaxVerifier> storeScript = (s, f, v) => { }; Func <string, IDisposable> timerFunc = s => new MockDisposable(); var command = new OpenScriptCommand(scriptHost.Object, selectScript, storeScript, timerFunc); Assert.Throws <LoadingOfScriptCanceledException>(() => command.Execute(null)); }
public void CanLoadScriptWhileHostIsExecuting() { var scriptHost = new Mock <IHostScripts>(); { scriptHost.Setup(s => s.IsExecutingScript) .Returns(true); } Func <Tuple <FileInfo, ScriptDescriptionModel> > selectScript = () => new Tuple <FileInfo, ScriptDescriptionModel>(new FileInfo(@"c:\temp\file.txt"), null); Action <ScriptDescriptionModel, FileInfo, ISyntaxVerifier> storeScript = (s, f, v) => { }; Func <string, IDisposable> timerFunc = s => new MockDisposable(); var command = new OpenScriptCommand(scriptHost.Object, selectScript, storeScript, timerFunc); Assert.IsFalse(command.CanExecute(null)); }