public void JavascriptActivity_ExecuteTool()
        {
            //---------------Set up test pack-------------------
            var uniqueId           = Guid.NewGuid().ToString();
            var javascriptActivity = new DsfJavascriptActivity()
            {
                UniqueID = uniqueId, EscapeScript = true
            };
            var dsfJavascriptActivity = new DsfJavascriptActivity()
            {
                UniqueID = uniqueId, EscapeScript = false
            };

            var mockObject    = new Mock <IDSFDataObject>();
            var env           = new ExecutionEnvironment();
            var esbChannel    = new Mock <IEsbChannel>().Object;
            var errorResultTO = new ErrorResultTO();

            mockObject.Setup(o => o.Environment).Returns(() => env);
            mockObject.Setup(o => o.IsDebugMode()).Returns(() => true);
            //---------------Execute Test ----------------------
            javascriptActivity.Execute(mockObject.Object, 0);
            //---------------Test Result -----------------------
            Assert.AreEqual("True", env.HasErrors().ToString());
        }
        public void DsfJavascriptActivity_GetState_ReturnsStateVariable()
        {
            //---------------Set up test pack-------------------
            //------------Setup for test--------------------------
            var act = new DsfJavascriptActivity {
                Script = "def add", EscapeScript = true, IncludeFile = "temp.py", Result = "[[res]]"
            };
            //------------Execute Test---------------------------
            var stateItems = act.GetState();

            Assert.AreEqual(4, stateItems.Count());

            var expectedResults = new[]
            {
                new StateVariable
                {
                    Name  = "Script",
                    Type  = StateVariable.StateType.Input,
                    Value = "def add"
                },
                new StateVariable
                {
                    Name  = "IncludeFile",
                    Type  = StateVariable.StateType.Input,
                    Value = "temp.py"
                },
                new StateVariable
                {
                    Name  = "EscapeScript",
                    Type  = StateVariable.StateType.Input,
                    Value = "True"
                },
                new StateVariable
                {
                    Name  = "Result",
                    Type  = StateVariable.StateType.Output,
                    Value = "[[res]]"
                }
            };

            var iter = act.GetState().Select(
                (item, index) => new
            {
                value       = item,
                expectValue = expectedResults[index]
            }
                );

            //------------Assert Results-------------------------
            foreach (var entry in iter)
            {
                Assert.AreEqual(entry.expectValue.Name, entry.value.Name);
                Assert.AreEqual(entry.expectValue.Type, entry.value.Type);
                Assert.AreEqual(entry.expectValue.Value, entry.value.Value);
            }
        }
        public void GivenFunctionNotInExternalFile_Execute_Javascript_ShouldNotExecuteFunction()
        {
            var activity = new DsfJavascriptActivity();

            Assert.IsNotNull(activity);
            activity.Script     = "return \"someValue\".endsWith(\"e\")";
            activity.ScriptType = enScriptType.JavaScript;
            activity.Execute(DataObject, 0);
            Assert.AreEqual(1, DataObject.Environment.Errors.Count);
        }
        public void ScriptType_GivenIsNew_ShouldSetJavascript()
        {
            //---------------Set up test pack-------------------
            var act = new DsfJavascriptActivity();

            //---------------Assert Precondition----------------
            Assert.AreEqual("JavaScript", act.DisplayName);
            //---------------Execute Test ----------------------
            //---------------Test Result -----------------------
            Assert.AreEqual(enScriptType.JavaScript, act.ScriptType);
        }
        public void OnConstruction_GivenType_ShouldInheritCorrectly()
        {
            //---------------Set up test pack-------------------
            var act = new DsfJavascriptActivity();

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------

            //---------------Test Result -----------------------
            Assert.IsInstanceOfType(act, typeof(DsfActivityAbstract <string>));
        }
        public void Script_GivenIsNew_ShouldBeEmpty()
        {
            //---------------Set up test pack-------------------
            var act = new DsfJavascriptActivity();

            //---------------Assert Precondition----------------
            Assert.IsInstanceOfType(act, typeof(DsfActivityAbstract <string>));
            //---------------Execute Test ----------------------
            var displayName = act.Script;

            //---------------Test Result -----------------------
            Assert.AreEqual("", displayName);
        }
Beispiel #7
0
        public void UniqueIDDifferent_EmptyCountRecordset_Object_Is_Equal()
        {
            //---------------Set up test pack-------------------
            var dsfJavascriptActivity = new DsfJavascriptActivity();
            var javascriptActivity    = new DsfJavascriptActivity();

            //---------------Assert Precondition----------------
            Assert.IsNotNull(dsfJavascriptActivity);
            //---------------Execute Test ----------------------
            var @equals = dsfJavascriptActivity.Equals(javascriptActivity);

            //---------------Test Result -----------------------
            Assert.IsFalse(equals);
        }
        public void Attribute_GivenIsNew_ShouldhaveCorrectValues()
        {
            //---------------Set up test pack-------------------
            var act = new DsfJavascriptActivity();

            //---------------Assert Precondition----------------
            Assert.IsNotNull(act);
            //---------------Execute Test ----------------------
            var toolDescriptorInfo = typeof(DsfJavascriptActivity).GetCustomAttributes(typeof(ToolDescriptorInfo), false).Single() as ToolDescriptorInfo;

            //---------------Test Result -----------------------

            Assert.AreEqual("Scripting", toolDescriptorInfo.Category);
            Assert.AreEqual("javascript script JSON JS", toolDescriptorInfo.FilterTag);
            Assert.AreEqual("Scripting-JavaScript", toolDescriptorInfo.Icon);
            Assert.AreEqual("JavaScript", toolDescriptorInfo.Name);
        }
