public void IndexActivity_GetInputs_Expected_Five_Input()
        {
            DsfIndexActivity testAct = new DsfIndexActivity();

            IBinaryDataList inputs = testAct.GetInputs();

            // remove test datalist ;)

            Assert.AreEqual(6, inputs.FetchAllEntries().Count);
        }
        public void IndexActivity_GetOutputs_Expected_One_Output()
        {
            DsfIndexActivity testAct = new DsfIndexActivity();

            IBinaryDataList outputs = testAct.GetOutputs();

            // remove test datalist ;)

            Assert.AreEqual(1, outputs.FetchAllEntries().Count);
        }
        public void DsfIndexActivity_UpdateForEachOutputs_NullUpdates_DoesNothing()
        {
            //------------Setup for test--------------------------
            const string result = "[[res]]";
            var          act    = new DsfIndexActivity {
                InField = "[[CompanyName]]", Index = "First Occurance", Characters = "2", Direction = "Left To Right", Result = result
            };

            act.UpdateForEachOutputs(null);
            //------------Assert Results-------------------------
            Assert.AreEqual(result, act.Result);
        }
        protected override void BuildDataList()
        {
            List <Tuple <string, string> > variableList;

            ScenarioContext.Current.TryGetValue("variableList", out variableList);

            if (variableList == null)
            {
                variableList = new List <Tuple <string, string> >();
                ScenarioContext.Current.Add("variableList", variableList);
            }

            variableList.Add(new Tuple <string, string>(ResultVariable, ""));
            var    resultVariable = ResultVariable;
            string resultVar;

            if (ScenarioContext.Current.TryGetValue("resultVariable", out resultVar))
            {
                resultVariable = resultVar;
                var resultVars = resultVariable.Split(',');
                variableList.AddRange(resultVars.Select(resVar => new Tuple <string, string>(resVar, "")));
            }
            BuildShapeAndTestData();

            string inField;

            ScenarioContext.Current.TryGetValue("inField", out inField);
            string index;

            ScenarioContext.Current.TryGetValue("index", out index);
            string characters;

            ScenarioContext.Current.TryGetValue("characters", out characters);
            string direction;

            ScenarioContext.Current.TryGetValue("direction", out direction);

            var findIndex = new DsfIndexActivity
            {
                Result     = resultVariable,
                InField    = inField,
                Index      = index,
                Characters = characters,
                Direction  = direction
            };

            TestStartNode = new FlowStep
            {
                Action = findIndex
            };
            ScenarioContext.Current.Add("activity", findIndex);
        }
        public void DsfIndexActivity_UpdateForEachInputs_NullUpdates_DoesNothing()
        {
            //------------Setup for test--------------------------
            const string inField    = "[[CompanyName]]";
            const string characters = "2";
            var          act        = new DsfIndexActivity {
                InField = inField, Index = "First Occurance", Characters = characters, Direction = "Left To Right", Result = "[[res]]"
            };

            //------------Execute Test---------------------------
            act.UpdateForEachInputs(null);
            //------------Assert Results-------------------------
            Assert.AreEqual(inField, act.InField);
            Assert.AreEqual(characters, act.Characters);
        }
        public void DsfBaseActivity_GetOutputs_Called_ShouldReturnListWithResultValueInIt()
        {
            //------------Setup for test--------------------------
            const string inField    = "[[CompanyName]]";
            const string characters = "2";
            var          act        = new DsfIndexActivity {
                InField = inField, Index = "First Occurance", Characters = characters, Direction = "Left To Right", Result = "[[res]]"
            };

            //------------Execute Test---------------------------
            var outputs = act.GetOutputs();

            //------------Assert Results-------------------------
            Assert.AreEqual(1, outputs.Count);
            Assert.AreEqual("[[res]]", outputs[0]);
        }
        public void DsfIndexActivity_UpdateForEachOutputs_1Updates_UpdateCommandResult()
        {
            //------------Setup for test--------------------------
            var act = new DsfIndexActivity {
                InField = "[[CompanyName]]", Index = "First Occurance", Characters = "2", Direction = "Left To Right", Result = "[[res]]"
            };

            var tuple1 = new Tuple <string, string>("[[res]]", "Test");

            //------------Execute Test---------------------------
            act.UpdateForEachOutputs(new List <Tuple <string, string> > {
                tuple1
            });
            //------------Assert Results-------------------------
            Assert.AreEqual("Test", act.Result);
        }
        public void DsfIndexActivity_GetForEachOutputs_WhenHasResult_ReturnsOutputList()
        {
            //------------Setup for test--------------------------
            const string result = "[[res]]";
            var          act    = new DsfIndexActivity {
                InField = "[[CompanyName]]", Index = "First Occurance", Characters = "2", Direction = "Left To Right", Result = result
            };

            //------------Execute Test---------------------------
            var dsfForEachItems = act.GetForEachOutputs();

            //------------Assert Results-------------------------
            Assert.AreEqual(1, dsfForEachItems.Count);
            Assert.AreEqual(result, dsfForEachItems[0].Name);
            Assert.AreEqual(result, dsfForEachItems[0].Value);
        }
        protected override void BuildDataList()
        {
            List<Tuple<string, string>> variableList;
            ScenarioContext.Current.TryGetValue("variableList", out variableList);

            if (variableList == null)
            {
                variableList = new List<Tuple<string, string>>();
                ScenarioContext.Current.Add("variableList", variableList);
            }

            variableList.Add(new Tuple<string, string>(ResultVariable, ""));
            var resultVariable = ResultVariable;
            string resultVar;
            if (ScenarioContext.Current.TryGetValue("resultVariable", out resultVar))
            {
                resultVariable = resultVar;
                var resultVars = resultVariable.Split(',');
                variableList.AddRange(resultVars.Select(resVar => new Tuple<string, string>(resVar, "")));
            }
            BuildShapeAndTestData();

            string inField;
            ScenarioContext.Current.TryGetValue("inField", out inField);
            string index;
            ScenarioContext.Current.TryGetValue("index", out index);
            string characters;
            ScenarioContext.Current.TryGetValue("characters", out characters);
            string direction;
            ScenarioContext.Current.TryGetValue("direction", out direction);

            var findIndex = new DsfIndexActivity
                {
                    Result = resultVariable,
                    InField = inField,
                    Index = index,
                    Characters = characters,
                    Direction = direction
                };

            TestStartNode = new FlowStep
                {
                    Action = findIndex
                };
            ScenarioContext.Current.Add("activity", findIndex);
        }
        public void GetActivityFieldsOffDsfIndexActivityExpectedAllFindMissingFieldsToBeReturned()
        {
            DsfIndexActivity activity = new DsfIndexActivity();

            activity.InField    = "[[InField]]";
            activity.Characters = "[[Characters]]";
            activity.Result     = "[[Result]]";
            activity.StartIndex = "[[StartIndex]]";
            Dev2FindMissingStrategyFactory fac      = new Dev2FindMissingStrategyFactory();
            IFindMissingStrategy           strategy = fac.CreateFindMissingStrategy(enFindMissingType.StaticActivity);
            List <string> actual   = strategy.GetActivityFields(activity);
            List <string> expected = new List <string> {
                "[[InField]]", "[[Characters]]", "[[Result]]", "[[StartIndex]]"
            };

            CollectionAssert.AreEqual(expected, actual);
        }
        public void Dev2FindMissingStrategyFactory_GetActivityFieldsOff_DsfIndex_Activity_ExpectAllFindMissingFieldsToBeReturned()
        {
            var activity = new DsfIndexActivity
            {
                InField    = "[[InField]]",
                Characters = "[[Characters]]",
                Result     = "[[Result]]",
                StartIndex = "[[StartIndex]]"
            };
            var fac      = new Dev2FindMissingStrategyFactory();
            var strategy = fac.CreateFindMissingStrategy(enFindMissingType.StaticActivity);
            var actual   = strategy.GetActivityFields(activity);
            var expected = new List <string> {
                "[[InField]]", "[[Characters]]", "[[Result]]", "[[StartIndex]]"
            };

            CollectionAssert.AreEqual(expected, actual);
        }
