public void DsfPythonActivityActivity_GetState_ReturnsStateVariable() { //---------------Set up test pack------------------- //------------Setup for test-------------------------- var act = new DsfPythonActivity { 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 ScriptType_GivenIsNew_ShouldSetJavascript() { //---------------Set up test pack------------------- var act = new DsfPythonActivity(); //---------------Assert Precondition---------------- Assert.AreEqual("Python", act.DisplayName); //---------------Execute Test ---------------------- //---------------Test Result ----------------------- Assert.AreEqual(enScriptType.Python, act.ScriptType); }
public void OnConstruction_GivenType_ShouldInheritCorrectly() { //---------------Set up test pack------------------- var act = new DsfPythonActivity(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- //---------------Test Result ----------------------- Assert.IsInstanceOfType(act, typeof(DsfActivityAbstract <string>)); }
public void Script_GivenIsNew_ShouldBeEmpty() { //---------------Set up test pack------------------- var act = new DsfPythonActivity(); //---------------Assert Precondition---------------- Assert.IsInstanceOfType(act, typeof(DsfActivityAbstract <string>)); //---------------Execute Test ---------------------- var displayName = act.Script; //---------------Test Result ----------------------- Assert.AreEqual("", displayName); }
public void UniqueIDDifferent_EmptyCountRecordset_Object_Is_Equal() { //---------------Set up test pack------------------- var dsfPythonActivity = new DsfPythonActivity(); var javascriptActivity = new DsfPythonActivity(); //---------------Assert Precondition---------------- Assert.IsNotNull(dsfPythonActivity); //---------------Execute Test ---------------------- var @equals = dsfPythonActivity.Equals(javascriptActivity); //---------------Test Result ----------------------- Assert.IsFalse(@equals); }
public void Attribute_GivenIsNew_ShouldhaveCorrectValues() { //---------------Set up test pack------------------- var act = new DsfPythonActivity(); //---------------Assert Precondition---------------- Assert.IsNotNull(act); //---------------Execute Test ---------------------- var toolDescriptorInfo = typeof(DsfPythonActivity).GetCustomAttributes(typeof(ToolDescriptorInfo), false).Single() as ToolDescriptorInfo; //---------------Test Result ----------------------- Assert.AreEqual("Scripting", toolDescriptorInfo.Category); Assert.AreEqual("python script", toolDescriptorInfo.FilterTag); Assert.AreEqual("Scripting-Python", toolDescriptorInfo.Icon); Assert.AreEqual("Python", toolDescriptorInfo.Name); }
public void Equals_Given_Different_Object_Is_Not_Equal() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var javascriptActivity = new DsfPythonActivity() { UniqueID = uniqueId, DisplayName = "A" }; var dsfPythonActivity = new DsfPythonActivity() { UniqueID = uniqueId, DisplayName = "ass" }; //---------------Assert Precondition---------------- Assert.IsNotNull(javascriptActivity); //---------------Execute Test ---------------------- var @equals = javascriptActivity.Equals(dsfPythonActivity); //---------------Test Result ----------------------- Assert.IsFalse(@equals); }
public void ScriptType_Different_Object_Is_Not_Equal() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var javascriptActivity = new DsfPythonActivity() { UniqueID = uniqueId, ScriptType = enScriptType.JavaScript }; var dsfPythonActivity = new DsfPythonActivity() { UniqueID = uniqueId, ScriptType = enScriptType.Python }; //---------------Assert Precondition---------------- Assert.IsNotNull(javascriptActivity); //---------------Execute Test ---------------------- var @equals = javascriptActivity.Equals(dsfPythonActivity); //---------------Test Result ----------------------- Assert.IsFalse(@equals); }
public void IncludeFile_Different_Object_Is_Not_Equal_CaseSensitive() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var javascriptActivity = new DsfPythonActivity() { UniqueID = uniqueId, IncludeFile = "AAA" }; var dsfPythonActivity = new DsfPythonActivity() { UniqueID = uniqueId, IncludeFile = "aaa" }; //---------------Assert Precondition---------------- Assert.IsNotNull(javascriptActivity); //---------------Execute Test ---------------------- var @equals = javascriptActivity.Equals(dsfPythonActivity); //---------------Test Result ----------------------- Assert.IsFalse(@equals); }
public void IncludeFile_Same_Object_IsEqual() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var javascriptActivity = new DsfPythonActivity() { UniqueID = uniqueId, IncludeFile = "a" }; var dsfPythonActivity = new DsfPythonActivity() { UniqueID = uniqueId, IncludeFile = "a" }; //---------------Assert Precondition---------------- Assert.IsNotNull(javascriptActivity); //---------------Execute Test ---------------------- var @equals = javascriptActivity.Equals(dsfPythonActivity); //---------------Test Result ----------------------- Assert.IsTrue(@equals); }
public void UniqueIDEquals_EmptyJavascript_Object_IsEqual() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var dsfPythonActivity = new DsfPythonActivity() { UniqueID = uniqueId }; var javascriptActivity = new DsfPythonActivity() { UniqueID = uniqueId }; //---------------Assert Precondition---------------- Assert.IsNotNull(dsfPythonActivity); //---------------Execute Test ---------------------- var @equals = dsfPythonActivity.Equals(javascriptActivity); //---------------Test Result ----------------------- Assert.IsTrue(@equals); }
public void EscapeScript_Same_Object_Is_Equal() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var javascriptActivity = new DsfPythonActivity() { UniqueID = uniqueId, EscapeScript = true }; var dsfPythonActivity = new DsfPythonActivity() { UniqueID = uniqueId, EscapeScript = false }; //---------------Assert Precondition---------------- Assert.IsFalse(javascriptActivity.Equals(dsfPythonActivity)); //---------------Execute Test ---------------------- javascriptActivity.EscapeScript = true; dsfPythonActivity.EscapeScript = true; var @equals = javascriptActivity.Equals(dsfPythonActivity); //---------------Test Result ----------------------- Assert.IsTrue(@equals); }