Beispiel #9
0
        public void Equals_Given_Different_Object_Is_Not_Equal()
        {
            //---------------Set up test pack-------------------
            var uniqueId           = Guid.NewGuid().ToString();
            var javascriptActivity = new DsfJavascriptActivity()
            {
                UniqueID = uniqueId, DisplayName = "A"
            };
            var dsfJavascriptActivity = new DsfJavascriptActivity()
            {
                UniqueID = uniqueId, DisplayName = "ass"
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(javascriptActivity);
            //---------------Execute Test ----------------------
            var @equals = javascriptActivity.Equals(dsfJavascriptActivity);

            //---------------Test Result -----------------------
            Assert.IsFalse(equals);
        }
Beispiel #10
0
        public void ScriptType_Different_Object_Is_Not_Equal()
        {
            //---------------Set up test pack-------------------
            var uniqueId           = Guid.NewGuid().ToString();
            var javascriptActivity = new DsfJavascriptActivity()
            {
                UniqueID = uniqueId, ScriptType = enScriptType.JavaScript
            };
            var dsfJavascriptActivity = new DsfJavascriptActivity()
            {
                UniqueID = uniqueId, ScriptType = enScriptType.Python
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(javascriptActivity);
            //---------------Execute Test ----------------------
            var @equals = javascriptActivity.Equals(dsfJavascriptActivity);

            //---------------Test Result -----------------------
            Assert.IsFalse(equals);
        }
Beispiel #11
0
        public void IncludeFile_Different_Object_Is_Not_Equal_CaseSensitive()
        {
            //---------------Set up test pack-------------------
            var uniqueId           = Guid.NewGuid().ToString();
            var javascriptActivity = new DsfJavascriptActivity()
            {
                UniqueID = uniqueId, IncludeFile = "AAA"
            };
            var dsfJavascriptActivity = new DsfJavascriptActivity()
            {
                UniqueID = uniqueId, IncludeFile = "aaa"
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(javascriptActivity);
            //---------------Execute Test ----------------------
            var @equals = javascriptActivity.Equals(dsfJavascriptActivity);

            //---------------Test Result -----------------------
            Assert.IsFalse(equals);
        }
Beispiel #12
0
        public void IncludeFile_Same_Object_IsEqual()
        {
            //---------------Set up test pack-------------------
            var uniqueId           = Guid.NewGuid().ToString();
            var javascriptActivity = new DsfJavascriptActivity()
            {
                UniqueID = uniqueId, IncludeFile = "a"
            };
            var dsfJavascriptActivity = new DsfJavascriptActivity()
            {
                UniqueID = uniqueId, IncludeFile = "a"
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(javascriptActivity);
            //---------------Execute Test ----------------------
            var @equals = javascriptActivity.Equals(dsfJavascriptActivity);

            //---------------Test Result -----------------------
            Assert.IsTrue(equals);
        }
Beispiel #13
0
        public void UniqueIDEquals_EmptyJavascript_Object_IsEqual()
        {
            //---------------Set up test pack-------------------
            var uniqueId = Guid.NewGuid().ToString();
            var dsfJavascriptActivity = new DsfJavascriptActivity()
            {
                UniqueID = uniqueId
            };
            var javascriptActivity = new DsfJavascriptActivity()
            {
                UniqueID = uniqueId
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(dsfJavascriptActivity);
            //---------------Execute Test ----------------------
            var @equals = dsfJavascriptActivity.Equals(javascriptActivity);

            //---------------Test Result -----------------------
            Assert.IsTrue(equals);
        }
Beispiel #14
0
        public void EscapeScript_Same_Object_Is_Equal()
        {
            //---------------Set up test pack-------------------
            var uniqueId           = Guid.NewGuid().ToString();
            var javascriptActivity = new DsfJavascriptActivity()
            {
                UniqueID = uniqueId, EscapeScript = true
            };
            var dsfJavascriptActivity = new DsfJavascriptActivity()
            {
                UniqueID = uniqueId, EscapeScript = false
            };

            //---------------Assert Precondition----------------
            Assert.IsFalse(javascriptActivity.Equals(dsfJavascriptActivity));
            //---------------Execute Test ----------------------
            javascriptActivity.EscapeScript    = true;
            dsfJavascriptActivity.EscapeScript = true;
            var @equals = javascriptActivity.Equals(dsfJavascriptActivity);

            //---------------Test Result -----------------------
            Assert.IsTrue(@equals);
        }