Exemple #12
0
        public void DsfIndexActivity_UpdateForEachOutputs_MoreThan1Updates_DoesNothing()
        {
            //------------Setup for test--------------------------
            const string result = "[[res]]";
            var          act    = new DsfIndexActivity {
                InField = "[[CompanyName]]", Index = "First Occurance", Characters = "2", Direction = "Left To Right", Result = result
            };

            var tuple1 = new Tuple <string, string>("Test", "Test");
            var tuple2 = new Tuple <string, string>("Test2", "Test2");

            //------------Execute Test---------------------------
            act.UpdateForEachOutputs(new List <Tuple <string, string> > {
                tuple1, tuple2
            });
            //------------Assert Results-------------------------
            Assert.AreEqual(result, act.Result);
        }
Exemple #13
0
        public void DsfIndexActivity_GetForEachInputs_WhenHasExpression_ReturnsInputList()
        {
            //------------Setup for test--------------------------
            const string inField    = "[[CompanyName]]";
            const string characters = "2";
            var          act        = new DsfIndexActivity {
                InField = inField, Index = "First Occurance", Characters = characters, Direction = "Left To Right", Result = "[[res]]"
            };

            //------------Execute Test---------------------------
            var dsfForEachItems = act.GetForEachInputs();

            //------------Assert Results-------------------------
            Assert.AreEqual(2, dsfForEachItems.Count);
            Assert.AreEqual(inField, dsfForEachItems[0].Name);
            Assert.AreEqual(inField, dsfForEachItems[0].Value);
            Assert.AreEqual(characters, dsfForEachItems[1].Name);
            Assert.AreEqual(characters, dsfForEachItems[1].Value);
        }
