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 <bool, ScriptDescriptionModel> > selectScript = () => new Tuple <bool, ScriptDescriptionModel>(true, model); Action <ScriptDescriptionModel, ISyntaxVerifier> storeScript = (s, v) => { Assert.AreSame(model, s); Assert.AreSame(verifier.Object, v); }; Func <string, IDisposable> timerFunc = s => new MockDisposable(); var command = new NewScriptCommand(scriptHost.Object, selectScript, storeScript, timerFunc); command.Execute(null); }
public void CanCreateNewScriptWithNullHost() { Func <Tuple <bool, ScriptDescriptionModel> > selectScript = () => new Tuple <bool, ScriptDescriptionModel>(false, null); Action <ScriptDescriptionModel, ISyntaxVerifier> storeScript = (s, v) => { }; Func <string, IDisposable> timerFunc = s => new MockDisposable(); var command = new NewScriptCommand(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 <bool, ScriptDescriptionModel> > selectScript = () => new Tuple <bool, ScriptDescriptionModel>(false, null); Action <ScriptDescriptionModel, ISyntaxVerifier> storeScript = (s, v) => { }; Func <string, IDisposable> timerFunc = s => new MockDisposable(); var command = new NewScriptCommand(scriptHost.Object, selectScript, storeScript, timerFunc); Assert.Throws <CreationOfNewScriptCanceledException>(() => command.Execute(null)); }
public void CanCreateNewScriptWhileHostIsExecuting() { var scriptHost = new Mock <IHostScripts>(); { scriptHost.Setup(s => s.IsExecutingScript) .Returns(true); } Func <Tuple <bool, ScriptDescriptionModel> > selectScript = () => new Tuple <bool, ScriptDescriptionModel>(false, null); Action <ScriptDescriptionModel, ISyntaxVerifier> storeScript = (s, v) => { }; Func <string, IDisposable> timerFunc = s => new MockDisposable(); var command = new NewScriptCommand(scriptHost.Object, selectScript, storeScript, timerFunc); Assert.IsFalse(command.CanExecute(null)); }