예제 #1
0
        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);
        }
예제 #2
0
        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));
        }
예제 #3
0
        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));
        }
예제 #4
0
        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));
        }