Exemple #14
0
        public void DsfIndexActivity_UpdateForEachInputs_MoreThan1Updates_Updates()
        {
            //------------Setup for test--------------------------
            const string inField    = "[[CompanyName]]";
            const string characters = "2";
            var          act        = new DsfIndexActivity {
                InField = inField, Index = "First Occurance", Characters = characters, Direction = "Left To Right", Result = "[[res]]"
            };

            var tuple1 = new Tuple <string, string>(characters, "Test");
            var tuple2 = new Tuple <string, string>(inField, "Test2");

            //------------Execute Test---------------------------
            act.UpdateForEachInputs(new List <Tuple <string, string> > {
                tuple1, tuple2
            });
            //------------Assert Results-------------------------
            Assert.AreEqual("Test2", act.InField);
            Assert.AreEqual("Test", act.Characters);
        }
Exemple #15
0
        public void GivenItContainsFindIndexIntoAs(string parentName, string activityName, string resultVariable, Table table)
        {
            var activity = new DsfIndexActivity {
                Result = resultVariable, DisplayName = activityName
            };

            foreach (var tableRow in table.Rows)
            {
                var variable  = tableRow["In Fields"];
                var index     = tableRow["Index"];
                var character = tableRow["Character"];
                var direction = tableRow["Direction"];

                activity.InField    = variable;
                activity.Index      = index;
                activity.Characters = character;
                activity.Direction  = direction;
            }
            _commonSteps.AddVariableToVariableList(resultVariable);
            _commonSteps.AddActivityToActivityList(parentName, activityName, activity);
        }
        public void DsfIndexActivity_GetForEachOutputs_WhenHasResult_ReturnsOutputList()
        {
            //------------Setup for test--------------------------
            const string result = "[[res]]";
            var act = new DsfIndexActivity { InField = "[[CompanyName]]", Index = "First Occurance", Characters = "2", Direction = "Left To Right", Result = result };

            //------------Execute Test---------------------------
            var dsfForEachItems = act.GetForEachOutputs();
            //------------Assert Results-------------------------
            Assert.AreEqual(1, dsfForEachItems.Count);
            Assert.AreEqual(result, dsfForEachItems[0].Name);
            Assert.AreEqual(result, dsfForEachItems[0].Value);
        }
        public void DsfIndexActivity_GetForEachInputs_WhenHasExpression_ReturnsInputList()
        {
            //------------Setup for test--------------------------
            const string inField = "[[CompanyName]]";
            const string characters = "2";
            var act = new DsfIndexActivity { InField = inField, Index = "First Occurance", Characters = characters, Direction = "Left To Right", Result = "[[res]]" };

            //------------Execute Test---------------------------
            var dsfForEachItems = act.GetForEachInputs();
            //------------Assert Results-------------------------
            Assert.AreEqual(2, dsfForEachItems.Count);
            Assert.AreEqual(inField, dsfForEachItems[0].Name);
            Assert.AreEqual(inField, dsfForEachItems[0].Value);
            Assert.AreEqual(characters, dsfForEachItems[1].Name);
            Assert.AreEqual(characters, dsfForEachItems[1].Value);
        }
        public void DsfIndexActivity_UpdateForEachOutputs_1Updates_UpdateCommandResult()
        {
            //------------Setup for test--------------------------
            var act = new DsfIndexActivity { InField = "[[CompanyName]]", Index = "First Occurance", Characters = "2", Direction = "Left To Right", Result = "[[res]]" };

            var tuple1 = new Tuple<string, string>("[[res]]", "Test");
            //------------Execute Test---------------------------
            act.UpdateForEachOutputs(new List<Tuple<string, string>> { tuple1 });
            //------------Assert Results-------------------------
            Assert.AreEqual("Test", act.Result);
        }
        public void DsfIndexActivity_UpdateForEachOutputs_MoreThan1Updates_DoesNothing()
        {
            //------------Setup for test--------------------------
            const string result = "[[res]]";
            var act = new DsfIndexActivity { InField = "[[CompanyName]]", Index = "First Occurance", Characters = "2", Direction = "Left To Right", Result = result };

            var tuple1 = new Tuple<string, string>("Test", "Test");
            var tuple2 = new Tuple<string, string>("Test2", "Test2");
            //------------Execute Test---------------------------
            act.UpdateForEachOutputs(new List<Tuple<string, string>> { tuple1, tuple2 });
            //------------Assert Results-------------------------
            Assert.AreEqual(result, act.Result);
        }
        public void DsfIndexActivity_UpdateForEachOutputs_NullUpdates_DoesNothing()
        {
            //------------Setup for test--------------------------
            const string result = "[[res]]";
            var act = new DsfIndexActivity { InField = "[[CompanyName]]", Index = "First Occurance", Characters = "2", Direction = "Left To Right", Result = result };

            act.UpdateForEachOutputs(null);
            //------------Assert Results-------------------------
            Assert.AreEqual(result, act.Result);
        }
        public void DsfIndexActivity_UpdateForEachInputs_MoreThan1Updates_Updates()
        {
            //------------Setup for test--------------------------
            const string inField = "[[CompanyName]]";
            const string characters = "2";
            var act = new DsfIndexActivity { InField = inField, Index = "First Occurance", Characters = characters, Direction = "Left To Right", Result = "[[res]]" };

            var tuple1 = new Tuple<string, string>(characters, "Test");
            var tuple2 = new Tuple<string, string>(inField, "Test2");
            //------------Execute Test---------------------------
            act.UpdateForEachInputs(new List<Tuple<string, string>> { tuple1, tuple2 });
            //------------Assert Results-------------------------
            Assert.AreEqual("Test2", act.InField);
            Assert.AreEqual("Test", act.Characters);
        }
        public void DsfIndexActivity_UpdateForEachInputs_NullUpdates_DoesNothing()
        {
            //------------Setup for test--------------------------
            const string inField = "[[CompanyName]]";
            const string characters = "2";
            var act = new DsfIndexActivity { InField = inField, Index = "First Occurance", Characters = characters, Direction = "Left To Right", Result = "[[res]]" };

            //------------Execute Test---------------------------
            act.UpdateForEachInputs(null);
            //------------Assert Results-------------------------
            Assert.AreEqual(inField, act.InField);
            Assert.AreEqual(characters, act.Characters);
        }
        public void IndexActivity_GetOutputs_Expected_One_Output()
        {
            DsfIndexActivity testAct = new DsfIndexActivity();

            IBinaryDataList outputs = testAct.GetOutputs();

            // remove test datalist ;)

            Assert.AreEqual(1, outputs.FetchAllEntries().Count);
        }
        public void IndexActivity_GetInputs_Expected_Five_Input()
        {
            DsfIndexActivity testAct = new DsfIndexActivity();

            IBinaryDataList inputs = testAct.GetInputs();

            // remove test datalist ;)

            Assert.AreEqual(6, inputs.FetchAllEntries().Count);
        }
Exemple #25
0
        public void DsfIndexActivity_GetState_Returns_Inputs_And_Outputs()
        {
            //------------Setup for test--------------------------
            var act = new DsfIndexActivity {
                InField = "[[CompanyName]]", Index = "First Occurance", Characters = "2", Direction = "Left To Right", Result = "[[res]]"
            };
            //------------Execute Test---------------------------
            var stateItems = act.GetState();

            //------------Assert Results-------------------------
            Assert.IsTrue(stateItems.Count() > 0);
            var expectedResults = new[]
            {
                new StateVariable
                {
                    Name  = "StartIndex",
                    Type  = StateVariable.StateType.Input,
                    Value = act.StartIndex
                },
                new StateVariable
                {
                    Name  = "MatchCase",
                    Type  = StateVariable.StateType.Input,
                    Value = act.MatchCase.ToString()
                },
                new StateVariable
                {
                    Name  = "Direction",
                    Type  = StateVariable.StateType.Input,
                    Value = act.Direction
                },
                new StateVariable
                {
                    Name  = "Characters",
                    Type  = StateVariable.StateType.Input,
                    Value = act.Characters
                },
                new StateVariable
                {
                    Name  = "Index",
                    Type  = StateVariable.StateType.Input,
                    Value = act.Index
                },
                new StateVariable
                {
                    Name  = "InField",
                    Type  = StateVariable.StateType.Input,
                    Value = act.InField
                },
                new StateVariable
                {
                    Name  = "Result",
                    Type  = StateVariable.StateType.Output,
                    Value = act.Result
                }
            };

            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 GivenItContainsFindIndexIntoAs(string parentName, string activityName, string resultVariable, Table table)
        {
            DsfIndexActivity activity = new DsfIndexActivity { Result = resultVariable, DisplayName = activityName };
            foreach(var tableRow in table.Rows)
            {
                var variable = tableRow["In Fields"];
                var index = tableRow["Index"];
                var character = tableRow["Character"];
                var direction = tableRow["Direction"];

                activity.InField = variable;
                activity.Index = index;
                activity.Characters = character;
                activity.Direction = direction;
            }
            CommonSteps.AddVariableToVariableList(resultVariable);
            CommonSteps.AddActivityToActivityList(parentName, activityName, activity);
        }
 public void GetActivityFieldsOffDsfIndexActivityExpectedAllFindMissingFieldsToBeReturned()
 {
     DsfIndexActivity activity = new DsfIndexActivity();
     activity.InField = "[[InField]]";
     activity.Characters = "[[Characters]]";
     activity.Result = "[[Result]]";
     activity.StartIndex = "[[StartIndex]]";
     Dev2FindMissingStrategyFactory fac = new Dev2FindMissingStrategyFactory();
     IFindMissingStrategy strategy = fac.CreateFindMissingStrategy(enFindMissingType.StaticActivity);
     List<string> actual = strategy.GetActivityFields(activity);
     List<string> expected = new List<string> { "[[InField]]", "[[Characters]]", "[[Result]]", "[[StartIndex]]" };
     CollectionAssert.AreEqual(expected, actual);
 }